getdns-0.9.0/0000775000175100017510000000000012641212403010004 500000000000000getdns-0.9.0/LICENSE0000664000175100017510000000271112641212403010732 00000000000000Copyright (c) 2013, Verisign, Inc., NLnet Labs All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. getdns-0.9.0/getdns.pc.in0000664000175100017510000000035112641212403012140 00000000000000prefix=@prefix@ exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include Name: getdns Version: @GETDNS_VERSION@ Description: A modern asynchronous DNS library Libs: -L${libdir} -lgetdns Cflags: -I${includedir} getdns-0.9.0/Makefile.in0000664000175100017510000002050212641212403011770 00000000000000# # @configure_input@ # # # Copyright (c) 2013, Verisign, Inc., NLnet Labs # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the names of the copyright holders nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package = @PACKAGE_NAME@ version = @PACKAGE_VERSION@@RELEASE_CANDIDATE@ tarname = @PACKAGE_TARNAME@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ distdir = $(tarname)-$(version) bintar = $(distdir)-bin.tar.gz prefix = @prefix@ datarootdir=@datarootdir@ exec_prefix = @exec_prefix@ bindir = @bindir@ docdir = @docdir@ libdir = @libdir@ srcdir = @srcdir@ INSTALL = @INSTALL@ all : default @GETDNS_QUERY@ default: cd src && $(MAKE) $@ install: all getdns.pc @INSTALL_GETDNS_QUERY@ $(INSTALL) -m 755 -d $(DESTDIR)$(docdir) $(INSTALL) -m 644 $(srcdir)/AUTHORS $(DESTDIR)$(docdir) $(INSTALL) -m 644 $(srcdir)/ChangeLog $(DESTDIR)$(docdir) $(INSTALL) -m 644 $(srcdir)/COPYING $(DESTDIR)$(docdir) $(INSTALL) -m 644 $(srcdir)/INSTALL $(DESTDIR)$(docdir) $(INSTALL) -m 644 $(srcdir)/LICENSE $(DESTDIR)$(docdir) $(INSTALL) -m 644 $(srcdir)/NEWS $(DESTDIR)$(docdir) $(INSTALL) -m 644 $(srcdir)/README.md $(DESTDIR)$(docdir) $(INSTALL) -m 755 -d $(DESTDIR)$(libdir)/pkgconfig $(INSTALL) -m 644 getdns.pc $(DESTDIR)$(libdir)/pkgconfig $(INSTALL) -m 755 -d $(DESTDIR)$(docdir)/spec $(INSTALL) -m 644 $(srcdir)/spec/index.html $(DESTDIR)$(docdir)/spec $(INSTALL) -m 644 $(srcdir)/spec/getdns*tgz $(DESTDIR)$(docdir)/spec || true cd src && $(MAKE) $@ cd doc && $(MAKE) $@ @echo "***" @echo "*** !!! IMPORTANT !!!! libgetdns needs a DNSSEC trust anchor!" @echo "***" @echo "*** For the library to be able to perform DNSSEC, the root" @echo "*** trust anchor needs to be present in presentation format" @echo "*** in the file: " @echo "*** @TRUST_ANCHOR_FILE@" @echo "***" @echo "*** We recomend using unbound-anchor to retrieve and install" @echo "*** the root trust anchor like this: " @echo "*** mkdir -p `dirname @TRUST_ANCHOR_FILE@`" @echo "*** unbound-anchor -a \"@TRUST_ANCHOR_FILE@\"" @echo "***" @echo "*** We strongly recommend package maintainers to provide the" @echo "*** root trust anchor by installing it with unbound-anchor" @echo "*** at package installation time from the post-install script." @echo "***" uninstall: @UNINSTALL_GETDNS_QUERY@ rm -rf $(DESTDIR)$(docdir) cd doc && $(MAKE) $@ cd src && $(MAKE) $@ doc: FORCE cd doc && $(MAKE) $@ example: cd spec/example && $(MAKE) $@ test: cd src && $(MAKE) $@ getdns_query: cd src && $(MAKE) $@ scratchpad: cd src && $(MAKE) $@ pad: scratchpad src/test/scratchpad || ./libtool exec gdb src/test/scratchpad install-getdns_query: cd src/test && $(MAKE) install uninstall-getdns_query: cd src/test && $(MAKE) uninstall clean: cd src && $(MAKE) $@ cd doc && $(MAKE) $@ cd spec/example && $(MAKE) $@ rm -f *.o *.pc depend: cd src && $(MAKE) $@ cd spec/example && $(MAKE) $@ distclean: cd src && $(MAKE) $@ rmdir src 2>/dev/null || true cd doc && $(MAKE) $@ rmdir doc 2>/dev/null || true cd spec/example && $(MAKE) $@ rmdir spec/example 2>/dev/null || true rmdir spec 2>/dev/null || true rm -f config.log config.status Makefile libtool getdns.pc rm -fR autom4te.cache rm -f m4/libtool.m4 rm -f m4/lt~obsolete.m4 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.md5 $(distdir).tar.gz.asc megaclean: cd $(srcdir) && rm -fr * .dir-locals.el .gitignore .indent.pro .travis.yml && git reset --hard dist: $(distdir).tar.gz pub: $(distdir).tar.gz.sha1 $(distdir).tar.gz.md5 $(distdir).tar.gz.asc $(distdir).tar.gz.sha1: $(distdir).tar.gz openssl sha1 $(distdir).tar.gz >$@ $(distdir).tar.gz.md5: $(distdir).tar.gz openssl md5 $(distdir).tar.gz >$@ $(distdir).tar.gz.asc: $(distdir).tar.gz gpg --armor --detach-sig $(distdir).tar.gz bindist: $(bintar) $(bintar): $(distdir) chown -R 0:0 $(distdir) 2>/dev/null || true cd $(distdir); ./configure; make tar chof - $(distdir) | gzip -9 -c > $@ rm -rf $(distdir) $(distdir).tar.gz: $(distdir) chown -R 0:0 $(distdir) 2>/dev/null || true tar chof - $(distdir) | gzip -9 -c > $@ rm -rf $(distdir) $(distdir): mkdir -p $(distdir)/m4 mkdir -p $(distdir)/src mkdir -p $(distdir)/src/getdns mkdir -p $(distdir)/src/test mkdir -p $(distdir)/src/extension mkdir -p $(distdir)/src/compat mkdir -p $(distdir)/src/util mkdir -p $(distdir)/src/gldns mkdir -p $(distdir)/doc mkdir -p $(distdir)/spec mkdir -p $(distdir)/spec/example cp $(srcdir)/configure.ac $(distdir) cp $(srcdir)/configure $(distdir) cp $(srcdir)/AUTHORS $(distdir) cp $(srcdir)/ChangeLog $(distdir) cp $(srcdir)/COPYING $(distdir) cp $(srcdir)/INSTALL $(distdir) cp $(srcdir)/LICENSE $(distdir) cp $(srcdir)/NEWS $(distdir) cp $(srcdir)/README.md $(distdir) cp $(srcdir)/Makefile.in $(distdir) cp $(srcdir)/install-sh $(distdir) cp $(srcdir)/config.sub $(distdir) cp $(srcdir)/config.guess $(distdir) cp $(srcdir)/getdns.pc.in $(distdir) cp libtool $(distdir) cp $(srcdir)/ltmain.sh $(distdir) cp $(srcdir)/m4/*.m4 $(distdir)/m4 cp $(srcdir)/src/*.in $(distdir)/src cp $(srcdir)/src/*.[ch] $(distdir)/src cp $(srcdir)/src/*.symbols $(distdir)/src cp $(srcdir)/src/extension/*.[ch] $(distdir)/src/extension cp $(srcdir)/src/extension/*.symbols $(distdir)/src/extension cp $(srcdir)/src/getdns/*.in $(distdir)/src/getdns cp $(srcdir)/src/getdns/getdns_*.h $(distdir)/src/getdns cp $(srcdir)/src/test/Makefile.in $(distdir)/src/test cp $(srcdir)/src/test/*.[ch] $(distdir)/src/test cp $(srcdir)/src/test/*.sh $(distdir)/src/test cp $(srcdir)/src/test/*.good $(distdir)/src/test cp $(srcdir)/src/compat/*.[ch] $(distdir)/src/compat cp $(srcdir)/src/util/*.[ch] $(distdir)/src/util cp $(srcdir)/src/gldns/*.[ch] $(distdir)/src/gldns cp $(srcdir)/doc/Makefile.in $(distdir)/doc cp $(srcdir)/doc/*.in $(distdir)/doc cp $(srcdir)/doc/manpgaltnames $(distdir)/doc cp $(srcdir)/spec/*.html $(distdir)/spec cp $(srcdir)/spec/*.tgz $(distdir)/spec || true cp $(srcdir)/spec/example/Makefile.in $(distdir)/spec/example cp $(srcdir)/spec/example/*.[ch] $(distdir)/spec/example rm -f $(distdir)/Makefile $(distdir)/src/Makefile $(distdir)/src/getdns/getdns.h $(distdir)/spec/example/Makefile $(distdir)/src/test/Makefile $(distdir)/doc/Makefile $(distdir)/src/config.h distcheck: $(distdir).tar.gz gzip -cd $(distdir).tar.gz | tar xvf - cd $(distdir) && ./configure cd $(distdir) && $(MAKE) all cd $(distdir) && $(MAKE) check cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall @remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \ if test "$${remaining}" -ne 0; then echo "@@@ $${remaining} file(s) remaining in stage directory!"; \ exit 1; \ fi cd $(distdir) && $(MAKE) clean rm -rf $(distdir) @echo "*** Package $(distdir).tar.gz is ready for distribution" getdns.pc: $(srcdir)/getdns.pc.in ./config.status $@ Makefile: $(srcdir)/Makefile.in config.status ./config.status $@ configure.status: configure ./config.status --recheck .PHONY: all distclean clean default doc test FORCE: getdns-0.9.0/COPYING0000664000175100017510000000271112641212403010760 00000000000000Copyright (c) 2013, Verisign, Inc., NLnet Labs All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. getdns-0.9.0/install-sh0000755000175100017510000003325512641212403011736 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-11-20.07; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: getdns-0.9.0/NEWS0000664000175100017510000000004312641212403010420 00000000000000this page intentionally left blank getdns-0.9.0/ChangeLog0000664000175100017510000003320212641212403011476 00000000000000* 2015-12-31: Version 0.9.0 * Update of unofficial extension to the API that supports stub mode TLS verification. GETDNS_AUTHENTICATION_HOSTNAME is replaced by GETDNS_AUTHENTICATION_REQUIRED (but remains available as an alias). Upstreams can now be configured with either a hostname or a SPKI pinset for TLS authentication (or both). If the GETDNS_AUTHENTICATION_REQUIRED option is used at least one piece of authentication information must be configured for each upstream, and all the configured authentication information for an upstream must validate. * Remove STARTTLS implementation (no change to SPEC) * Enable TCP Fast Open when possible. Add OSX support for TFO. * Rename return_call_debugging to return_call_reporting * Bugfix: configure problem with getdns-0.5.1 on OpenBSD Thanks Claus Assmann. * pkg-config support. Thanks Neil Cook. * Functions to convert from RR dicts to wireformat and text format and vice versa. Including a function that builds a getdns_list of RR dicts from a zonefile. * Use the with the getdns_context_set_dns_root_servers() function provided root servers in recursing resolution modus. * getdns_query option (-f) to read a DNSSEC trust anchor from file. * getdns_query option (-R) to read a "root hints" file. * Bugfix: Detect and prevent duplicate NSEC(3)s to be returned with dnssec_return_validation_chain. * Bugfix: Remove duplicate RRs from RRsets when DNSSEC verifying * Client side edns-tcp-keepalive support * TSIG support + getdns_query syntax to specify TSIG parameters per upstream: @[^[:]:] * Bugfix: Allow truncated answers to be returned in case of missing fallback transport. * Verify upstream TLS pubkeys with pinsets; A getdns_query option (-K) to attach pinsets to getdns_contexts. Thanks Daniel Kahn Gillmor * Initial support for Windows. Thanks Gowri Visweswaran * add_warning_for_bad_dns extension * Try and retry with suffixes giving with getdns_context_set_suffix() following directions given by getdns_context_set_append_name() getdns_query options to set suffixes and append_name directions: '-W' to append suffix always (default) '-1' to append suffix only to single label after failure '-M' to append suffix only to multi label name after failure '-N' to never append a suffix '-Z ' to set suffixes with the given comma separed list * Better help text for getdns_query (printed with the '-h' option) * Setting the +specify_class extension with getdns_query * Return NOT_IMPLEMENTED for not implemented namespaces, and the not implemented getdns_context_set_follow_redirects() function. * 2015-11-18: Version 0.5.1 * Bugfix: growing upstreams arrow. * Bugfix: Segfault on timeout in specific conditions * Bugfix: install getdns_extra.h from build location * Bugfix: Don't let cookies overwrite existing EDNS0 options * Don't link libdl * The EDNS(0) Padding Option (draft-mayrhofer-edns0-padding). When using DNS over TLS, query sizes will be padded to multiples of a block size given with: getdns_context_set_tls_query_padding_blocksize() * An EDNS client subnet private option, that will ask a EDNS client subnet aware resolver to not reveal any details about the originating network. See: draft-ietf-dnsop-edns-client-subnet Set with: getdns_context_set_edns_client_subnet_private() * The return_call_debugging extension. The extension will also return the transport used on top of the information about the request which is described in the API spec. * A dnssec_roadblock_avoidance extension. When set, the library will work in stub resolution mode and try to get a by DNSSEC validation assessed answer. On BOGUS answers the library will retry rescursive resolution mode. This is the simplest form of passive roadblock detection and avoidance: draft-ietf-dnsop-dnssec-roadblock-avoidance. Use the --enable-draft-dnssec-roadblock-avoidance option to configure to compile with this extension. * 2015-10-29: Version 0.5.0 * Native crypto. No ldns dependency anymore. (ldns still necessary to be able to run tests though) * JSON pointer arguments to getdns_dict_get_* and getdns_dict_set_* to dereference nested dicts and lists. * Bugfix: DNSSEC code finding zone cut with redirects + pursuing unsigned DS answers close to the root. Thanks Theogene Bucuti! * Default port for TLS changed to 853 * Unofficial extension to the API to allow TLS hostname verification to be required for stub mode when using only TLS as a transport. When required a hostname must be supplied in the 'hostname' field of the upstream_list dict and the TLS cipher suites are restricted to the 4 AEAD suites recommended in RFC7525. * 2015-09-09: Version 0.3.3 * Fix clearing upstream events on shutdown * Fix dnssec validation of direct CNAME queries. Thanks Simson L. Garfinkel. * Fix get_api_information():version_string also for release candidates * 2015-09-04: Version 0.3.2 * Fix returned upstreams list by getdns_context_get_api_information() * Fix some autoconf issues when srcdir != builddir * Fix remove build date from manpage version for reproducable builds * Fix transport fallback issues plus transport fallback unit test script * Fix string bindata's need not contain trailing zero byte * --enable-stub-only configure option for stub only operation. Stub mode will be the default. Removes the dependency on libunbound * --with-getdns_query compiles and installs the getdns_query tool too * Fix assert on context destruction from a callback in stub mode too. * Use a thread instead of a process for running the unbound event loop. * 2015-07-18: Version 0.3.1 * Fix repeating rdata fields * 2015-07-17: Version 0.3.0 * Unit test for spurious execute bits. Thanks Paul Wouters. * Added new transport list options in API. The option is now an ordered list of GETDNS_TRANSPORT_UDP, GETDNS_TRANSPORT_TCP, GETDNS_TRANSPORT_TLS, GETDNS_TRANSPORT_STARTTLS. * Added new context setting for idle_timeout * CSYNC RR type * EDNS0 COOKIE option code set to 10 * dnssec_return_validation_chain for negative and insecure responses. * dnssec_return_validation_chain return a single RRSIG on each RRSET (whenever possible) * getdns_validate_dnssec() accept replies from the replies_tree * getdns_validate_dnssec() asses negative and insecure responses. * Native stub dnssec validation * Implemented getdns_context_set_dnssec_trust_anchors() * Switch freely between stub and recursive mode * getdns_query -k shows default trust anchors * functions and defines to get library and API versions in string and numeric values: getdns_get_version(), getdns_get_version_number(), getdns_get_api_version() and getdns_get_api_version_number() * 2015-05-21: Version 0.2.0 * Fix libversion numbering: Thanks Daniel Kahn Gillmor * run_once method for the libevent extension * autoreconf -fi on FreeBSD always, because of newer libtool version suitable for FreeBSD installs too. Thanks Robert Edmonds * True asynchronous processing of the new TLS transport options * GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN transport option. * Manpage fixes: Thanks Anthony Kirby * 2015-04-19: Version 0.1.8 * The GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN and GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN DNS over TLS transport options. * 2015-04-08: Version 0.1.7 * Individual getter functions for context settings * Fix: --with-current-date function to make build deterministically reproducible (i.e. the GETDNS_COMPILATION_COMMENT define from getdns.h contains a date value). Thanks Ondřej Surý * Fix: Include m4 dir in distribution tarball * Fix: Link build requirements in tests too. Thanks Ondřej Surý * Fix: Remove executable flags on source files. Thanks Paul Wouters * Fix: Return "just_address_answers" only when queried for addresses * Eliminate ldns intermediate wireformat parsing * The CSYNC RR type * Fix: canonical_name in response dict returns the canonical name found after following all CNAMEs * Implementation of the section 6 and 7 version of draft-ietf-dnsop-cookies-01.txt for stub resolution. Enable with the --enable-draft-edns-cookies option to configure. Use it by setting the edns_cookies extension to GETDNS_EXTENSION_TRUE. * Pretty printing of lists with: char *getdns_pretty_print_list(getdns_list *list) * Output to json format with: char * getdns_print_json_dict(const getdns_dict *some_dict, int pretty); char * getdns_print_json_list(const getdns_list *some_list, int pretty); * snprintf style versions of the dict, list and json print functions. * Better random number generation with OpenBSD's arc4random * Let getdns_address schedule the AAAA query first. This results in AAAA being the first in the just_address_answers sections of the response dict. * New context update callback function to also return a user given argument along with the context and which item was changed. Thanks Scott Hollenbeck. * Demotivate use of getdns_strerror and expose getdns_get_errorstr_by_id. Thanks Scott Hollenbeck. * A getter for context update callback, to allow for chaining update callbacks. * 2015-01-16: Version 0.1.6 * Fix: linking against libev on FreeBSD * Fix: Let configure report problem on FreeBSD when configuring with libevent and libunbound <= 1.4.22 is not compiled with libevent. * Fix: Build on Mac OS-X * Fix: Lintian errors in manpages * Better libcheck detection * Better portability with UNIX systems * 2014-10-31: Version 0.1.5 * Unit tests for transport settings * Fix: adhere to set maximum UDP payload size * API change: when no maximum UDP payload size is set, outgoing values will adhere to the suggestions in RFC 6891 and may follow a scheme that uses multiple values to maximize receptivity. * Stub mode use 1232 maximum UDP payload size when connecting to an IPv6 upstreams and 1432 with an IPv4 upstream. * Evaluate namespaces (or not) on a per query basis * GETDNS_NAMESPACE_LOCALNAMES namespace now gives just_address_answers only and does not mimic a DNS packet answer anymore * The add_opt_parameters extension * IPv6 scope_id support with link-local addresses. Both with parsing /etc/resolv.conf and by providing them explicitly via getdns_context_set_upstream_recursive_servers * Query for A and AAAA simultaneously with return_both_v4_and_v6 * GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN DNS transport * Fix: Answers without RRs in query secion (i.e. REFUSED) * Fix: Return empty response dict on timeout in async mode too * Move spec examples to spec subdirectory * Fix issue#76: Setting UDP Payload size below 512 should not error * Fix: Include OPT RR in response dict always (even without options) * TCP Fast open support (linux only). Enable with the --enable-tcp-fastopen configure option * Bump library version because of binary API change * 2014-09-03: Version 0.1.4 * Synchronous resolves now respect timeout setting, * On timeout *_sync functions now return GETDNS_RETURN_GOOD and a response dict with "status" GETDNS_RESPSTATUS_ALL_TIMEOUT> * Fix issue#50: getdns_dict_remove_name returns GETDNS_RETURN_GOOD on success. * Fix Issue#54: set_ub_dns_transport() not working * Fix Issue#49: Typo in documentation (thanks Stephane Bortzmeyer) * getdns_context_set_limit_outstanding_queries(), getdns_context_set_dnssec_allowed_skew() and getdns_context_set_edns_maximum_udp_payload_size() now working * _unknown rdata field for unknown or unsupported RR types * Temporarily disable timeout unit test 3 because of unpredictable results * Spec updated to version 0.507 * Renamed "resolver_type" to "resolution_type" in dict returned from getdns_context_get_api_information() * Added GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS return code for with the dnssec_return_only_secure extension * Added support for CDS and CDNSKEY RR types, but needs ldns > 1.6.17 to be able to parse the wire format (not released yet at time of writing) * Added OPENPGPKEY RR type, but no rdata fields implementation yet * Updated spec to version 0.508 (September 2014) * Also chase NSEC and NSEC3 RRSIGs with dnssec_return_validation_chain * 2014-06-25: Version 0.1.3 * libtool chage, remove -release, added -version-info * Update specification to the June 2014 version (0.501) * 2014-06-02: Version 0.1.2 * Fixed rdata fields for MX * Expose only public API symbols * Updated manpages * specify_class extension * Build from separate build directory * Anticipate libunbound not returning the answer packet * Pretty print bindata's representing IP addresses * Anticipate absense of implicit DSO linking * Mention getdns specific options to configure in INSTALL Thanks Paul Hoffman * Mac OSX package built instructions for generic user in README.md Thanks Joel Purra * Fixed build problems on RHEL/CentOS due using libevent 1.x * 2014-03-24 : Version 0.1.1 * default to NOT build extensions (libev, libuv, libevent), handle --with/--without options to configure for them * Fixed some build/make nits * respect configure --docdir=X * Documentation/man page updates * Fix install and cpp guards in getdns_extra.h * Add method to switch between threads and fork mode for unbound * Fixes for libuv integration (saghul) * Fixes for calling getdns_destroy_context within a callback * Fixed signal related defines/decls * 2014-02-25 : Version 0.1.0 * Initial public release of the getdns API getdns-0.9.0/config.guess0000755000175100017510000012355012641212403012250 00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2014 Free Software Foundation, Inc. timestamp='2014-03-23' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches with a ChangeLog entry to config-patches@gnu.org. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: getdns-0.9.0/doc/0000775000175100017510000000000012641212403010551 500000000000000getdns-0.9.0/doc/getdns_hostname.3.in0000664000175100017510000001250012641212403014342 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_hostname 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_hostname, .B getdns_hostname_sync -- get hostname by address .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_hostname (getdns_context *context, .RS 3 getdns_dict *address, .br getdns_dict *extensions, .br void *userarg, .br getdns_transaction_t *transaction_id, .br getdns_callback_t callbackfn) .RE getdns_return_t .br .B getdns_hostname_sync (getdns_context *context, .RS 3 getdns_dict *address, .br getdns_dict *extensions, .br getdns_dict **response) .RE .SH DESCRIPTION .LP The getdns_hostname(3) and getdns_hostname_sync functions provide public entry points into the getdns API library to retrieve the host name given an address. .HP 3 .I context A pointer to the previously created DNS context that is to be used with this DNS request. see getdns_context (3) .HP 3 .I address a getdns_dict structure containing two names: address_type (whose value is bindata and is either "IPv4" or "IPv6") and address_data whose value is bindata .HP 3 .I extensions extensions for this request, NULL if no extensions, see libgetdns (3) for a detailed description of extensions .HP 3 .I userarg returned to the callback function untouched, can be NULL .HP 3 .I transaction_id populated by the API and used to identify the callback (for example to getdns_cancel_callback), can be NULL, set to 0 if the function fails .HP 3 .I callbackfn non-NULL pointer to a callback function defined by the application, typically used to process the response. Only the asynchronous signature accepts a callback function, the synchronous signature does not include a callback. See libgetdns (3) for a more detailed discussion of callback functions. .HP 3 .I response A getdns_dict type is returned in response and always contains at least three names: replies_full (a list containing the DNS response as binary data), replies_tree (a list containing the parsed DNS response data) and status (an int). The storage associated with this must be freed by a call to getdns_free_sync_request_memory (3). .HP .SH "RETURN VALUES" Upon successful completion the functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_BAD_CONTEXT if the context pointer is invalid or the context has internal deficiencies .LP .B GETDNS_RETURN_BAD_DOMAIN_NAME if the domain name passed to the function is invalid .LP .B GETDNS_RETURN_EXTENSION_MISFORMAT if the data type specified in one or more of the extensions does not match the specifications .LP .B GETDNS_RETURN_GENERIC_ERROR if some problem was encountered in the function not addressed by one of the more specific return codes .LP .B GETDNS_RETURN_INVALID PARAMETER if one or more parameters has an invalid value .LP .B GETDNS_RETURN_MEMORY_ERROR if unable to allocate the memory required .LP .B GETDNS_RETURN_NO_SUCH_EXTENSION if one or more of the strings specified in the extensions are not valid The values of status included in the response parameter are: .LP .B GETDNS_RESPSTATUS_GOOD if at least one response was returned .LP .B GETDNS_RESPSTATUS_NO_NAME if queries for the name yielded all negative responses .LP .B GETDNS_RESPSTATUS_ALL_TIMEOUT if all queries for the name timed out .LP .B GETDNS_RESPSTATUS_NO_SECURE_ANSWERS if only secure replies accepted (per context) and at least one response was received but no DNS responses were secure through DNSSEC .LP For a more detailed explanation of the response object see .I libgetdns (3) .SH EXAMPLES TBD .SH FILES .br /etc/hosts .br /etc/resolv.conf .SH SEE ALSO .BR libgetdns (3), .BR getdns_context (3), .BR getdns_free_sync_request_memory (3), .BR getdns_general (3), .BR getdns_address (3), .BR getdns_service (3), getdns-0.9.0/doc/getdns_convert.3.in0000664000175100017510000000717312641212403014216 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_convert 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_convert, .B getdns_convert_dns_name_to_fqdn, .B getdns_convert_fqdn_to_dns_name -- convert dname between presentation- and wire-format .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_convert_dns_name_to_fqdn (const getdns_bindata *dns_name_wire_fmt, .br .RS 3 char **fqdn_as_string) .RE getdns_return_t .br .B getdns_convert_fqdn_to_dns_name (char *fqdn_as_string, .br .RS 3 const getdns_bindata **dns_name_wire_fmt) .RE .SH DESCRIPTION .LP Names in DNS fields are stored in a fashion very different from the normal presentation format normally used in applications. The DNS format is described in the first paragraph in Section 3.1 of RFC 1035; the presentation format here is a null-terminated string with interior dots. These helper functions only work with names in the DNS format that are not compressed. They are useful for converting domain names in the replies_tree to and from the FQDN presentation format. getdns_convert_dns_name_to_fqdn() converts a domain name in DNS format to the presentation format. For example, the hex sequence 03 77 77 77 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 would be converted to "www.example.com". getdns_convert_fqdn_to_dns_name() does the reverse: it converts a null-terminated string in FQDN format to bytes in DNS format. .HP 3 .I dns_name_wire_fmt The non-compressed DNS wire format name (per RFC 1035) in a bindata structure that will be converted to/from an fqdn. In getdns_convert_fqdn_to_dns_name storage is allocated using the system allocator (malloc) and must be freed by the caller. .HP 3 .I fqdn_as_string a null terminated string to be converted to/from non-compressed DNS wire format name (per RFC 1035). In getdns_convert_dns_name_to_fqdn storage is allocated using the system allocator (malloc) and must be freed by the caller. .HP .SH "RETURN VALUES" Upon successful completion the function returns .B GETDNS_RETURN_GOOD .SH EXAMPLES TBD .SH SEE ALSO .BR libgetdns (3) getdns-0.9.0/doc/getdns_context_set_context_update_callback.3.in0000664000175100017510000000562712641212403022021 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_context_set_context_update_callback 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_context_set_context_update_callback -- get informed on getdns context updates .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_context_set_context_update_callback (getdns_context ** context, .RS 3 .br void (*cbfun)(getdns_context *context, getdns_context_code_t changed_item) .RE .SH DESCRIPTION .LP Changes to the context such as in response to system files that affect the contet (/etc/resolv.conf etc.) trigger a call to the callback function specified as .B cbfun .HP 3 .I context a previously initialized context .HP 3 .I cbfun callback function to invoked when the specified context changes. If this argument is NULL then updates to the context will not invoke a callback. .HP .SH "RETURN VALUES" Upon successful completion each of these functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_GENERIC_ERROR memory allocation failed or some other untoward thing happened .LP .B GETDNS_RETURN_BAD_CONTEXT if the context pointer is invalid .SH EXAMPLES TBD .SH SEE ALSO .BR libgetdns (3), .BR getdns_context_create (3), .BR getdns_context_set (3), .BR getdns_context_set_context_update_callback (3), getdns-0.9.0/doc/getdns_display_ip_address.3.in0000664000175100017510000000461312641212403016374 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_display_ip_address 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_display_ip_address -- convert an getdns ip address to string .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include char * .br .B getdns_display_ip_address (const getdns_bindata *ipv4_or_ipv6_addr) .SH DESCRIPTION .LP This helper function returns a nicely formatted string representation of the IPv4 or IPv6 address. The length of the bindata is used to determine whether the address is IPv4 or IPv6. .HP 3 .I ipv4_or_ipv6_addr bindata of the address to print .HP .SH "RETURN VALUES" Returns a string representation of the IP address (allocated using the system allocator - malloc), the caller is responsible for freeing the storage using free(). .SH EXAMPLES TBD .SH SEE ALSO .BR libgetdns (3) getdns-0.9.0/doc/getdns_list_get.3.in0000664000175100017510000000736612641212403014354 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_list 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_list_get, .B getdns_list_get_bindata, .B getdns_list_get_data_type, .B getdns_list_get_dict, .B getdns_list_get_length, .B getdns_list_get_list, .B getdns_list_get_int -- get a value by index from a getdns list .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_list_get_bindata (getdns_list *this_list, .RS 3 size_t index, .br getdns_bindata **answer) .RE getdns_return_t .br .B getdns_list_get_data_type (getdns_list *this_list, .RS 3 size_t index, .br getdns_data_type *answer) .RE getdns_return_t .br .B getdns_list_get_dict (getdns_list *this_list, .RS 3 size_t index, .br getdns_dict **answer) .RE getdns_return_t .br .B getdns_list_get_length (getdns_list *this_list, .RS 3 size_t *answer) .RE getdns_return_t .br .B getdns_list_get_list (getdns_list *this_list, .RS 3 size_t index, .br getdns_list **answer) .RE getdns_return_t .br .B getdns_list_get_int (getdns_list *this_list, .RS 3 size_t index, .br uint32_t *answer) .RE .SH DESCRIPTION .LP The getdns_list type is used to manage heterogeneous lists in which the objects are each one of the data types: .RS 3 .br getdns_bindata .br getdns_dict .br getdns_list .br uint32_t .RE .LP .I this_list the list from which to retrieve the object .LP .I index the numeric index (0 based) of the item in the list you would like copied to answer .LP .I answer a copy of the object in the list is placed in answer, the caller is responsible for freeing the storage associated with that object by calling the appropriate destroy function. .SH "RETURN VALUES" Upon successful completion the functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_GENERIC_ERROR if this_list is not a valid list .LP .B GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range .LP .B GETDNS_RETURN_WRONG_TYPE_REQUESTED if the requested data type doesn't match the contents of the indexed argument .SH EXAMPLES TBD .SH SEE ALSO .BR libgetdns (3), .BR getdns_address (3), .BR getdns_dict (3), .BR getdns_general (3), .BR getdns_hostname (3), .BR getdns_service (3), getdns-0.9.0/doc/Makefile.in0000664000175100017510000000777112641212403012552 00000000000000# # @configure_input@ # # # Copyright (c) 2013, Verisign, Inc., NLnet Labs # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the names of the copyright holders nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package = @PACKAGE_NAME@ version = @PACKAGE_VERSION@ tarname = @PACKAGE_TARNAME@ distdir = $(tarname)-$(version) api_version = @API_VERSION@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ # datarootdir is here to please some checkers datarootdir=@datarootdir@ mandir = @mandir@ INSTALL = @INSTALL@ srcdir = @srcdir@ VPATH = @srcdir@ EDITS=-e 's/@''version@/$(version)/g' DOXYGEN = @DOXYGEN@ DOCDIRS = html latex man MANPAGES3 = libgetdns.3 getdns_address.3 getdns_cancel_callback.3 getdns_context.3 getdns_context_set.3 getdns_context_set_context_update_callback.3 getdns_convert.3 getdns_dict.3 getdns_dict_get.3 getdns_dict_set.3 getdns_display_ip_address.3 getdns_general.3 getdns_hostname.3 getdns_list.3 getdns_list_get.3 getdns_list_set.3 getdns_pretty_print_dict.3 getdns_root_trust_anchor.3 getdns_service.3 getdns_validate_dnssec.3 default: all all: doc doc: $(MANPAGES3) if test x_$(DOXYGEN) != x_ ; then cd ../src; doxygen; fi .SUFFIXES: .3.in .3 .3.in.3: sed $(EDITS) -e "s/@date@/$(api_version)/g" $< > $@ # we assume that we want a separate file for each "name" specified for each man page # and consider these "alternate names" simple copies of the main man page install: $(MANPAGES3) $(INSTALL) -m 755 -d $(DESTDIR)$(mandir) $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man3 for x in $(MANPAGES3); do echo $(INSTALL) -m 644 $$x $(DESTDIR)$(mandir)/man3; $(INSTALL) -m 644 $$x $(DESTDIR)$(mandir)/man3; for altpg in $$($(srcdir)/manpgaltnames $$x); do cp $$x $$altpg; echo $(INSTALL) -m 644 $$altpg $(DESTDIR)$(mandir)/man3; $(INSTALL) -m 644 $$altpg $(DESTDIR)$(mandir)/man3; done; done check: $(MANPAGES3) for x in $(MANPAGES3); do LC_ALL=en_US.UTF-8 MANROFFSEQ='' MANWIDTH=80 man --warnings -E UTF-8 -l -Tutf8 -Z $$x 2>&1 >/dev/null | awk "-vpage=$$x" '{printf("%s: ", page);print}'; if ! lexgrog $$x >/dev/null 2>&1 ; then echo $$x: manpage-has-bad-whatis-entry; fi; done uninstall: for x in $(MANPAGES3); do echo rm -f $(DESTDIR)$(mandir)/man3/$$x; rm -f $(DESTDIR)$(mandir)/man3/$$x; for altpg in $$($(srcdir)/manpgaltnames $$x); do echo rm -f $(DESTDIR)$(mandir)/man3/$$altpg; rm -f $(DESTDIR)$(mandir)/man3/$$altpg; done; done clean: for x in $(MANPAGES3); do rm -f $$($(srcdir)/manpgaltnames $$x); done rm -rf $(DOCDIRS) $(MANPAGES3) distclean : clean rm -f Makefile config.status config.log rm -Rf autom4te.cache Makefile: Makefile.in ../config.status cd .. && ./config.status $@ configure.status: configure cd .. && ./config.status --recheck .PHONY: clean $(DOC) getdns-0.9.0/doc/getdns_list_set.3.in0000664000175100017510000000667412641212403014371 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_list_set 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_list_set, .B getdns_list_set_bindata, .B getdns_list_set_dict, .B getdns_list_set_int, .B getdns_list_set_list, -- set a value by index from a getdns list .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_list_set_bindata (getdns_list *this_list, .RS 3 size_t index, .br getdns_bindata *child_bindata) .RE getdns_return_t .br .B getdns_list_set_dict (getdns_list *this_list, .RS 3 size_t index, .br getdns_dict *child_dict) .RE getdns_return_t .br .B getdns_list_set_int (getdns_list *this_list, .RS 3 size_t index, .br uint32_t child_uint32_t) .RE getdns_return_t .br .B getdns_list_set_list (getdns_list *this_list, .RS 3 size_t index, .br getdns_list *child_list) .RE .SH DESCRIPTION .LP The getdns_list type is used to manage a heterogeneous indexed list of values that include: .RS 3 .br getdns_bindata .br getdns_dict .br getdns_list .br uint32_t .RE .LP .I this_list the list in which to add/update the indexed item .LP .I index the index whose associated value is to be set. If the index exists in the list the value associated with that index is replaced, if the index does not exist in the list a new item is added to the list at the specified index. .LP .I child_bindata .I child_dict .I child_list .I child_uint32 value to assign the indexed element .SH "RETURN VALUES" Upon successful completion the functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range .LP .B GETDNS_RETURN_GENERIC_ERROR if this_list is not a valid list .SH EXAMPLES TBD .SH SEE ALSO .BR libgetdns (3), .BR getdns_address (3), .BR getdns_list (3), .BR getdns_list_get (3), .BR getdns_general (3), .BR getdns_hostname (3), .BR getdns_service (3), getdns-0.9.0/doc/getdns_root_trust_anchor.3.in0000664000175100017510000000534212641212403016310 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_root_trust_anchor 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_root_trust_anchor -- return the getdns list of default root trust anchors .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_list * .br .B getdns_root_trust_anchor (time_t *utc_date_of_anchor) .SH DESCRIPTION .LP If an application wants the API to perform DNSSEC validation without using the extensions, it can use the getdns_validate_dnssec() helper function. The API will use the resource records in bundle_of_support_records to construct the validation chain and the DNSKEY or DS records in trust_anchor_records as trust anchors. The default list of trust anchor records that is used by the library to validate DNSSEC can be retrieved by using the getdns_root_trust_anchor helper function. .HP 3 .I utc_date_of_anchor time the trust anchors were obtained in epoch seconds (on success) .HP .SH "RETURN VALUES" Returns the default list of trust anchor records used by the library to validate DNSSEC or NULL if no default trust anchors are available. .SH EXAMPLES TBD .SH SEE ALSO .BR getdns_validate_dnssec (3) .BR libgetdns (3) getdns-0.9.0/doc/getdns_dict.3.in0000664000175100017510000000707712641212403013464 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_dict 3 "@date@" "getdns @version@" getdns .ad l .SH NAME .B getdns_dict, .B getdns_dict_create, .B getdns_dict_create_with_extended_memory_functions, .B getdns_dict_create_with_memory_functions, .B getdns_dict_destroy -- getdns dict create and destroy routines .ad n .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_dict * .br .B getdns_dict_create () getdns_dict * .br .B getdns_dict_create_with_extended_memory_functions .RS 3 (void *userarg, .br void *(*malloc)(void *userarg, size_t sz), .br void *(*realloc)(void *userarg, void *buf, size_t sz), .br void (*free)(void *userarg, void *buf) .RE 3 getdns_dict * .br .B getdns_dict_create_with_memory_functions .RS 3 (void *(*malloc)(size_t sz), .br void *(*realloc)(void *buf, size_t sz), .br void (*free)(void *buf) .RE 3 void .br .B getdns_dict_destroy (getdns_dict *this_dict) .SH DESCRIPTION .LP The getdns_dict type is used to manage name/value pairs in which the names are strings and the data types of the values are heterogeneous and include .RS 3 .br getdns_bindata .br getdns_dict .br getdns_list .br uint32_t .RE .LP The destroy function performs a "deep" destroy, freeing storage for all of the members of the dictionary before destroying the dictionary. There are a number of helper functions that provide access to the dictionary object, see their respective man pages. .LP .I userarg pass this argument to the user specified memory management functions for operations on lists created using extended memory functions .LP .I this_dict the dictionary to destroy .SH "RETURN VALUES" Upon successful completion the getdns_dict_create function returns a valid (empty) dictionary structure that should be freed via a call to getdns_dict_destroy. If a parameter in invalid or in the event of some error getdns_dict_create returns NULL. .SH EXAMPLES TBD .SH SEE ALSO .BR libgetdns (3), .BR getdns_dict_get (3), .BR getdns_dict_set (3), .BR getdns_list (3), .BR getdns_pretty_print_dict (3). getdns-0.9.0/doc/getdns_address.3.in0000664000175100017510000001274112641212403014160 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_address 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_address, .B getdns_address_sync -- get ip address(es) for a name .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_address (getdns_context *context, .RS 3 const char *name, .br getdns_dict *extensions, .br void *userarg, .br getdns_transaction_t *transaction_id, .br getdns_callback_t callbackfn) .RE getdns_return_t .br .B getdns_address_sync (getdns_context *context, .RS 3 const char *name, .br getdns_dict *extensions, .br getdns_dict **response) .RE .SH DESCRIPTION .LP The getdns_address(3) and getdns_address_sync functions provide public entry points into the getdns API library to retrieve the address given a host name. They always returns both IPv4 and IPv6 addresses. This function will use all of the namespaces from the context (to better emulate getaddrinfo (3)). .HP 3 .I context A pointer to the previously created DNS context that is to be used with this DNS request. see getdns_context (3) .HP 3 .I name the host name to resolve to an address (note that an IP address is considered invalid) .HP 3 .I extensions extensions for this request, NULL if no extensions, see libgetdns (3) for a detailed description of extensions .HP 3 .I userarg returned to the callback function untouched, can be NULL .HP 3 .I transaction_id populated by the API and used to identify the callback (for example to getdns_cancel_callback), can be NULL, set to 0 if the function fails .HP 3 .I callbackfn non-NULL pointer to a callback function defined by the application, typically used to process the response. Only the asynchronous signature accepts a callback function, the synchronous signature does not include a callback. See libgetdns (3) for a more detailed discussion of callback functions. .HP 3 .I response A getdns_dict type is returned in response and always contains at least three names: replies_full (a list containing the DNS response as binary data), replies_tree (a list containing the parsed DNS response data) and status (an int). The storage associated with this must be freed by a call to getdns_free_sync_request_memory (3). .HP .SH "RETURN VALUES" Upon successful completion the functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_BAD_CONTEXT if the context pointer is invalid or the context has internal deficiencies .LP .B GETDNS_RETURN_BAD_DOMAIN_NAME if the domain name passed to the function is invalid .LP .B GETDNS_RETURN_EXTENSION_MISFORMAT if the data type specified in one or more of the extensions does not match the specifications .LP .B GETDNS_RETURN_GENERIC_ERROR if some problem was encountered in the function not addressed by one of the more specific return codes .LP .B GETDNS_RETURN_INVALID PARAMETER if one or more parameters has an invalid value .LP .B GETDNS_RETURN_MEMORY_ERROR if unable to allocate the memory required .LP .B GETDNS_RETURN_NO_SUCH_EXTENSION if one or more of the strings specified in the extensions are not valid The values of status included in the response parameter are: .LP .B GETDNS_RESPSTATUS_GOOD if at least one response was returned .LP .B GETDNS_RESPSTATUS_NO_NAME if queries for the name yielded all negative responses .LP .B GETDNS_RESPSTATUS_ALL_TIMEOUT if all queries for the name timed out .LP .B GETDNS_RESPSTATUS_NO_SECURE_ANSWERS if only secure replies accepted (per context) and at least one response was received but no DNS responses were secure through DNSSEC .LP For a more detailed explanation of the response object see .I libgetdns (3) .SH EXAMPLES TBD .SH FILES .br /etc/hosts .br /etc/resolv.conf .SH SEE ALSO .BR libgetdns (3), .BR getdns_context (3), .BR getdns_free_sync_request_memory (3), .BR getdns_general (3), .BR getdns_general_sync (3), .BR getdns_hostname (3), .BR getdns_hostname_sync (3), .BR getdns_service (3), .BR getdns_service_sync (3) getdns-0.9.0/doc/getdns_dict_set.3.in0000664000175100017510000000664012641212403014332 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_dict_set 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_dict_set, .B getdns_dict_set_bindata, .B getdns_dict_set_dict, .B getdns_dict_set_int, .B getdns_dict_set_list, -- set a value by name in a getdns dict .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_dict_set_bindata (getdns_dict *this_dict, .RS 3 char *name, .br getdns_bindata *child_bindata) .RE getdns_return_t .br .B getdns_dict_set_dict (getdns_dict *this_dict, .RS 3 char *name, .br getdns_dict *child_dict) .RE getdns_return_t .br .B getdns_dict_set_int (getdns_dict *this_dict, .RS 3 char *name, .br uint32_t child_uint32_t) .RE getdns_return_t .br .B getdns_dict_set_list (getdns_dict *this_dict, .RS 3 char *name, .br getdns_list *child_list) .RE .SH DESCRIPTION .LP The getdns_dict type is used to manage name/value pairs in which the names are strings and the data types of the values are heterogeneous and include .RS 3 .br getdns_bindata .br getdns_dict .br getdns_list .br uint32_t .RE .LP .I this_dict the dictionary in which to add/update the name/value pair .LP .I name the name whose associated value is to be set. If the name exists in the dictionary the value associated with that name is replaced, if the name does not exist in the dictionary a new item is added to the dictionary. .LP .I child_bindata .I child_dict .I child_list .I child_uint32 value to assign the name .SH "RETURN VALUES" Upon successful completion the functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_GENERIC_ERROR if this_dict is not a valid dictionary .SH EXAMPLES TBD .SH SEE ALSO .BR libgetdns (3), .BR getdns_address (3), .BR getdns_dict (3), .BR getdns_dict_get (3), .BR getdns_general (3), .BR getdns_hostname (3), .BR getdns_service (3) getdns-0.9.0/doc/getdns_cancel_callback.3.in0000664000175100017510000000621512641212403015573 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_cancel_callback 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_cancel_callback -- cancel an outstanding asyn getdns request .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_cancel_callback (getdns_context_t context, .RS 3 .br getdns_transaction_t *transaction_id) .RE .SH DESCRIPTION .LP To cancel an outstanding callback, use getdns_cancel_callback. This causes the API to call the callback with a callback_type of GETDNS_CALLBACK_CANCEL if the callback for this transaction_id has not already been called. The callback code for cancellation should clean up any memory related to the identified call, such as to deallocate the memory for the userarg. getdns_cancel_callback() may return immediately, even before the callback finishes its work and returns. .HP 3 .I context see getdns_context (3) .HP 3 .I transaction_id populated by the API and used to identify the callback (for example to getdns_cancel_callback), can be NULL, set to 0 if the function fails .HP .SH "RETURN VALUES" Upon successful completion the functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_INVALID_PARAMETER if context == NULL .LP .B GETDNS_RETURN_UNKNOWN_TRANSACTION if the transaction_id that is unknown or belongs to a callback that has already been called .SH EXAMPLES TBD .SH FILES .br /etc/hosts .br /etc/resolv.conf .SH SEE ALSO .BR libgetdns (3), .BR getdns_context (3), .BR getdns_general (3), .BR getdns_hostname (3), .BR getdns_service (3), getdns-0.9.0/doc/getdns_context_set.3.in0000664000175100017510000002402312641212403015066 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_context_set 3 "@date@" "getdns @version@" getdns .ad l .SH NAME .B getdns_context_set_append_name, .B getdns_context_set_context_update_callback, .B getdns_context_set_dns_root_servers, .B getdns_context_set_dns_transport, .B getdns_context_set_dnssec_trust_anchors, .B getdns_context_set_dnssec_allowed_skew, .B getdns_context_set_follow_redirects, .B getdns_context_set_limit_outstanding_queries, .B getdns_context_set_namespaces, .B getdns_context_set_resolution_type, .B getdns_context_set_suffix, .B getdns_context_set_timeout, -- getdns context manipulation routines .ad n .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_context_set_append_name (getdns_context_t context, .RS 3 .br getdns_append_name_t when_to_append) .RE getdns_return_t .br .B getdns_context_set_context_update_callback (getdns_context_t context, .RS 3 .br (*callback)(struct getdns_context *context, uint16_t changed_item)) .RE getdns_return_t .br .B getdns_context_set_dns_root_servers (getdns_context_t context, .RS 3 .br getdns_list *root_addresses) .RE getdns_return_t .br .B getdns_context_set_dns_transport (getdns_context_t context, .RS 3 .br uint16_t transport) .RE getdns_return_t .br .B getdns_contet_set_dnssec_allowed_skew (getdns_context *context, .RS 3 uint32_t skew_seconds) .RE getdns_return_t .br .B getdns_contet_set_dnssec_trust_anchors (getdns_context *context, .RS 3 getdns_list *trust_anchors) .RE getdns_return_t .br .B getdns_context_set_follow_redirects (getdns_context_t context, .RS 3 .br getdns_redirects_t followredir) .RE getdns_return_t .br .B getdns_context_set_limit_outstanding_queries (getdns_context_t context, .RS 3 .br uint16_t limit) .RE getdns_return_t .br .B getdns_context_set_namespaces (getdns_context_t context, .RS 3 .br size_t namespace_count, .br uint16_t *namespaces) .RE getdns_return_t .br .B getdns_context_set_resolution_type (getdns_context_t context, .RS 3 uint16_t restype) .RE getdns_return_t .br .B getdns_context_set_suffix (getdns_context *context, .RS 3 getdns_list *suffixes) .RE getdns_return_t .br .B getdns_context_set_timeout (getdns_context_t context, .RS 3 uint16_t timeout) .RE .SH DESCRIPTION .LP These functions are used to manipulate a previously allocated and initialized context, see getdns_context (3) for more details on the functions used to allocate, initialized and destroy contexts and for a more detailed discussion of the getdns_context in general. .LP .B getdns_context_set_append_name Specifies whether to append a suffix supplied via getdns_context_set_suffix (3) to the query string before the API starts resolving a name. .LP .B getdns_context_set_context_update_callback sets a function that will be called if changes to the system files (for example /etc/resolv.conf and /etc/hosts). .LP .B getdns_context_set_dns_transport specifies the transport used for DNS lookups, the default is to use UDP and fall back to TCP as needed. .LP .B getdns_context_set_dnssec_trust_anchors allows the caller to specify trust anchors as alternatives to the default trust anchors .LP .B getdns_context_set_dnssec_allowed_skew set the number of seconds skew allowed in either direction when checking an RRSIGs expiration and inception fields, the default is 0. .LP .B getdns_context_set_limit_outstanding_queries specifies the maximum number of outstanding DNS queries, the API will queue queries over this limit until current queries are answers and will then automatically issue the queries on the queue. .LP .B getdns_context_set_dns_root_servers provides an alternate set of addresses to use to look up the top level domains. The default (if this function is not called) is the list of IANA root servers (think of this as the root hints). .LP .B getdns_context_set_follow_redirects specifies whether or not DNS queries follow redirects (CNAME and DNAME), the default behavior is to follow redirects and return the eventual target. .LP .B getdns_context_set_namespaces sets the namespaces to be used by the resolver, the default is DNS and then local files. Future implementations will support netbios, mdns, and nis. .LP .B getdns_context_set_resolution_type specifies whether DNS queries are performed with non-recursive lookups or as a stub resolver. .LP .B getdns_context_set_suffix Append suffixes to domain names prior to executing the lookup based on getdns_context_set_append_name. .LP .B getdns_context_set_timeout specifies the number of milliseconds the API will wait for a response. .HP 3 .I context a previously allocated and initialized getdns_context .HP 3 .I callback a callback function that will be called when changes are made to the system files (/etc/resolv.conf and /etc/hosts) for contexts created with set_from_os = 1. When this function is called the changed_item parameter indicates which item in the context has changed. .HP 3 .I root_addresses This is a list of getdns_dict types that each identify a single root server to use to look up top level domains. Each dictionary includes two names, .I address_type , a bindata containing the string "IPv4" or "IPv6" and .I address_data a bindata containing the IP address. .HP 3 .I transport may be one of GETDNS_CONTEXT_UDP_FIRST_AND_FALL_BACK_TO_TCP, GETDNS_CONTEXT_UDP_ONLY, GETDNS_CONTEXT_TCP_ONLY, GETDNS_CONTEXT_TCP_ONLY_KEEP_CONNECTIONS_OPEN. If you need more information on what each of these means reread the mnemonic and take a guess ;) .HP 3 .I followredir If set to GETDNS_REDIRECTS_FOLLOW (the default) then the eventual target of the redirect is returned. If set to GETDNS_REDIRECTS_DO_NOT_FOLLOW then the CNAME or DNAME is returned and NOT the eventual target. .HP 3 .I limit the maximum number of concurrent outstanding (unanswered) DNS queries, if exceeded the API will queue queries and issue them as the number of outstanding queries drops. A value of 0 indicates that there is no limit. .ad l .HP 3 .I namespaces The namespaces array contains an ordered list of namespaces that will be queried. Important: this context setting is ignored for the getdns_general and getdns_general_sync functions; it is used for the other functions. The values are GETDNS_CONTEXT_NAMESPACE_DNS, GETDNS_CONTEXT_NAMESPACE_LOCALNAMES, GETDNS_CONTEXT_NAMESPACE_NETBIOS, GETDNS_CONTEXT_NAMESPACE_MDNS, and GETDNS_CONTEXT_NAMESPACE_NIS. When a normal lookup is done, the API does the lookups in the order given and stops when it gets the first result; a different method with the same result would be to run the queries in parallel and return when it gets the first result. Because lookups might be done over different mechanisms because of the different namespaces, there can be information leakage that is similar to that seen with getaddrinfo(). The default is determined by the OS. .ad n .HP 3 .I restype can be set to either GETDNS_CONTEXT_RECURSIVE (the default) or GETDNS_CONTEXT_STUB (requires that forwarders be specified by the caller). .HP 3 .I seconds_skew the number of seconds skew allowed in either direction when checking an RRSIGs expiration and inception fields. .HP 3 .I suffixes A list of bindatas that are strings that are to be appended based on getdns_context_set_append_name. The values here follow the rules in section 2.1 of RFC 4343 to allow non-ASCII octets and special characters in labels. .HP 3 .I timeout the number of milliseconds the API will wait for a response, after which the callback will be invoked (or the synchronous function will return) with a timeout error. .HP 3 .I trust_anchors list of bindatas that are the DNSSEC trust anchors expressed as RDATA from the DNSKEY resource records, the default are supplied by the IANA root. .HP 3 .I when_to_append The value is .RS .IP \(bu 3 GETDNS_APPEND_NAME_ALWAYS, .IP \(bu 3 GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE, .IP \(bu 3 GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE, or .IP \(bu 3 GETDNS_APPEND_NAME_NEVER. .RE .HP .SH "RETURN VALUES" Upon successful completion the functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_BAD_CONTEXT if the context pointer is invalid .LP .B GETDNS_RETURN_CONTEXT_UPDATE_FAIL if there was a problem updating the context .SH EXAMPLES TBD .SH FILES .br /etc/hosts .br /etc/resolv.conf .SH SEE ALSO .BR libgetdns (3), .BR getdns_address (3), .BR getdns_address_sync (3), .BR getdns_context (3), .BR getdns_general (3), .BR getdns_general_sync (3), .BR getdns_hostname (3), .BR getdns_hostname_sync (3), .BR getdns_service (3), .BR getdns_service_sync (3). getdns-0.9.0/doc/getdns_dict_get.3.in0000664000175100017510000000750112641212403014313 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_dict_get 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_dict_get, .B getdns_dict_get_bindata, .B getdns_dict_get_data_type, .B getdns_dict_get_dict, .B getdns_dict_get_int, .B getdns_dict_get_list, .B getdns_dict_get_names -- get value by name from a getdns dict .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_dict_get_bindata (getdns_dict *this_dict, .RS 3 char *name, .br getdns_bindata **answer) .RE getdns_return_t .br .B getdns_dict_get_data_type (getdns_dict *this_dict, .RS 3 char *name, .br getdns_data_type *answer) .RE getdns_return_t .br .B getdns_dict_get_dict (getdns_dict *this_dict, .RS 3 char *name, .br getdns_dict **answer) .RE getdns_return_t .br .B getdns_dict_get_int (getdns_dict *this_dict, .RS 3 char *name, .br uint32_t *answer) .RE getdns_return_t .br .B getdns_dict_get_list (getdns_dict *this_dict, .RS 3 char *name, .br getdns_list **answer) .RE getdns_return_t .br .B getdns_dict_get_names (getdns_dict *this_dict, .RS 3 getdns_list **answer) .RE .SH DESCRIPTION .LP The getdns_dict type is used to manage name/value pairs in which the names are strings and the data types of the values are heterogeneous and include .RS 3 .br getdns_bindata .br getdns_dict .br getdns_list .br uint32_t .RE .LP .I this_dict the dictionary from which to retrieve the list of names .LP .I name the name whose associated value is to be returned in answer .LP .I answer the list of all names in the dictionary, note that the caller must free storage allocated to the list via a call to .B getdns_list_destroy(3) .SH "RETURN VALUES" Upon successful completion the functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_GENERIC_ERROR if this_dict is not a valid dictionary .LP .B GETDNS_RETURN_NO_SUCH_DICT_NAME if the name argument doesn't exist in the dictionary .LP .B GETDNS_RETURN_WRONG_TYPE_REQUESTED if the requested data type doesn't match the contents of the indexed argument or name .SH EXAMPLES TBD .SH SEE ALSO .BR libgetdns (3), .BR getdns_address (3), .BR getdns_dict (3), .BR getdns_dict_set (3), .BR getdns_general (3), .BR getdns_hostname (3), .BR getdns_list (3), .BR getdns_service (3), getdns-0.9.0/doc/getdns_validate_dnssec.3.in0000664000175100017510000000620412641212403015660 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_validate_dnssec 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_validate_dnssec -- DNSSEC validate a given getdns record .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_validate_dnssec (getdns_list *record_to_validate, .br .RS 3 getdns_list *bundle_of_support_records, .br getdns_list *trust_anchor_records) .RE .SH DESCRIPTION .LP If an application wants the API to perform DNSSEC validation without using the extensions, it can use the getdns_validate_dnssec() helper function. The API will use the resource records in bundle_of_support_records to construct the validation chain and the DNSKEY or DS records in trust_anchor_records as trust anchors. The default list of trust anchor records that is used by the library to validate DNSSEC can be retrieved by using the getdns_root_trust_anchor helper function. .HP 3 .I record_to_validate the resource record being validated .HP 3 .I bundle_of_support_records records used to construct the validation chain .HP 3 .I trust_anchor_records trust anchor records to use for the validation .HP .SH "RETURN VALUES" .LP .B GETDNS_DNSSEC_BOGUS the DNSSEC signature is bogus .LP .B GETDNS_DNSSEC_INDETERMINATE validation could not be completed .LP .B GETDNS_DNSSEC_INSECURE one or more pieces of the validation chain are demonstrably incorrect .LP .B GETDNS_DNSSEC_SECURE validation succeeded .LP .B GETDNS_RETURN_MEMORY_ERROR an attempt to allocate memory failed .SH EXAMPLES TBD .SH SEE ALSO .BR getdns_root_trust_anchor (3) .BR libgetdns (3) getdns-0.9.0/doc/getdns_list.3.in0000664000175100017510000000700112641212403013477 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_list 3 "@date@" "getdns @version@" getdns .ad l .SH NAME .B getdns_list, .B getdns_list_create, .B getdns_list_create_with_extended_memory_functions, .B getdns_list_create_with_memory_functions, .B getdns_list_destroy -- getdns list create and destroy routines .ad n .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_list * .br .B getdns_list_create () getdns_list * .br .B getdns_list_create_with_extended_memory_functions .RS 3 (void *userarg, .br void *(*malloc)(void *userarg, size_t sz), .br void *(*realloc)(void *userarg, void *buf, size_t sz), .br void (*free)(void *userarg, void *buf) .RE 3 getdns_list * .br .B getdns_list_create_with_memory_functions .RS 3 (void *userarg, .br void *(*malloc)(size_t sz), .br void *(*realloc)(void *buf, size_t sz), .br void (*free)(void *buf) .RE 3 void .br .B getdns_list_destroy (getdns_list *this_dict) .SH DESCRIPTION .LP The getdns_list type is used to manage heterogeneous indexed lists name/value pairs in which the data types of the values include .RS 3 .br getdns_bindata .br getdns_dict .br getdns_list .br uint32_t .RE .LP The destroy function performs a "deep" destroy, freeing storage for all of the members of the list before destroying the list. There are a number of helper functions that provide access to the list object, see their respective man pages. .LP .I userarg pass this argument to the user specified memory management functions for operations on lists created using extended memory functions .LP .I this_list the list to destroy .SH "RETURN VALUES" Upon successful completion the getdns_list_create function returns a valid (empty) list structure that should be freed via a call to getdns_list_destroy. If a parameter in invalid or in the event of some error getdns_list_create returns NULL. .SH EXAMPLES TBD .SH SEE ALSO .BR libgetdns (3), .BR getdns_dict (3), .BR getdns_list_get (3), .BR getdns_list_set (3) getdns-0.9.0/doc/libgetdns.3.in0000664000175100017510000006260112641212403013142 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH libgetdns 3 "@date@" "getdns @version@" getdns .SH NAME libgetdns -- an implementation of a modern asynchronous DNS API by and for application developers .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS .B libgetdns This man page describes the getdns library, the general concepts behind the API and some of the common elements of the public interface to the library. Each of the public entry points and more complex data types are captured in separate man pages. .SH DESCRIPTION .LP getdns is modern asynchronous DNS API intended to be useful to application developers and operating system distributors as a way of making all types of DNS information easily available in many types of programs. The major features of this new API are: .RS 3 Full support for event-driven programming Supports DNSSEC in multiple ways Mirroring of the resolution in getaddrinfo() Easily supports all RRtypes, even those yet to be defined .RE .LP Each of the entry points is offered with both asynchronous and synchronous signatures. The asynchronous functions rely on event handling and callback via libevent. Functions are thread safe. .LP A context structure maintains DNS query and response data and is used to maintain state during calls to the public entry points. .LP The project page for this implementation is at .IP http://getdnsapi.net .LP The specification is maintained at .IP http://getdnsapi.net/spec .LP The git repository for this implementation is at .IP http://github.com/getdnsapi/getdns .SH DATA STRUCTURES .LP The API uses a few data structures to pass data into and return data from the public entry points. .IP list an ordered list, the members of the list can be any of the four data types. .IP dict a name-value pair. The name is a string literal, and the value can be any of the four data types. The order of the name-value pairs in a dict is not important. .IP int an integer compatible with uint32_t. .IP bindata a struct used to hold binary data defined as { size_t size; uint8_t *binary_stuff; }. .SH ASYNCHRONOUS USE .LP The getdns specification emphasizes the asynchronous nature of the API and allows implementations to define their own approach. This page documents this implementation's decisions and facilities provided to the developer. .LP This implementation provides asynchronous support via the following mechanisms: .RS 3 File Descriptor Polling .br Event Loop Integrations: .RS 3 libevent .br libuv .br libev .RE Custom Event Loop Integrations .RE .LP All functions and types discussed in this page are declared in getdns_extra.h .SS "Build-in Event loop" The library has an built in event loop that can be used if none of the extensions for external event loops are used. The library will execute requests and dispatch callbacks with a call to .I getdns_context_run(). If an event loop extension is used, this will run the extension's eventloop. .HP 3 void getdns_context_run(getdns_context *context) Run the context's event loop until nothing more to do. .HP 3 uint32_t getdns_context_get_num_pending_requests(getdns_context* context, struct timeval* next_timeout) Get the number of outstanding asynchronous requests for a given context as well as the the amount of time until the next timeout. The next_timeout struct can be NULL. If supplied and the number of outstanding requests is > 0, then the timeout represents the relative time until the next timeout. .HP 3 getdns_return_t getdns_context_process_async(getdns_context* context) Inform the context to process its outstanding requests. Users should call this when either a timeout has occurred or the file descriptor signals that it is ready. User callbacks are fired during this call. .SS "Included Event Loop Integrations" .LP A number of applications achieve asynchronous behavior by leveraging event loop abstraction libraries. If the build system discovers a supported event loop, the event loop extension is built in addition to the getdns library. Extensions are built as an additional shared library. The following event loop libraries are supported: .B libevent1 and libevent2 .LP The libevent extension allows a context to attach to a event_base. The event loop is then run like any other application using libevent via event_base_dispatch or event_base_loop and expect getdns callbacks to fire. .LP Note that if both libevent1 and libevent2 reside on system, the extension uses libevent2. .RS 3 Extension library: libgetdns_ext_event.[shared_lib_ext] .br Extension header: getdns/getdns_ext_libevent.h .RE .B libuv .LP The libuv extension allows a context to attach to a uv_loop_s. The event loop can then be run like any other application using libuv via uv_run and expect getdns callbacks to fire. .RS 3 Extension library: libgetdns_ext_uv.[shared_lib_ext] .br Extension header: getdns_ext_libuv.h .RE .B libev .LP The libev extension allows a context to attach to a ev_loop. The event loop can then be run like any other application using libev via ev_run and expect getdns callbacks to fire. .RS 3 Extension library: libgetdns_ext_ev.[shared_lib_ext] .br Extension header: getdns_ext_libev.h .RE .SS "getdns_context event loop extension functions" .LP The following are functions used by the extension entry point to attach to a particular context. .LP The application sets an event loop extension on a context. The extension_data is optional data that is passed into the extension methods. If an event loop is already set on a context then it is cleaned up. All outstanding requests are also canceled. .IP getdns_return_t getdns_extension_set_eventloop(struct getdns_context* context, getdns_eventloop_extension* extension, void* extension_data); .LP The application gets the extension data associated with a context. .IP void* getdns_context_get_extension_data(struct getdns_context* context); .LP When no more work must be done the application detaches an event loop from a context .IP getdns_return_t getdns_extension_detach_eventloop(struct getdns_context* context); .SH SYNCHRONOUS USE .LP There are four synchronous functions parallel to the four getdns async functions, except that there is no callback parameter. When an application calls one of these synchronous functions, the API gathers all the required information and then returns the result. The value returned is exactly the same as the response returned in the callback if you had used the async version of the function. .LP When you are done with the data in the response, call getdns_free_sync_request_memory so that the API can free the memory from its internal pool. .SH EXTENSIONS Applications may populate an extension dictionary when making a call to the public entry points. To use an extension add it to the extension dictionary prior to making the call to the public entry point and set the value depending on the behavior you expect. These extensions include: .HP 3 "dnssec_return_status" (int) Set to GETDNS_EXTENSION_TRUE to include the DNSSEC status for each DNS record in the replies_tree .HP 3 "dnssec_return_only_secure" (int) Set to GETDNS_EXTENSION_TRUE to cause only records that the API can validate as secure withe DNSSEC to be returned in the .I replies_tree and .I replies_full lists .HP 3 "dnssec_return_validation_chain" (int) Set to GETDNS_EXTENSION_TRUE to cause the set of additional DNSSEC-related records needed for validation to be returned in the response object as the list named .I additional_dnssec at the top level of the response object .HP 3 "return_both_v4_and_v6" (int) Set to GETDNS_EXTENSION_TRUE to cause the results of both A and AAAA records for the queried name to be included in the response object. .HP 3 "add_opt_parameters" (dict) TBD (complicated) .HP 3 "add_warning_for_bad_dns" Set to GETDNS_EXTENSION_TRUE to cause each reply in the .I replies_tree to contain an additional name whose data type is a list, .I bad_dns which contains zero or more ints that indicate the types of bad DNS found in the reply. .RS 6 .br GETDNS_BAD_DNS_CNAME_IN_TARGET: query type does not allow a CNAME pointed to a CNAME .br GETDNS_BAD_DNS_ALL_NUMERIC_LABEL: one or more labels is all numeric .br GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE: query type for other than CNAME returned a CNAME .RE .HP 3 "specify_class" (int) Set to the DNS class number (other than Internet (IN) class desired in query. .HP 3 "return_call_reporting" (int) Set to GETDNS_EXTENSION_TRUE to add the name .I call_reporting (list) to the top level of the response object that includes a dict for each call made to the API. TBD: more detail .LP This implementation of the getdns API is licensed under the BSD license. .SH DNSSEC .LP If an application wants the API to do DNSSEC validation for a request, it must set one or more DNSSEC-related extensions. Note that the default is for none of these extensions to be set and the API will not perform DNSSEC. Note that getting DNSSEC results can take longer in a few circumstances. .LP To return the DNSSEC status for each DNS record in the replies_tree list, use the dnssec_return_status extension. The extension's value (an int) is set to GETDNS_EXTENSION_TRUE to cause the returned status to have the name dnssec_status (an int) added to the other names in the record's dict ("header", "question", and so on). The values for that name are GETDNS_DNSSEC_SECURE, GETDNS_DNSSEC_BOGUS, GETDNS_DNSSEC_INDETERMINATE, and GETDNS_DNSSEC_INSECURE. Thus, a reply might look like: .EX { # This is the first reply "dnssec_status": GETDNS_DNSSEC_INDETERMINATE, "header": { "id": 23456, "qr": 1, "opcode": 0, ... }, . . . .EE .LP If instead of returning the status, you want to only see secure results, use the dnssec_return_only_secure extension. The extension's value (an int) is set to GETDNS_EXTENSION_TRUE to cause only records that the API can validate as secure with DNSSEC to be returned in the replies_tree and replies_full lists. No additional names are added to the dict of the record; the change is that some records might not appear in the results. When this context option is set, if the API receives DNS replies but none are determined to be secure, the error code at the top level of the response object is GETDNS_RESPSTATUS_NO_SECURE_ANSWERS. .LP Applications that want to do their own validation will want to have the DNSSEC-related records for a particular response. Use the dnssec_return_validation_chain extension. The extension's value (an int) is set to GETDNS_EXTENSION_TRUE to cause a set of additional DNSSEC-related records needed for validation to be returned in the response object. This set comes as validation_chain (a list) at the top level of the response object. This list includes all resource record dicts for all the resource records (DS, DNSKEY and their RRSIGs) that are needed to perform the validation from the root up. Thus, a reply might look like: .EX { # This is the response object "validation_chain": [ { "name": , "type": GETDNS_RRTYPE_DNSKEY, "rdata": { "flags": 256, . . . }, . . . }, { "name": , "type": GETDNS_RRTYPE_DNSKEY, "rdata": { "flags": 257, . . . }, . . . }, { "name": , "type": GETDNS_RRTYPE_RRSIG, "rdata": { "signers_name": , "type_covered": GETDNS_RRTYPE_DNSKEY, . . . }, }, { "name": , "type": GETDNS_RRTYPE_DS, . . . }, { "name": , "type": GETDNS_RRTYPE_RRSIG "rdata": { "signers_name": , "type_covered": GETDNS_RRTYPE_DS, . . . }, . . . }, { "name": , "type": GETDNS_RRTYPE_DNSKEY "rdata": { "flags": 256, . . . }, . . . }, { "name": , "type": GETDNS_RRTYPE_DNSKEY "rdata": { "flags": 257, . . . }, . . . }, { "name": , "type": GETDNS_RRTYPE_RRSIG "rdata": { "signers_name": , "type_covered": GETDNS_RRTYPE_DNSKEY, . . . }, . . . }, { "name": , "type": GETDNS_RRTYPE_DS, . . . }, { "name": , "type": GETDNS_RRTYPE_RRSIG "rdata": { "signers_name": , "type_covered": GETDNS_RRTYPE_DS, . . . }, . . . }, { "name": , "type": GETDNS_RRTYPE_DNSKEY "rdata": { "flags": 257, ... }, . . . }, . . . ] "replies_tree": [ . . . .EE .LP If a request is using a context in which stub resolution is set, and that request also has any of the dnssec_return_status, dnssec_return_only_secure, or dnssec_return_validation_chain extensions specified, the API will not perform the request and will instead return an error of GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED. .SH OPT RESOURCE RECORDS .LP For lookups that need an OPT resource record in the Additional Data section, use the add_opt_parameters extension. The extension's value (a dict) contains the parameters; these are described in more detail in RFC 2671. They are: .HP 3 .I maximum_udp_payload_size (an int) between 512 and 65535; if not specified, this defaults to those from the DNS context .HP 3 .I extended_rcode (an int) between 0 and 255; if not specified, this defaults to those from the DNS context .HP 3 .I version (an int) between 0 and 255; if not specified, this defaults to 0 .HP 3 .I do_bit (an int) between 0 and 1; if not specified, this defaults to those from the DNS context .HP 3 .I options (a list) contains dicts for each option to be specified. Each list time contains two names: option_code (an int) and option_data (a bindata). The API marshalls the entire set of options into a properly-formatted RDATA for the resource record. .LP It is very important to note that the OPT resource record specified in the add_opt_parameters extension might not be the same the one that the API sends in the query. For example, if the application also includes any of the DNSSEC extensions, the API will make sure that the OPT resource record sets the resource record appropriately, making the needed changes to the settings from the add_opt_parameters extension. .LP The use of this extension can conflict with the values in the DNS context. For example, the default for an OS might be a maximum payload size of 65535, but the extension might specify 1550. In such a case, the API will honor the values stated in the extension, but will honor the values from the DNS context if values are not given in the extension. .SH RESPONSE DATA .LP The callback function contains a pointer to a response object. A response object is always a dict. The response object always contains at least three names: replies_full (a list) and replies_tree (a list), and status (an int). replies_full is a list of DNS replies (each is bindata) as they appear on the wire. replies_tree is a list of DNS replies (each is a dict) with the various part of the reply parsed out. status is a status code for the query. .LP Because the API might be extended in the future, a response object might also contain names other than replies_full, replies_tree, and status. Similarly, any of the dicts described here might be extended in later versions of the API. Thus, an application using the API must not assume that it knows all possible names in a dict. .LP The following lists the status codes for response objects. Note that, if the status is that there are no responses for the query, the lists in replies_full and replies_tree will have zero length. .HP 3 .B GETDNS_RESPSTATUS_GOOD At least one response was returned .HP 3 .B GETDNS_RESPSTATUS_NO_NAME Queries for the name yielded all negative responses .HP 3 .B GETDNS_RESPSTATUS_ALL_TIMEOUT All queries for the name timed out .HP 3 .B GETDNS_RESPSTATUS_NO_SECURE_ANSWERS The context setting for getting only secure responses was specified, and at least one DNS response was received, but no DNS response was determined to be secure through DNSSEC. .LP The top level of replies_tree can optionally have the following names: canonical_name (a bindata), intermediate_aliases (a list), answer_ipv4_address (a bindata), answer_ipv6_address (a bindata), and answer_type (an int). .LP The value of canonical_name is the name that the API used for its lookup. It is in FQDN presentation format. The values in the intermediate_aliases list are domain names from any CNAME or unsynthesized DNAME found when resolving the original query. The list might have zero entries if there were no CNAMEs in the path. These may be useful, for example, for name comparisons when following the rules in RFC 6125. The value of answer_ipv4_address and answer_ipv6_address are the addresses of the server from which the answer was received. The value of answer_type is the type of name service that generated the response. The values are: .RS 3 GETDNS_NAMETYPE_DNS Normal DNS (RFC 1035) GETDNS_NAMETYPE_WINS The WINS name service (some reference needed) .RE .LP If the call was getdns_address or getdns_address_sync, the top level of replies_tree has an additional name, just_address_answers (a list). The value of just_address_answers is a list that contains all of the A and AAAA records from the answer sections of any of the replies, in the order they appear in the replies. Each item in the list is a dict with at least two names: address_type (whose value is a bindata; it is currently either "IPv4" or "IPv6") and address_data (whose value is a bindata). Note that the dnssec_return_only_secure extension affects what will appear in the just_address_answers list. If the DNS returns other address types, those types will appear in this list as well. .LP The API can make service discovery through SRV records easier. If the call was getdns_service or getdns_service_sync, the top level of replies_tree has an additional name, srv_addresses (a list). The list is ordered by priority and weight based on the weighting algorithm in RFC 2782, lowest priority value first. Each element of the list is dict has at least two names: port and domain_name. If the API was able to determine the address of the target domain name (such as from its cache or from the Additional section of responses), the dict for an element will also contain address_type (whose value is a bindata; it is currently either "IPv4" or "IPv6") and address_data (whose value is a bindata). Note that the dnssec_return_only_secure extension affects what will appear in the srv_addresses list. .SH STRUCTURE OF DNS REPLIES_TREE .LP The names in each entry in the the replies_tree list for DNS responses include header (a dict), question (a dict), answer (a list), authority (a list), and additional (a list), corresponding to the sections in the DNS message format. The answer, authority, and additional lists each contain zero or more dicts, with each dict in each list representing a resource record. .LP The names in the header dict are all the fields from Section 4.1.1. of RFC 1035. They are: id, qr, opcode, aa, tc, rd, ra, z, rcode, qdcount, ancount, nscount, and arcount. All are ints. .LP The names in the question dict are the three fields from Section 4.1.2. of RFC 1035: qname (a bindata), qtype (an int), and qclass (an int). .LP Resource records are a bit different than headers and question sections in that the RDATA portion often has its own structure. The other names in the resource record dicts are name (a bindata), type (an int), class (an int), ttl (an int) and rdata (a dict); there is no name equivalent to the RDLENGTH field. .LP The rdata dict has different names for each response type. There is a complete list of the types defined in the API. For names that end in "-obsolete" or "-unknown", the bindata is the entire RDATA field. For example, the rdata for an A record has a name ipv4_address (a bindata); the rdata for an SRV record has the names priority (an int), weight (an int), port (an int), and target (a bindata). .LP Each rdata dict also has a rdata_raw field (a bindata). This is useful for types not defined in this version of the API. It also might be of value if a later version of the API allows for additional parsers. Thus, doing a query for types not known by the API still will return a result: an rdata with just a rdata_raw. .LP It is expected that later extensions to the API will give some DNS types different names. It is also possible that later extensions will change the names for some of the DNS types listed above. .SH CALLBACK FUNCTIONS .LP A call to the async getdns functions typically returns before any network or file I/O occurs. After the API marshalls all the needed information, it calls the callback function that was passed by the application. The callback function might be called at any time, even before the calling function has returned. The API guarantees that the callback will be called exactly once unless the calling function returned an error, in which case the callback function is never called. The getdns calling function calls the callback with the parameters defined as follows: .br typedef void (*getdns_callback_t)( .RS 3 getdns_context_t context, .br uint16_t callback_type, .br getdns_dict *response, .br void *userarg, .br getdns_transaction_t transaction_id) .RE .HP 3 .I context see getdns_context (3) .HP 3 .I callback_type Supplies the reason for the callback. .RS 3 .LP .B GETDNS_CALLBACK_COMPLETE The response has the requested data in it .LP .B GETDNS_CALLBACK_CANCEL The calling program canceled the callback; response is NULL .LP .B GETDNS_CALLBACK_TIMEOUT The requested action timed out; response is NULL .LP .B GETDNS_CALLBACK_ERROR The requested action had an error; response is NULL .RE .HP 3 .I response A response object with the response data. This is described in the section titled "RESPONSE DATA" elsewhere in this manual page. The response object is part of the API's memory space, and will be freed by the API with the callback returns. .HP 3 .I userarg Identical to the userarg passed to the calling function. .HP 3 .I transaction_id The transaction identified assigned by the calling function, used to associate a DNS response to a specific DNS request. .LP To cancel an outstanding callback, use the following function. .RS 3 .br getdns_return_t .br .B getdns_cancel_callback (getdns_context_t context, getdns_transaction_t transaction_id) .RE .LP This causes the API to call the callback with a callback_type of GETDNS_CALLBACK_CANCEL if the callback for this transaction_id has not already been called. The callback code for cancellation should clean up any memory related to the identified call, such as to deallocate the memory for the userarg. getdns_cancel_callback() may return immediately, even before the callback finishes its work and returns. Calling getdns_cancel_callback() with a transaction_id of a callback that has already been called or an unknown transaction_id returns GETDNS_RETURN_UNKNOWN_TRANSACTION; otherwise, getdns_cancel_callback() returns GETDNS_RETURN_GOOD. .SH FILES .br /etc/hosts .br /etc/resolv.conf .SH EXAMPLES TBD .SH DIAGNOSTICS TBD .SH "SEE ALSO" .BR getdns_address (3), .BR getdns_bindata (3), .BR getdns_context (3), .BR getdns_convert (3), .BR getdns_dict (3), .BR getdns_general (3), .BR getdns_hostname (3), .BR getdns_list (3), .BR getdns_root_trust_anchor (3) .BR getdns_service (3) .BR getdns_validate_dnssec (3) .SH REPORTING PROBLEMS Bug reports should be sent to the getdns-bugs@getdns.net .SH AUTHORS The getdns API was documented by Paul Hoffman. This implementation of the getdns API was written by: .LP .RS 3 .br Craig Despeaux, Verisign Inc. .br John Dickinson, Sinodun .br Sara Dickinson, Sinodun .br Neel Goyal, Verisign Inc. .br Shumon Huque, Verisign Labs .br Olaf Kolkman, NLnet Labs .br Allison Mankin, Verisign Inc. - Verisign Labs. .br Melinda Shore, No Mountain Software LLC .br Willem Toorop, NLnet Labs .br Gowri Visweswaran, Verisign Labs .br Wouter Wijngaards, NLnet Labs .br Glen Wiley, Verisign Inc. .RE getdns-0.9.0/doc/getdns_general.3.in0000664000175100017510000001603412641212403014147 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_general 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_general, .B getdns_general_sync -- do a getdns DNS lookup .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_general (getdns_context *context, .RS 3 const char *name, .br uint16_t request_type .br getdns_dict *extensions, .br void *userarg, .br getdns_transaction_t *transaction_id, .br getdns_callback_t callbackfn) .RE getdns_return_t .br .B getdns_general_sync (getdns_context *context, .RS 3 const char *name, .br uint16_t request_type .br getdns_dict *extensions, .br getdns_dict **response) .RE .SH DESCRIPTION .LP The getdns_general(3) and getdns_general_sync functions provide public entry points into the getdns API library to retrieve any valid responses to a query from the DNS (note that other namespaces in the context are not used). Most typical use cases for applications are probably satisifed via calls to getdns_address(3) which would replace getaddrinfo(3). .HP 3 .I context A pointer to the previsouly created DNS context that is to be used with this DNS request. see getdns_context (3) .HP 3 .I name The ASCII-based domain name looked up as a string. This can also be an IPv4 or IPv6 address for request types that take addresses instead of domain names, such as PTR. The values here follow the rules in section 2.1 of RFC 4343 to allow non-ASCII octets and special characters in labels. .HP 3 .I request_type Specifies the RRtype for the query; the RRtype numbers are listed in the IANA registry. For example, to get the NS records, request_type would be 2. The API also has defined macros for most of the RRtypes by name; the definition names all start with "GETDNS_RRTYPE_". For example, to get the NS records, you can also set the request_type to GETDNS_RRTYPE_NS. .HP 3 .I extensions extensions for this request, NULL if no extensions, see libgetnds (3) for a detailed description of extensions .HP 3 .I userarg returned to the callback function untouched, can be NULL .HP 3 .I transaction_id populated by the API and used to identify the callback (for example to getdns_cancel_callback), can be NULL, set to 0 if the function fails .HP 3 .I callbackfn non-NULL pointer to a callback function defined by the application, typically used to process the response. Only the asynchronous signature accepts a callback function, the synchronous signature does not include a callback. See libgetdns (3) for a more detailed discussion of callback functions. .HP 3 .I response A getdns_dict type is returned in response and always contains at least three names: replies_full (a list containing the DNS response as binary data), replies_tree (a list containing the parsed DNS response data) and status (an int). The storage associated with this must be freed by a call to getdns_free_sync_request_memory (3). .HP .SH "RETURN VALUES" Upon successful completion the functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_BAD_CONTEXT if the context pointer is invalid or the context has internal deficiencies .LP .B GETDNS_RETURN_BAD_DOMAIN_NAME if the domain name passed to the function is invalid .LP .B GETDNS_RETURN_EXTENSION_MISFORMAT if the data type specified in one or more of the extensions does not match the specifications .LP .B GETDNS_RETURN_GENERIC_ERROR if some problem was encountered in the function not addressed by one of the more specific return codes .LP .B GETDNS_RETURN_INVALID PARAMETER if one or more parameters has an invalid value .LP .B GETDNS_RETURN_MEMORY_ERROR if unable to allocate the memory required .LP .B GETDNS_RETURN_NO_SUCH_EXTENSION if one or more of the strings specified in the extensions are not valid The values of status included in the response parameter are: .LP .B GETDNS_RESPSTATUS_GOOD if at least one response was returned .LP .B GETDNS_RESPSTATUS_NO_NAME if queries for the name yielded all negative responses .LP .B GETDNS_RESPSTATUS_ALL_TIMEOUT if all queries for the name timed out .LP .B GETDNS_RESPSTATUS_NO_SECURE_ANSWERS if only secure replies accepted (per context) and at least one response was received but no DNS responses were secure through DNSSEC .LP For a more detailed explanation of the response object see .I libgetdns (3) .SH REQUEST TYPES This is a list of the most common request types, a full list of request types in more detail is available at http://www.iana.org/assignments/dns-parameters/dns-parameters.xml .RS 3 .TP 11 .B A Host address .TP .B AAAA IPv6 address .TP .B CAA Certificate Authority Authorization .TP .B CNAME Canonical name for an alias .TP .B DLV DNSSEC lookaside validation .TP .B DNAME DNAME .TP .B DS Delegation signer .TP .B HINFO Host information .TP .B KEY Security key .TP .B MINFO Mailbox or mail list information .TP .B MX Mail exchange .TP .B NS Authoritative name server .TP .B NSEC Next secure record .TP .B NSEC3 Next secure record (hashed) .TP .B NSEC3PARAM NSEC3PARAM .TP .B PTR Domain name pointer .TP .B RRSIG Signature for a record set .TP .B SIG Security signature .TP .B SOA Marks the start of a zone of authority .TP .B SRV Server selection .TP .B TA DNSSEC trust authorities .TP .B TKEY Transaction key .TP .B TLSA TLSA .TP .B TSIG Transaction signature .TP .B TXT Text strings .RE .SH EXAMPLES TBD .SH FILES .br /etc/hosts .br /etc/resolv.conf .SH SEE ALSO .BR libgetdns (3), .BR getdns_address (3), .BR getdns_context (3), .BR getdns_free_sync_request_memory (3), .BR getdns_hostname (3), .BR getdns_service (3), getdns-0.9.0/doc/getdns_service.3.in0000664000175100017510000001226212641212403014171 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_service 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_service, .B getdns_service_sync -- getdns lookup of a service .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_service (getdns_context *context, .RS 3 const char *name, .br getdns_dict *extensions, .br void *userarg, .br getdns_transaction_t *transaction_id, .br getdns_callback_t callbackfn) .RE getdns_return_t .br .B getdns_service_sync (getdns_context *context, .RS 3 const char *name, .br getdns_dict *extensions, .br getdns_dict **response) .RE .SH DESCRIPTION .LP The getdns_service (3) and getdns_service_sync functions provide public entry points into the getdns API library to retrieve the SRV information given a name. .HP 3 .I context A pointer to the previously created DNS context that is to be used with this DNS request. see getdns_context (3) .HP 3 .I name the service name to resolve .HP 3 .I extensions extensions for this request, NULL if no extensions, see libgetdns (3) for a detailed description of extensions .HP 3 .I userarg returned to the callback function untouched, can be NULL .HP 3 .I transaction_id populated by the API and used to identify the callback (for example to getdns_cancel_callback), can be NULL, set to 0 if the function fails .HP 3 .I callbackfn non-NULL pointer to a callback function defined by the application, typically used to process the response. Only the asynchronous signature accepts a callback function, the synchronous signature does not include a callback. See libgetdns (3) for a more detailed discussion of callback functions. .HP 3 .I response A getdns_dict type is returned in response and always contains at least three names: replies_full (a list containing the DNS response as binary data), replies_tree (a list containing the parsed DNS response data) and status (an int). The storage associated with this must be freed by a call to getdns_free_sync_request_memory (3). .HP .SH "RETURN VALUES" Upon successful completion the functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_BAD_CONTEXT if the context pointer is invalid or the context has internal deficiencies .LP .B GETDNS_RETURN_BAD_DOMAIN_NAME if the domain name passed to the function is invalid .LP .B GETDNS_RETURN_EXTENSION_MISFORMAT if the data type specified in one or more of the extensions does not match the specifications .LP .B GETDNS_RETURN_GENERIC_ERROR if some problem was encountered in the function not addressed by one of the more specific return codes .LP .B GETDNS_RETURN_INVALID PARAMETER if one or more parameters has an invalid value .LP .B GETDNS_RETURN_MEMORY_ERROR if unable to allocate the memory required .LP .B GETDNS_RETURN_NO_SUCH_EXTENSION if one or more of the strings specified in the extensions are not valid The values of status included in the response parameter are: .LP .B GETDNS_RESPSTATUS_GOOD if at least one response was returned .LP .B GETDNS_RESPSTATUS_NO_NAME if queries for the name yielded all negative responses .LP .B GETDNS_RESPSTATUS_ALL_TIMEOUT if all queries for the name timed out .LP .B GETDNS_RESPSTATUS_NO_SECURE_ANSWERS if only secure replies accepted (per context) and at least one response was received but no DNS responses were secure through DNSSEC .LP For a more detailed explanation of the response object see .I libgetdns (3) .SH EXAMPLES TBD .SH FILES .br /etc/hosts .br /etc/resolv.conf .SH SEE ALSO .BR libgetdns (3), .BR getdns_context (3), .BR getdns_free_sync_request_memory (3), .BR getdns_general (3), .BR getdns_hostname (3), .BR getdns_address (3), getdns-0.9.0/doc/manpgaltnames0000775000175100017510000000345512641212403013255 00000000000000#!/bin/sh # generate list of alternate names for the specified man page # used to generate alternative man pages # # Copyright (c) 2013, Verisign, Inc., NLnet Labs # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the names of the copyright holders nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [ ! -f $1 ] && exit 0 main=${1%.[0-9]} sect=${1#*.} sed -n '/.SH NAME/,/.SH LIBRARY/p' $1 |grep "^.B " | sed 's/.B //g' | sed 's/ *$//g' | sed 's/,//g' | grep -v "^$main\$" | sed "s/\$/.$sect/" getdns-0.9.0/doc/getdns_pretty_print_dict.3.in0000664000175100017510000000452312641212403016300 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_pretty_print_dict 3 "@date@" "getdns @version@" getdns .SH NAME .B getdns_pretty_print_dict -- return a string representation of a getdns dict .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_list * .br .B getdns_pretty_print_dict (const getdns_dict *this_dict) .SH DESCRIPTION .LP Helper function that returns a string of nicely formatted data including all of the elements in the dict. .HP 3 .I this_dict the dictionary to render as a string .HP .SH "RETURN VALUES" Returns a string that the calling function must free (it is allocated using the system allocator not the user defined allocator). Returns NULL if there is an error. .SH EXAMPLES TBD .SH SEE ALSO .BR getdns_dict (3) .BR libgetdns (3) getdns-0.9.0/doc/getdns_context.3.in0000664000175100017510000002114212641212403014212 00000000000000.\" The "BSD-New" License .\" .\" Copyright (c) 2013, NLnet Labs, Verisign, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are met: .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" * Neither the names of the copyright holders nor the .\" names of its contributors may be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .TH getdns_context 3 "@date@" "getdns @version@" getdns .ad l .SH NAME .B getdns_context, .B getdns_context_create, .B getdns_context_create_with_memory_functions, .B getdns_context_create_with_extended_memory_functions, .B getdns_context_destroy, .B getdns_context_get_api_information -- getdns context create and destroy routines .ad n .SH LIBRARY DNS Resolver library (libgetdns, -lgetdns) .SH SYNOPSIS #include getdns_return_t .br .B getdns_context_create (getdns_context ** context, .RS 3 .br int set_from_os) .RE getdns_return_t .br .B getdns_context_create_with_memory_functions (getdns_context ** context, .RS 3 .br int set_from_os, .br void *(*malloc) (size_t), .br void *(*realloc) (void *, size_t), .br void (*free) (void *)) .RE getdns_return_t .br .B getdns_context_create_with_extended_memory_functions (getdns_context **context, .RS 3 .br int set_from_os, .br void *userarg, .br void *(*malloc) (void *userarg, size_t), .br void *(*realloc) (void *userarg, void *, size_t), .br void (*free) (void *userarg, void *)) .RE void .br .B getdns_context_destroy (getdns_context *context) getdns_dict * .br .B getdns_context_get_api_information (getdns_context *context) .SH DESCRIPTION .LP Calls to getdns functions require a DNS context, which is a group of API settings that affect how DNS calls are made. For most applications, a default context is sufficient. .LP To create a new DNS context, use the function: .RS 3 .br getdns_return_t .B getdns_context_create (getdns_context_t *context, bool set_from_os) .RE .LP The call to getdns_context_create immediately returns a context that can be used with other API calls; that context contains the API's default values. Most applications will want set_from_os set to true. .LP To clean up the context, including cleaning up all outstanding transactions that were called using this context, use the function: .RS 3 .br void .B getdns_context_destroy (getdns_context_t context) .RE .LP When getdns_context_destroy() returns, the application knows that all outstanding transactions associated with this context will have been called; callbacks that had not been called before getdns_context_destroy() was called will be called with a callback_type of GETDNS_CALLBACK_CANCEL. getdns_context_destroy() returns after all of the needed cleanup is done and callbacks are made. .HP 3 .I context Used to return the pointer to an opaque structure. The caller passes the address of a pointer (decl: getdns_context *context; passed as &context) which will be populated as a result of returning from the function. The result is a newly allocated and initialized context (if there are no errors). In the getdns_destroy_context function this is the context whose associated memory will be released. .HP 3 .I set_from_os If set_from_os is 0 then the caller must provide forwarding name servers if running in stub mode. If set_from_os is 1 then the system files are used to initialize the context. /etc/resolv.conf is used to populate forwarders when running as a stub resolver (only "nameserver" lines are recognized). If set_from_os is 1 /etc/hosts entries are preferred before resorting to a DNS query. Errors in the system files will not prevent the context form being constructed. .HP 3 .I userarg In the extended use case this argument is passed unchanged to each of the memory management functions each time they are called. .HP 3 .I malloc The function that will be used for creating response dicts (and the members within the response dicts). By default the system malloc is used. .HP 3 .I realloc The function that will be used for creating response dicts (and the members within the response dicts). By default the system realloc is used. .HP 3 .I free The function that will be used for releasing storage for response dicts (and the members within the response dicts). By default the system free is used. .SH DESCRIPTION (LONG) .LP Many calls in the DNS API require a DNS context. A DNS context contains the information that the API needs in order to process DNS calls, such as the locations of upstream DNS servers, DNSSEC trust anchors, and so on. The internal structure of the DNS context is opaque, and might be different on each OS. When a context is passed to any function, it must be an allocated context; the context must not be NULL. .LP A typical application using this API doesn't need to know anything about contexts. Basically, the application creates a default context, uses it in the functions that require a context, and then deallocates it when done. Context manipulation is available for more DNS-aware programs, but is unlikely to be of interest to applications that just want the results of lookups for A, AAAA, SRV, and PTR records. .LP It is expected that contexts in implementations of the API will not necessarily be thread-safe, but they will not be thread-hostile. A context should not be used by multiple threads: create a new context for use on a different thread. It is just fine for an application to have many contexts, and some DNS-heavy applications will certainly want to have many even if the application uses a single thread. .LP When the context is used in the API for the first time and set_from_os is 1, the API starts replacing some of the values with values from the OS, such as those that would be found in res_query(3), /etc/resolv.conf, and so on, then proceeds with the new function. Some advanced users will not want the API to change the values to the OS's defaults; if set_from_os is 0, the API will not do any updates to the initial values based on changes in the OS. For example, this might be useful if the API is acting as a stub resolver that is using a specific upstream recursive resolver chosen by the application, not the one that might come back from DHCP. .HP .SH "RETURN VALUES" Upon successful completion each of these functions return .B GETDNS_RETURN_GOOD , otherwise the following error values are returned: .LP .B GETDNS_RETURN_GENERIC_ERROR memory allocation failed or some other untoward thing happened while initializing the context .LP .B GETDNS_RETURN_BAD_CONTEXT if the context pointer is invalid (getdns_context_destroy) .LP The getdns_dict returned by getdns_context_get_api_information must be destroyed by the called and includes the following name/value pairs: .IP version_string a bindata containing a printable string of the version of the DNS API implemented by this library .IP implementation_string a bindata containing a printable string set by the implementation .IP resolution_type an int equal to GETDNS_RESOLUTION_RECURSING or GETDNS_RESOLUTION_STUB .IP all_context a getdns_dict with names for all the types of context, feed it to getdns_pretty_print_dict (3) for something easily readable .SH EXAMPLES TBD .SH FILES .br /etc/hosts .br /etc/resolv.conf .SH SEE ALSO .BR libgetdns (3), .BR getdns_address (3), .BR getdns_address_sync (3), .BR getdns_context_set (3), .BR getdns_context_set_context_update_callback (3), .BR getdns_general (3), .BR getdns_general_sync (3), .BR getdns_hostname (3), .BR getdns_hostname_sync (3), .BR getdns_service (3), .BR getdns_service_sync (3). getdns-0.9.0/configure.ac0000664000175100017510000010726512641212403012225 00000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. # known to work with autconf version: autoconf (GNU Autoconf) 2.69 # # @configure_input@ # # Copyright (c) 2013, Verisign, Inc., NLnet Labs # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the names of the copyright holders nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. AC_PREREQ([2.56]) AC_CONFIG_MACRO_DIRS([m4]) sinclude(./m4/acx_openssl.m4) sinclude(./m4/acx_getaddrinfo.m4) sinclude(./m4/ax_check_compile_flag.m4) sinclude(./m4/pkg.m4) AC_INIT([getdns], [0.9.0], [stub-resolver@verisignlabs.com], [], [https://getdnsapi.net]) AC_SUBST(RELEASE_CANDIDATE, []) # Set current date from system if not set AC_ARG_WITH([current-date], [AS_HELP_STRING([--with-current-date] [current date of the compilation, set to fixed date for reproducible builds @<:@default=system@:>@])], [CURRENT_DATE="$with_current_date"], [CURRENT_DATE="`date -u +%Y-%m-%dT%H:%M:%SZ`"]) AC_SUBST(GETDNS_VERSION, ["AC_PACKAGE_VERSION$RELEASE_CANDIDATE"]) AC_SUBST(GETDNS_NUMERIC_VERSION, [0x00090000]) AC_SUBST(API_VERSION, ["December 2015"]) AC_SUBST(API_NUMERIC_VERSION, [0x07df0c00]) GETDNS_COMPILATION_COMMENT="AC_PACKAGE_NAME $GETDNS_VERSION configured on $CURRENT_DATE for the $API_VERSION version of the API" # Library version # --------------- # current:revision:age # (binary-api-number):(which-binary-api-version):(how-many-nrs-backwardscompat) # if source code changes increment revision # if any interfaces have been added/removed/changed since last update then # increment current and set revision to 0 # if any interfaces have been added since the last public release then increment age # if any interfaces have been removed or changed since the last public release then # set age to 0 # # getdns-0.1.4 had libversion 0:0:0 # getdns-0.1.5 had libversion 1:0:0 # getdns-0.1.6 had libversion 1:1:0 # getdns-0.1.7 had libversion 1:2:1 (but should have had 2:0:1) # getdns-0.1.8 had libversion 1:3:0 (but should have had 2:1:1) # getdns-0.2.0 had libversion 2:2:1 # getdns-0.3.0 had libversion 3:3:2 # getdns-0.3.1 had libversion 3:4:2 # getdns-0.3.2 had libversion 3:5:2 # getdns-0.3.3 had libversion 3:6:2 # getdns-0.5.0 had libversion 4:0:3 # getdns-0.5.1 had libversion 4:1:3 (but should have been getdns-0.6.0) # getdns-0.9.0 will have libversion 5:0:4 # GETDNS_LIBVERSION=5:0:4 AC_SUBST(GETDNS_COMPILATION_COMMENT) AC_SUBST(GETDNS_LIBVERSION) AC_CONFIG_SRCDIR([src/getdns/getdns.h.in]) # AM_INIT_AUTOMAKE # LT_INIT AC_CONFIG_MACRO_DIR([m4]) AC_PROG_CC AC_PROG_CPP # Checks for programs. AC_CANONICAL_HOST CFLAGS="$CFLAGS" AC_PROG_CC_C99 AX_CHECK_COMPILE_FLAG([-xc99],[CFLAGS="$CFLAGS -xc99"],[],[]) AX_CHECK_COMPILE_FLAG([-Wall],[CFLAGS="$CFLAGS -Wall"],[],[]) case "$host_os" in linux* ) CFLAGS="$CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE" ;; solaris* ) CFLAGS="$CFLAGS -D__EXTENSIONS__" # for strdup() from ;; darwin* ) CFLAGS="$CFLAGS -D_DARWIN_C_SOURCE" # for strlcpy() from ;; esac # always use ./libtool unless override from commandline (libtool=mylibtool) if test -z "$libtool"; then libtool="`pwd`/libtool" fi AC_SUBST(libtool) AC_PROG_LIBTOOL AC_PROG_INSTALL initial_LIBS="$LIBS" initial_LDFLAGS="$LDFLAGS" dnl Add option to disable the evil rpath. Check whether to use rpath or not. dnl Adds the --disable-rpath option. Uses trick to edit the ./libtool. AC_DEFUN([ACX_ARG_RPATH], [ AC_ARG_ENABLE(rpath, [ --disable-rpath disable hardcoded rpath (default=enabled)], enable_rpath="$enableval", enable_rpath=yes) if test "x$enable_rpath" = xno; then dnl AC_MSG_RESULT([Fixing libtool for -rpath problems.]) AC_CONFIG_COMMANDS([disable-rpath], [ sed < libtool > libtool-2 \ 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_RPATH_SED__ "/' mv libtool-2 libtool chmod 755 libtool libtool="./libtool" ]) fi ]) ACX_ARG_RPATH AC_ARG_ENABLE(debug-sched, AC_HELP_STRING([--enable-debug-sched], [Enable scheduling debugging messages])) AC_ARG_ENABLE(debug-stub, AC_HELP_STRING([--enable-debug-stub], [Enable stub debugging messages])) AC_ARG_ENABLE(debug-sec, AC_HELP_STRING([--enable-debug-sec], [Enable dnssec debugging messages])) AC_ARG_ENABLE(all-debugging, AC_HELP_STRING([--enable-all-debugging], [Enable scheduling, stub and dnssec debugging])) case "$enable_all_debugging" in yes) enable_debug_sched=yes enable_debug_stub=yes enable_debug_sec=yes ;; no|*) ;; esac case "$enable_debug_sched" in yes) AC_DEFINE_UNQUOTED([SCHED_DEBUG], [1], [Define this to enable printing of scheduling debugging messages.]) ;; no|*) ;; esac case "$enable_debug_stub" in yes) AC_DEFINE_UNQUOTED([STUB_DEBUG], [1], [Define this to enable printing of stub debugging messages.]) ;; no|*) ;; esac case "$enable_debug_sec" in yes) AC_DEFINE_UNQUOTED([SEC_DEBUG], [1], [Define this to enable printing of dnssec debugging messages.]) ;; no|*) ;; esac AC_ARG_ENABLE(tcp-fastopen, AC_HELP_STRING([--disable-tcp-fastopen], Disable TCP Fast Open (default=enabled if available)), enable_tcp_fastopen="$enableval", enable_tcp_fastopen=yes) if test "x$enable_tcp_fastopen" = xno; then AC_MSG_WARN([TCP Fast Open is disabled]) else case `uname` in Linux) AC_CHECK_DECL([MSG_FASTOPEN], [AC_DEFINE_UNQUOTED([USE_TCP_FASTOPEN], [1], [Define this to enable TCP fast open.])], [AC_MSG_WARN([TCP Fast Open is not available, continuing without])], [#include ]) ;; Darwin) AC_CHECK_DECL([CONNECT_RESUME_ON_READ_WRITE], [AC_DEFINE_UNQUOTED([USE_OSX_TCP_FASTOPEN], [1], [Define this to enable TCP fast open.])], [AC_MSG_WARN([TCP Fast Open is not available, continuing without])], [#include ]) ;; *) AC_MSG_WARN([TCP Fast Open is not available, continuing without]) ;; esac fi AC_ARG_ENABLE(native-stub-dnssec, AC_HELP_STRING([--disable-native-stub-dnssec], [Disable native stub DNSSEC support])) case "$enable_native_stub_dnssec" in no) ;; yes|*) AC_DEFINE_UNQUOTED([STUB_NATIVE_DNSSEC], [1], [Define this to enable native stub DNSSEC support.]) ;; esac USE_NSS="no" # openssl if test $USE_NSS = "no"; then ACX_WITH_SSL_OPTIONAL ACX_LIB_SSL AC_MSG_CHECKING([for LibreSSL]) if grep VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "LibreSSL" >/dev/null; then AC_MSG_RESULT([yes]) AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL]) # libressl provides these compat functions, but they may also be # declared by the OS in libc. See if they have been declared. AC_CHECK_DECLS([strlcpy,strlcat,arc4random,arc4random_uniform,reallocarray]) else AC_MSG_RESULT([no]) fi AC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT]) AC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT]) AC_CHECK_FUNCS([OPENSSL_config EVP_md5 EVP_sha1 EVP_sha224 EVP_sha256 EVP_sha384 EVP_sha512 FIPS_mode]) 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 #include #endif #ifdef HAVE_OPENSSL_RAND_H #include #endif #ifdef HAVE_OPENSSL_CONF_H #include #endif #ifdef HAVE_OPENSSL_ENGINE_H #include #endif #include #include ]) fi AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support])) case "$enable_sha2" in no) ;; yes|*) AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.]) ;; esac # check wether gost also works AC_DEFUN([AC_CHECK_GOST_WORKS], [AC_REQUIRE([AC_PROG_CC]) AC_MSG_CHECKING([if GOST works]) if test c${cross_compiling} = cno; then BAKCFLAGS="$CFLAGS" if test -n "$ssldir"; then CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib" fi AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include #include #include /* routine to load gost (from sldns) */ int load_gost_id(void) { static int gost_id = 0; const EVP_PKEY_ASN1_METHOD* meth; ENGINE* e; if(gost_id) return gost_id; /* see if configuration loaded gost implementation from other engine*/ meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1); if(meth) { EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); return gost_id; } /* see if engine can be loaded already */ e = ENGINE_by_id("gost"); if(!e) { /* load it ourself, in case statically linked */ ENGINE_load_builtin_engines(); ENGINE_load_dynamic(); e = ENGINE_by_id("gost"); } if(!e) { /* no gost engine in openssl */ return 0; } if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) { ENGINE_finish(e); ENGINE_free(e); return 0; } meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1); if(!meth) { /* algo not found */ ENGINE_finish(e); ENGINE_free(e); return 0; } EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); return gost_id; } int main(void) { EVP_MD_CTX* ctx; const EVP_MD* md; unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */ const char* str = "Hello world"; const unsigned char check[] = { 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 , 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 , 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d , 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d }; OPENSSL_config(NULL); (void)load_gost_id(); md = EVP_get_digestbyname("md_gost94"); if(!md) return 1; memset(digest, 0, sizeof(digest)); ctx = EVP_MD_CTX_create(); if(!ctx) return 2; if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3; if(!EVP_DigestUpdate(ctx, str, 10)) return 4; if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5; /* uncomment to see the hash calculated. {int i; for(i=0; i<32; i++) printf(" %2.2x", (int)digest[i]); printf("\n");} */ if(memcmp(digest, check, sizeof(check)) != 0) return 6; return 0; } ]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"]) CFLAGS="$BAKCFLAGS" else eval "ac_cv_c_gost_works=maybe" fi AC_MSG_RESULT($ac_cv_c_gost_works) ])dnl AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support])) use_gost="no" if test $USE_NSS = "no"; then case "$enable_gost" in no) ;; *) AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])]) AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])]) AC_CHECK_GOST_WORKS if test "$ac_cv_c_gost_works" != no; then use_gost="yes" AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.]) fi ;; esac fi dnl !USE_NSS AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support])) use_ecdsa="no" case "$enable_ecdsa" in no) ;; *) if test $USE_NSS = "no"; then AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])]) AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa])]) AC_CHECK_DECLS([NID_X9_62_prime256v1, NID_secp384r1], [], [AC_MSG_ERROR([OpenSSL does not support the ECDSA curves: please upgrade or rerun with --disable-ecdsa])], [AC_INCLUDES_DEFAULT #include ]) # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency) AC_MSG_CHECKING([if openssl supports SHA2 and ECDSA with EVP]) if grep OPENSSL_VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "OpenSSL" >/dev/null; then if grep OPENSSL_VERSION_NUMBER $ssldir/include/openssl/opensslv.h | grep 0x0 >/dev/null; then AC_MSG_RESULT([no]) AC_DEFINE_UNQUOTED([USE_ECDSA_EVP_WORKAROUND], [1], [Define this to enable an EVP workaround for older openssl]) else AC_MSG_RESULT([yes]) fi else # not OpenSSL, thus likely LibreSSL, which supports it AC_MSG_RESULT([yes]) fi fi # we now know we have ECDSA and the required curves. AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.]) use_ecdsa="yes" ;; 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])) 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.]) ;; no|*) ;; esac case "$enable_draft_edns_cookies" in 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]) fi AC_DEFINE_UNQUOTED([EDNS_COOKIES], [1], [Define this to enable the experimental draft edns cookies.]) ;; no|*) ;; esac AC_DEFINE_UNQUOTED([EDNS_COOKIE_OPCODE], [10], [The edns cookie option code.]) AC_DEFINE_UNQUOTED([EDNS_COOKIE_ROLLOVER_TIME], [(24 * 60 * 60)], [How often the edns client cookie is refreshed.]) AC_DEFINE_UNQUOTED([MAXIMUM_UPSTREAM_OPTION_SPACE], [3000], [limit for dynamically-generated DNS options]) AC_DEFINE_UNQUOTED([EDNS_PADDING_OPCODE], [12], [The edns padding option code.]) my_with_libunbound=1 AC_ARG_ENABLE(stub-only, AC_HELP_STRING([--enable-stub-only], [Restricts resolution modes to STUB (which will be the default mode). Removes the libunbound dependency.])) case "$enable_stub_only" in yes) my_with_libunbound=0 ;; no|*) ;; esac # search to set include and library paths right # find libidn (no libidn on windows though) AC_CHECK_HEADERS([windows.h winsock.h stdio.h winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT]) ACX_CHECK_GETADDRINFO_WITH_INCLUDES if test "$USE_WINSOCK" = 1; then AC_MSG_NOTICE([ Building on Windows ... YES! ]) AC_DEFINE_UNQUOTED([GETDNS_ON_WINDOWS], [1], [Define this to enable Windows build.]) AC_DEFINE_UNQUOTED([STUB_NATIVE_DNSSEC], [1]) LIBS="$LIBS -lgdi32 -liphlpapi" my_with_libunbound=0 my_with_libidn=0 else my_with_libidn=1 fi if test $my_with_libidn = 1 then AC_ARG_WITH(libidn, AS_HELP_STRING([--with-libidn=pathname], [path to libidn (default: search /usr/local ..)]), [], [withval="yes"]) if test x_$withval = x_yes; then for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do if test -f "$dir/include/idna.h"; then CFLAGS="$CFLAGS -I$dir/include" LDFLAGS="$LDFLAGS -L$dir/lib" AC_MSG_NOTICE([Found libidn in $dir]) break fi if test -f "$dir/include/idn/idna.h"; then CFLAGS="$CFLAGS -I$dir/include/idn" LDFLAGS="$LDFLAGS -L$dir/lib" AC_MSG_NOTICE([Found libidn in $dir]) break fi done if test -f "/usr/include/idn/idna.h"; then CFLAGS="$CFLAGS -I/usr/include/idn" #LDFLAGS="$LDFLAGS -L/usr/lib" AC_MSG_NOTICE([Found libidn in /usr]) fi else if test x_$withval != x_no; then CFLAGS="$CFLAGS -I$withval/include" LDFLAGS="$LDFLAGS -L$withval/lib" else my_with_libidn=0 fi fi fi if test $my_with_libunbound = 1 then # find libunbound AC_ARG_WITH(libunbound, AS_HELP_STRING([--with-libunbound=pathname], [path to libunbound (default: search /usr/local ..)]), [], [withval="yes"]) if test x_$withval = x_yes; then for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do if test -f "$dir/include/unbound.h"; then CFLAGS="$CFLAGS -I$dir/include" LDFLAGS="$LDFLAGS -L$dir/lib" AC_MSG_NOTICE([Found libunbound in $dir]) break fi done else if test x_$withval != x_no; then CFLAGS="$CFLAGS -I$withval/include" LDFLAGS="$LDFLAGS -L$withval/lib" else AC_DEFINE_UNQUOTED([DISABLE_RESOLUTION_RECURSING], [1], [Define this to disable recursing resolution type.]) my_with_libunbound=0 fi fi fi # Checks for libraries. found_all_libs=1 if test $my_with_libidn = 1 then AC_MSG_NOTICE([Checking for dependency libidn]) AC_CHECK_LIB([idn], [idna_to_ascii_8z], [], [found_all_libs=0]) fi if test $my_with_libunbound = 1 then AC_MSG_NOTICE([Checking for dependency libunbound]) AC_CHECK_LIB([unbound], [ub_fd], [], [found_all_libs=0]) fi if test $found_all_libs = 0 then AC_MSG_ERROR([One more dependencies is missing]) fi AC_PATH_PROG([DOXYGEN], [doxygen]) if test -z "$DOXYGEN"; then AC_MSG_WARN([doxygen not found, continuing without]) fi # Checks for header files. AC_CHECK_HEADERS([inttypes.h netinet/in.h stdint.h stdlib.h string.h],,, [AC_INCLUDES_DEFAULT]) # Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T AC_TYPE_UINT8_T AC_CHECK_TYPE([u_char]) AC_CHECK_FUNCS([fcntl]) # check ioctlsocket AC_MSG_CHECKING(for ioctlsocket) AC_LINK_IFELSE([AC_LANG_PROGRAM([ #ifdef HAVE_WINSOCK2_H #include #endif ], [ (void)ioctlsocket(0, 0, NULL); ])], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_IOCTLSOCKET, 1, [if the function 'ioctlsocket' is available]) ],[AC_MSG_RESULT(no)]) # Check for libraries for other things than libgetdns after this point, # so the getdns libraries can be reset with: # # LIBS="$getdns_LIBS" # LDFLAGS="$getdns_LDFLAGS" # # afterwards. getdns_LIBS="$LIBS" getdns_LDFLAGS="$LDFLAGS" getdns_CFLAGS="$CFLAGS" #-------------------- libraries needed for libcheck LIBS="$initial_LIBS" CHECK_GETDNS="" CHECK_LIBS="" CHECK_CFLAGS="" PKG_CHECK_MODULES([CHECK],[check >= 0.9.6],[CHECK_GETDNS="check_getdns"],[ AC_SEARCH_LIBS([floor], [m]) AC_SEARCH_LIBS([timer_create], [rt]) AC_SEARCH_LIBS([pthread_create], [pthread]) AC_SEARCH_LIBS([srunner_create],[check check_pic],[ CHECK_GETDNS="check_getdns" CHECK_LIBS="$LIBS"],[ AC_SUBST(NOLIBCHECK, [nolibcheck]) AC_MSG_WARN([libcheck not found or usable; unit tests will not be compiled and run])])]) LIBS="$getdns_LIBS" AC_SUBST([CHECK_GETDNS]) AC_SUBST([CHECK_LIBS]) AC_SUBST([CHECK_CFLAGS]) # end libraries needed for libcheck # find libldns LIBS="$initial_LIBS" LDNS_LIBS="" LDNS_CFLAGS="" LDNS_LDFLAGS="" NOLIBLDNS="" AC_ARG_WITH(libldns, AS_HELP_STRING([--with-libldns=pathname], [path to libldns (default: search /usr/local ..)]), [], [withval="yes"]) if test x_$withval = x_yes; then for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do if test -f "$dir/include/ldns/ldns.h"; then LDNS_CFLAGS="-I$dir/include" LDNS_LDFLAGS="-L$dir/lib" CFLAGS="$CFLAGS $LDNS_CFLAGS" LDFLAGS="$LDFLAGS $LDNS_LDFLAGS" AC_MSG_NOTICE([Found libldns in $dir]) break fi done else if test x_$withval != x_no; then LDNS_CFLAGS="-I$withval/include" LDNS_LDFLAGS="-L$withval/lib" CFLAGS="$CFLAGS $LDNS_CFLAGS" LDFLAGS="$LDFLAGS $LDNS_LDFLAGS" else NOLIBLDNS="nolibldns" AC_MSG_WARN([libldns not found or usable; unit tests will not be compiled and run]) fi fi if test x$NOLIBLDNS = x then AC_CHECK_LIB([ldns], [ldns_dname_new_frm_str], [ LDNS_LIBS="-lldns" AC_DEFINE_UNQUOTED(HAVE_LIBLDNS, [1], [Have libldns]) ], [ NOLIBLDNS="nolibldns" AC_MSG_WARN([libldns not found or usable; unit tests will not be compiled and run]) ]) fi AC_SUBST([LDNS_LIBS]) AC_SUBST([LDNS_CFLAGS]) AC_SUBST([LDNS_LDFLAGS]) AC_SUBST([NOLIBLDNS]) LIBS="$getdns_LIBS" CFLAGS="$getdns_CFLAGS" LDFLAGS="$getdns_LDFLAGS" #-------------------- libevent extension AC_ARG_WITH([libevent], [AS_HELP_STRING([--with-libevent], [path to libevent (default: search /usr/local ..)])], [with_libevent=search], [withval=no]) # libevent 1.x requires a u_char typedef which is not always available # on some systems so our check is a little complicated # we further need to ensure that this is included in the getdns headers # that get installed later so some users may not be building in an # environment that has the generated config.h SO we need to generate # this one extra header in that case have_libevent=0 EXTENSION_LIBEVENT_EXT_LIBS="" EXTENSION_LIBEVENT_LIB="" EXTENSION_LIBEVENT_LDFLAGS="" CHECK_EVENT_PROG="" AS_IF([test x_$withval = x_no], [], [AS_IF([test x_$withval = x_yes], [AC_SEARCH_LIBS([event_loop], [event_core event], [AC_CHECK_FUNCS([event_base_new event_base_free])] [AC_CHECK_HEADERS([event2/event.h], [have_libevent=1] [AS_IF([test "x_$ac_cv_search_event_loop" = "x_none required"],[],[EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop"])], [AC_CHECK_HEADERS([event.h], [have_libevent=1] [AS_IF([test "x_$ac_cv_search_event_loop" = "x_none required"],[],[EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop"])], [AC_MSG_ERROR([event2/event.h and event.h missing, try without libevent])] [have_libevent=0], [AC_INCLUDES_DEFAULT] [#if HAVE_U_CHAR == 0 typedef unsigned char u_char; #endif])], [AC_INCLUDES_DEFAULT])], [AC_MSG_ERROR([libevent missing, try without libevent])] )], [have_libevent=1] [AC_MSG_NOTICE([assuming libevent in $withval])] [CFLAGS="$CFLAGS -I$withval/include"] [EXTENSION_LIBEVENT_LDFLAGS="-L$withval/lib"] [EXTENSION_LIBEVENT_EXT_LIBS="-levent"])] ) AS_IF([test x_$have_libevent = x_1], [EXTENSION_LIBEVENT_LIB="libgetdns_ext_event.la"] [CHECK_EVENT_PROG=check_getdns_event] # libunbound version 1.4.22 and older, not linked against libevent, on FreeBSD, # ============================================================================= # cannot be linked against a program that also links libevent, because of # symbol clash. Libunbound has a libevent clone (called mini_event) build when # not linked against libevent that uses the same symbols as libevent. # First detect if the libevent symbols are visible when linking with libunbound [LIBS="$getdns_LIBS"] [LDFLAGS="$getdns_LDFLAGS"] [AC_MSG_CHECKING([if event_get_version symbol is leaking from libunbound])] [AC_LANG_PUSH(C)] AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[const char *event_get_version(void);]], [[const char *v = event_get_version();]]) ],[[AC_MSG_RESULT([yes])] [AC_MSG_CHECKING([if libunbound is linked against libevent])] AC_RUN_IFELSE( [AC_LANG_PROGRAM( [[const char *event_get_version(void);]], [[const char *v = event_get_version();] [return v@<:@0@:>@ == 'm' && v@<:@1@:>@ == 'i' && v@<:@2@:>@ == 'n' && v@<:@3@:>@ == 'i' ? 1 : 0;]]) ],[[AC_MSG_RESULT([yes])] ],[[AC_MSG_RESULT([no])] [AC_MSG_FAILURE([ *** *** On this system, when using libevent, libunbound must *** also have been compiled with libevent. Please recompile *** libunbound with libevent, or configure --without-libevent. ***])] ] ) ],[[AC_MSG_RESULT([no])] ] ) [AC_LANG_POP(C)]) AC_SUBST(have_libevent) AC_SUBST(EXTENSION_LIBEVENT_LIB) AC_SUBST(EXTENSION_LIBEVENT_EXT_LIBS) AC_SUBST(EXTENSION_LIBEVENT_LDFLAGS) AS_IF([test "x$have_libcheck" = x1], [AC_SUBST(CHECK_EVENT_PROG)]) LIBS="$getdns_LIBS" LDFLAGS="$getdns_LDFLAGS" # end libevent extension #-------------------- libuv extension # if user says nothing about libuv, or specifies --with-libuv=no or --without-libuv # then we do not want libuv extensions built # if user specifies --with-libuv then search for it # if user specifies --with-libuv=/path then check the lib at that path AC_ARG_WITH([libuv], [AS_HELP_STRING([--with-libuv], [path to libuv (default: search /usr/local ..)])], [with_libuv=search], [withval=no]) have_libuv=0 EXTENSION_LIBUV_EXT_LIBS="" EXTENSION_LIBUV_LIB="" EXTENSION_LIBUV_LDFLAGS="" CHECK_UV_PROG="" AS_IF([test x_$withval = x_no], [], [AS_IF([test x_$withval = x_yes], [AC_SEARCH_LIBS([uv_run], [uv], [AC_CHECK_HEADERS([uv.h], [have_libuv=1] [EXTENSION_LIBUV_EXT_LIBS="$ac_cv_search_uv_run"], [AC_MSG_ERROR([uv.h missing, try without libuv])] [have_libuv=0], [AC_INCLUDES_DEFAULT])], [AC_MSG_ERROR([libuv missing, try without libuv])] )], [have_libuv=1] [AC_MSG_NOTICE([assuming libuv in $withval])] [CFLAGS="$CFLAGS -I$withval/include"] [EXTENSION_LIBUV_LDFLAGS="-L$withval/lib"] [EXTENSION_LIBUV_EXT_LIBS="-luv"])] ) AS_IF([test x_$have_libuv = x_1], [EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la"] [CHECK_UV_PROG=check_getdns_uv] [AC_MSG_CHECKING([for new signature of uv_timer_cb]) AC_LANG_PUSH(C) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[#include ] [void test_cb(uv_timer_t *handle);]], [[uv_timer_cb cb = test_cb;] [(*cb)(0);]]) ],[AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_NEW_UV_TIMER_CB, [1], [Does libuv have the new uv_time_cb signature]) ],[AC_MSG_RESULT([no]) ]) AC_LANG_POP(C)] ) AC_SUBST(have_libuv) AC_SUBST(EXTENSION_LIBUV_LIB) AC_SUBST(EXTENSION_LIBUV_EXT_LIBS) AC_SUBST(EXTENSION_LIBUV_LDFLAGS) AS_IF([test "x$have_libcheck" = x1], [AC_SUBST(CHECK_UV_PROG)]) LIBS="$getdns_LIBS" LDFLAGS="$getdns_LDFLAGS" # end libuv extension #-------------------- libev extension AC_ARG_WITH([libev], [AS_HELP_STRING([--with-libev], [path to libev (default: search /usr/local ..)])], [with_libev=search], [withval=no]) have_libev=0 EXTENSION_LIBEV_EXT_LIBS="" EXTENSION_LIBEV_LIB="" EXTENSION_LIBEV_LDFLAGS="" CHECK_EV_PROG="" AS_IF([test x_$withval = x_no], [], [AS_IF([test x_$withval = x_yes], [AC_SEARCH_LIBS([ev_run], [ev], [AC_CHECK_HEADERS([ev.h], [have_libev=1] [EXTENSION_LIBEV_EXT_LIBS="$ac_cv_search_ev_run"], [AC_CHECK_HEADERS([libev/ev.h], [have_libev=1] [EXTENSION_LIBEV_EXT_LIBS="$ac_cv_search_ev_run"], [AC_MSG_ERROR([ev.h missing, try without libev])] [have_libev=0], [AC_INCLUDES_DEFAULT]) ], [AC_INCLUDES_DEFAULT]) ], [AC_MSG_ERROR([libev missing, try without libev])] )], [have_libev=1] [AC_MSG_NOTICE([assuming libev in $withval])] [CFLAGS="$CFLAGS -I$withval/include"] [EXTENSION_LIBEV_LDFLAGS="-L$withval/lib"] [EXTENSION_LIBEV_EXT_LIBS="-lev"])] ) AS_IF([test x_$have_libev = x_1], [EXTENSION_LIBEV_LIB="libgetdns_ext_ev.la"] [CHECK_EV_PROG=check_getdns_ev]) AC_SUBST(have_libev) AC_SUBST(EXTENSION_LIBEV_LIB) AC_SUBST(EXTENSION_LIBEV_EXT_LIBS) AC_SUBST(EXTENSION_LIBEV_LDFLAGS) AS_IF([test "x$have_libcheck" = x1], [AC_SUBST(CHECK_EV_PROG)]) LIBS="$getdns_LIBS" LDFLAGS="$getdns_LDFLAGS" # end libev extension # --with-trust-anchor= AC_DEFINE([SYSCONFDIR], [sysconfdir], [System configuration dir]) AC_ARG_WITH(trust-anchor, AS_HELP_STRING([--with-trust-anchor=KEYFILE], [Default location of the trust anchor file. [default=SYSCONFDIR/unbound/getdns-root.key]]), [ TRUST_ANCHOR_FILE="$withval" ],[ if test "x$TRUST_ANCHOR_FILE" = "x"; then if test "x$sysconfdir" = 'x${prefix}/etc' ; then if test "x$prefix" = 'xNONE' ; then TRUST_ANCHOR_FILE="/etc/unbound/getdns-root.key" else TRUST_ANCHOR_FILE="${prefix}/etc/unbound/getdns-root.key" fi else TRUST_ANCHOR_FILE="${sysconfdir}/unbound/getdns-root.key" fi fi ]) AC_DEFINE_UNQUOTED([TRUST_ANCHOR_FILE], ["$TRUST_ANCHOR_FILE"], [Default trust anchor file]) AC_SUBST(TRUST_ANCHOR_FILE) AC_MSG_NOTICE([Default trust anchor: $TRUST_ANCHOR_FILE]) AC_ARG_WITH(getdns_query, AS_HELP_STRING([--with-getdns_query], [Also compile and install the getdns_query tool]), [], [withval="no"]) if test x_$withval = x_no; then GETDNS_QUERY="" INSTALL_GETDNS_QUERY="" UNINSTALL_GETDNS_QUERY="" else GETDNS_QUERY="getdns_query" INSTALL_GETDNS_QUERY="install-getdns_query" UNINSTALL_GETDNS_QUERY="uninstall-getdns_query" fi AC_SUBST(GETDNS_QUERY) AC_SUBST(INSTALL_GETDNS_QUERY) AC_SUBST(UNINSTALL_GETDNS_QUERY) AC_CONFIG_FILES([Makefile src/Makefile src/version.c src/getdns/getdns.h src/getdns/getdns_extra.h spec/example/Makefile src/test/Makefile doc/Makefile getdns.pc]) if [ test -n "$DOXYGEN" ] then AC_CONFIG_FILES([src/Doxyfile]) fi dnl ----- dnl ----- Start of "Things needed for gldns" section dnl ----- dnl --------------------------------------------------------------------------- AC_CHECK_HEADERS([stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h bsd/string.h sys/select.h],,, [AC_INCLUDES_DEFAULT]) dnl Check the printf-format attribute (if any) dnl result in HAVE_ATTR_FORMAT. dnl AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "format" attribute) AC_CACHE_VAL(ac_cv_c_format_attribute, [ac_cv_c_format_attribute=no AC_TRY_COMPILE( [#include void f (char *format, ...) __attribute__ ((format (printf, 1, 2))); void (*pf) (char *format, ...) __attribute__ ((format (printf, 1, 2))); ], [ f ("%s", "str"); ], [ac_cv_c_format_attribute="yes"], [ac_cv_c_format_attribute="no"]) ]) AC_MSG_RESULT($ac_cv_c_format_attribute) if test $ac_cv_c_format_attribute = yes; then AC_DEFINE(HAVE_ATTR_FORMAT, 1, [Whether the C compiler accepts the "format" attribute]) fi AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "unused" attribute) AC_CACHE_VAL(ac_cv_c_unused_attribute, [ac_cv_c_unused_attribute=no AC_TRY_COMPILE( [#include void f (char *u __attribute__((unused))); ], [ f ("x"); ], [ac_cv_c_unused_attribute="yes"], [ac_cv_c_unused_attribute="no"]) ]) AC_MSG_RESULT($ac_cv_c_unused_attribute) if test $ac_cv_c_unused_attribute = yes; then AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute]) fi AC_CHECK_DECLS([strlcpy,arc4random,arc4random_uniform]) AC_REPLACE_FUNCS(inet_pton) AC_REPLACE_FUNCS(inet_ntop) AC_REPLACE_FUNCS(strlcpy) AC_REPLACE_FUNCS(arc4random) AC_REPLACE_FUNCS(arc4random_uniform) if test "$ac_cv_func_arc4random" = "no"; then AC_LIBOBJ(explicit_bzero) AC_LIBOBJ(arc4_lock) AC_CHECK_FUNCS([getentropy],,[ if test "$USE_WINSOCK" = 1; then AC_LIBOBJ(getentropy_win) else case `uname` in Darwin) AC_LIBOBJ(getentropy_osx) ;; SunOS) AC_LIBOBJ(getentropy_solaris) AC_CHECK_HEADERS([sys/sha2.h],, [ AC_CHECK_FUNCS([SHA512_Update],,[ AC_LIBOBJ(sha512) ]) ], [AC_INCLUDES_DEFAULT]) if test "$ac_cv_header_sys_sha2_h" = "yes"; then # this lib needed for sha2 on solaris LIBS="$LIBS -lmd" fi AC_SEARCH_LIBS([clock_gettime], [rt]) ;; Linux|*) AC_LIBOBJ(getentropy_linux) dnl AC_CHECK_FUNCS([SHA512_Update],,[ dnl AC_DEFINE([COMPAT_SHA512], [1], [Do sha512 definitions in config.h]) dnl AC_LIBOBJ(sha512) dnl]) AC_CHECK_HEADERS([sys/sysctl.h],,, [AC_INCLUDES_DEFAULT]) AC_CHECK_FUNCS([getauxval]) AC_SEARCH_LIBS([clock_gettime], [rt]) ;; esac fi ]) fi AC_DEFINE(USE_MINI_EVENT, 1, [Needed for sync stub resolver functions]) AC_TYPE_SIGNAL case `uname` in FreeBSD) C99COMPATFLAGS="" ;; *) C99COMPATFLAGS="-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600" ;; esac AC_SUBST(C99COMPATFLAGS) AH_BOTTOM([ /* the version of the windows API enabled */ #undef WINVER #undef _WIN32_WINNT #define WINVER 0x0600 // 0x0502 #define _WIN32_WINNT 0x0600 // 0x0502 #ifdef HAVE_WINSOCK2_H #include #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif #ifndef USE_WINSOCK #define ARG_LL "%ll" #else #define ARG_LL "%I64" #endif /* detect if we need to cast to unsigned int for FD_SET to avoid warnings */ #ifdef HAVE_WINSOCK2_H #define FD_SET_T (u_int) #else #define FD_SET_T #endif #include #include #include #include #include #ifdef HAVE_BSD_STRING_H #include #endif #ifdef __cplusplus extern "C" { #endif #if STDC_HEADERS #include #include #endif #if !defined(HAVE_STRLCPY) || !HAVE_DECL_STRLCPY || !defined(strlcpy) size_t strlcpy(char *dst, const char *src, size_t siz); #else #ifndef __BSD_VISIBLE #define __BSD_VISIBLE 1 #endif #endif #if !defined(HAVE_ARC4RANDOM) || !HAVE_DECL_ARC4RANDOM uint32_t arc4random(void); #endif #if !defined(HAVE_ARC4RANDOM_UNIFORM) || !HAVE_DECL_ARC4RANDOM_UNIFORM uint32_t arc4random_uniform(uint32_t upper_bound); #endif #ifndef HAVE_ARC4RANDOM void explicit_bzero(void* buf, size_t len); int getentropy(void* buf, size_t len); void arc4random_buf(void* buf, size_t n); void _ARC4_LOCK(void); void _ARC4_UNLOCK(void); #endif #ifdef COMPAT_SHA512 #ifndef SHA512_DIGEST_LENGTH #define SHA512_BLOCK_LENGTH 128 #define SHA512_DIGEST_LENGTH 64 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) typedef struct _SHA512_CTX { uint64_t state[8]; uint64_t bitcount[2]; uint8_t buffer[SHA512_BLOCK_LENGTH]; } SHA512_CTX; #endif /* SHA512_DIGEST_LENGTH */ void SHA512_Init(SHA512_CTX*); void SHA512_Update(SHA512_CTX*, void*, size_t); void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); unsigned char *SHA512(void* data, unsigned int data_len, unsigned char *digest); #endif /* COMPAT_SHA512 */ #ifndef HAVE_INET_PTON int inet_pton(int af, const char* src, void* dst); #endif /* HAVE_INET_PTON */ #ifndef HAVE_INET_NTOP const char *inet_ntop(int af, const void *src, char *dst, size_t size); #endif #ifdef __cplusplus } #endif /** Use on-board gldns */ #define USE_GLDNS 1 #ifdef HAVE_SSL # define GLDNS_BUILD_CONFIG_HAVE_SSL 1 #endif #ifdef HAVE_STDARG_H #include #endif #include #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #ifdef HAVE_OPENSSL_SSL_H #include #endif #ifdef HAVE_ATTR_FORMAT # define ATTR_FORMAT(archetype, string_index, first_to_check) \ __attribute__ ((format (archetype, string_index, first_to_check))) #else /* !HAVE_ATTR_FORMAT */ # define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */ #endif /* !HAVE_ATTR_FORMAT */ #if defined(DOXYGEN) # define ATTR_UNUSED(x) x #elif defined(__cplusplus) # define ATTR_UNUSED(x) #elif defined(HAVE_ATTR_UNUSED) # define ATTR_UNUSED(x) x __attribute__((unused)) #else /* !HAVE_ATTR_UNUSED */ # define ATTR_UNUSED(x) x #endif /* !HAVE_ATTR_UNUSED */ #ifdef TIME_WITH_SYS_TIME # include # include #else # ifdef HAVE_SYS_TIME_H # include # else # include # endif #endif #ifdef HAVE_LIBUNBOUND #include #endif ]) dnl --------------------------------------------------------------------------- dnl ----- dnl ----- End of "Things needed for gldns" section dnl ----- AC_CONFIG_HEADER([src/config.h]) AC_OUTPUT getdns-0.9.0/config.sub0000755000175100017510000010577512641212403011724 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2014 Free Software Foundation, Inc. timestamp='2014-09-11' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches with a ChangeLog entry to config-patches@gnu.org. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: getdns-0.9.0/AUTHORS0000664000175100017510000000041212641212403010771 00000000000000Craig Despeaux Neel Goyal Allison Mankin Melinda Shore Willem Toorop W.C.A. Wijngaards Glen Wiley getdns-0.9.0/INSTALL0000664000175100017510000004070612641212403010764 00000000000000Installation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2012 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. (Options specific to getdns are listed at the end of this document.) Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the `make install' phase executed with root privileges. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. This is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the `make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of `${prefix}'. Any directories that were specified during `configure', but not in terms of `${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For example, `make install DESTDIR=/alternate/directory' will prepend `/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with `make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX `make' updates targets which have the same time stamps as their prerequisites, which makes it generally unusable when shipped generated files such as `configure' are involved. Use GNU `make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common On Mac OSX getdns will not build against the version of OpenSSL shipped with OSX. If you link against a self-complied version of OpenSSL then manual configuration of certificates into the default OpenSSL directory /usr/local/etc/openssl/certs is currently required for TLS authentication to work. However if linking against the version of OpenSSL installed via Homebrew TLS authentication will work out of the box. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf limitation. Until the limitation is lifted, you can use this workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. getdns-specific Options ======================= `--with-libidn=pathname' path to libidn (default: search /usr/local ..) `--with-libldns=pathname' path to libldns (default: search /usr/local ..) `--with-libunbound=pathname' path to libunbound (default: search /usr/local ..) `--with-libevent' path to libevent (default: search /usr/local ..) `--with-libuv' path to libuv (default: search /usr/local ..) `--with-libev' path to libev (default: search /usr/local ..) `--with-trust-anchor=KEYFILE' Default location of the trust anchor file. [default=SYSCONFDIR/unbound/getdns-root.key] getdns-0.9.0/configure0000775000175100017510000166022112641212403011643 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for getdns 0.9.0. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: stub-resolver@verisignlabs.com about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='getdns' PACKAGE_TARNAME='getdns' PACKAGE_VERSION='0.9.0' PACKAGE_STRING='getdns 0.9.0' PACKAGE_BUGREPORT='stub-resolver@verisignlabs.com' PACKAGE_URL='https://getdnsapi.net' ac_unique_file="src/getdns/getdns.h.in" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS C99COMPATFLAGS LIBOBJS UNINSTALL_GETDNS_QUERY INSTALL_GETDNS_QUERY GETDNS_QUERY TRUST_ANCHOR_FILE CHECK_EV_PROG EXTENSION_LIBEV_LDFLAGS EXTENSION_LIBEV_EXT_LIBS EXTENSION_LIBEV_LIB have_libev CHECK_UV_PROG EXTENSION_LIBUV_LDFLAGS EXTENSION_LIBUV_EXT_LIBS EXTENSION_LIBUV_LIB have_libuv CHECK_EVENT_PROG EXTENSION_LIBEVENT_LDFLAGS EXTENSION_LIBEVENT_EXT_LIBS EXTENSION_LIBEVENT_LIB have_libevent NOLIBLDNS LDNS_LDFLAGS LDNS_CFLAGS LDNS_LIBS CHECK_GETDNS NOLIBCHECK CHECK_LIBS CHECK_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG DOXYGEN RUNTIME_PATH HAVE_SSL INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL AWK RANLIB STRIP ac_ct_AR AR DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED LIBTOOL libtool host_os host_vendor host_cpu host build_os build_vendor build_cpu build CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC GETDNS_LIBVERSION GETDNS_COMPILATION_COMMENT API_NUMERIC_VERSION API_VERSION GETDNS_NUMERIC_VERSION GETDNS_VERSION RELEASE_CANDIDATE target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking with_current_date enable_shared enable_static with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock enable_rpath enable_debug_sched enable_debug_stub enable_debug_sec enable_all_debugging enable_tcp_fastopen enable_native_stub_dnssec with_ssl enable_sha2 enable_gost enable_ecdsa enable_draft_dnssec_roadblock_avoidance enable_draft_edns_cookies enable_all_drafts enable_stub_only with_libidn with_libunbound with_libldns with_libevent with_libuv with_libev with_trust_anchor with_getdns_query ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR CHECK_CFLAGS CHECK_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures getdns 0.9.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/getdns] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of getdns 0.9.0:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-rpath disable hardcoded rpath (default=enabled) --enable-debug-sched Enable scheduling debugging messages --enable-debug-stub Enable stub debugging messages --enable-debug-sec Enable dnssec debugging messages --enable-all-debugging Enable scheduling, stub and dnssec debugging --disable-tcp-fastopen Disable TCP Fast Open (default=enabled if available) --disable-native-stub-dnssec Disable native stub DNSSEC support --disable-sha2 Disable SHA256 and SHA512 RRSIG support --disable-gost Disable GOST support --disable-ecdsa Disable ECDSA support --enable-draft-dnssec-roadblock-avoidance Enable experimental dnssec roadblock avoidance --enable-draft-edns-cookies Enable experimental edns cookies --enable-all-drafts Enable cookies and roadblock avoidance --enable-stub-only Restricts resolution modes to STUB (which will be the default mode). Removes the libunbound dependency. Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-current-date current date of the compilation, set to fixed date for reproducible builds [default=system] --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-ssl=pathname enable SSL (will check /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr) --with-libidn=pathname path to libidn (default: search /usr/local ..) --with-libunbound=pathname path to libunbound (default: search /usr/local ..) --with-libldns=pathname path to libldns (default: search /usr/local ..) --with-libevent path to libevent (default: search /usr/local ..) --with-libuv path to libuv (default: search /usr/local ..) --with-libev path to libev (default: search /usr/local ..) --with-trust-anchor=KEYFILE Default location of the trust anchor file. [default=SYSCONFDIR/unbound/getdns-root.key] --with-getdns_query Also compile and install the getdns_query tool Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path CHECK_CFLAGS C compiler flags for CHECK, overriding pkg-config CHECK_LIBS linker flags for CHECK, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . getdns home page: . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF getdns configure 0.9.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES # --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_find_uintX_t LINENO BITS VAR # ------------------------------------ # Finds an unsigned integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_uintX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 $as_echo_n "checking for uint$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : case $ac_type in #( uint$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_uintX_t cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by getdns $as_me 0.9.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Set current date from system if not set # Check whether --with-current-date was given. if test "${with_current_date+set}" = set; then : withval=$with_current_date; CURRENT_DATE="$with_current_date" else CURRENT_DATE="`date -u +%Y-%m-%dT%H:%M:%SZ`" fi GETDNS_VERSION="0.9.0$RELEASE_CANDIDATE" GETDNS_NUMERIC_VERSION=0x00090000 API_VERSION="December 2015" API_NUMERIC_VERSION=0x07df0c00 GETDNS_COMPILATION_COMMENT="getdns $GETDNS_VERSION configured on $CURRENT_DATE for the $API_VERSION version of the API" # Library version # --------------- # current:revision:age # (binary-api-number):(which-binary-api-version):(how-many-nrs-backwardscompat) # if source code changes increment revision # if any interfaces have been added/removed/changed since last update then # increment current and set revision to 0 # if any interfaces have been added since the last public release then increment age # if any interfaces have been removed or changed since the last public release then # set age to 0 # # getdns-0.1.4 had libversion 0:0:0 # getdns-0.1.5 had libversion 1:0:0 # getdns-0.1.6 had libversion 1:1:0 # getdns-0.1.7 had libversion 1:2:1 (but should have had 2:0:1) # getdns-0.1.8 had libversion 1:3:0 (but should have had 2:1:1) # getdns-0.2.0 had libversion 2:2:1 # getdns-0.3.0 had libversion 3:3:2 # getdns-0.3.1 had libversion 3:4:2 # getdns-0.3.2 had libversion 3:5:2 # getdns-0.3.3 had libversion 3:6:2 # getdns-0.5.0 had libversion 4:0:3 # getdns-0.5.1 had libversion 4:1:3 (but should have been getdns-0.6.0) # getdns-0.9.0 will have libversion 5:0:4 # GETDNS_LIBVERSION=5:0:4 # AM_INIT_AUTOMAKE # LT_INIT ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Checks for programs. ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac CFLAGS="$CFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5 $as_echo_n "checking for $CC option to accept ISO C99... " >&6; } if ${ac_cv_prog_cc_c99+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include // Check varargs macros. These examples are taken from C99 6.10.3.5. #define debug(...) fprintf (stderr, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK your preprocessor is broken; #endif #if BIG_OK #else your preprocessor is broken; #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0; } // Check varargs and va_copy. static void test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str; int number; float fnumber; while (*format) { switch (*format++) { case 's': // string str = va_arg (args_copy, const char *); break; case 'd': // int number = va_arg (args_copy, int); break; case 'f': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); } int main () { // Check bool. _Bool success = false; // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. test_varargs ("s, d' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' || dynamic_array[ni.number - 1] != 543); ; return 0; } _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c99" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c99" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 $as_echo "$ac_cv_prog_cc_c99" >&6; } ;; esac if test "x$ac_cv_prog_cc_c99" != xno; then : fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -xc99" >&5 $as_echo_n "checking whether C compiler accepts -xc99... " >&6; } if ${ax_cv_check_cflags___xc99+:} false; then : $as_echo_n "(cached) " >&6 else ax_check_save_flags=$CFLAGS CFLAGS="$CFLAGS -xc99" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ax_cv_check_cflags___xc99=yes else ax_cv_check_cflags___xc99=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS=$ax_check_save_flags fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___xc99" >&5 $as_echo "$ax_cv_check_cflags___xc99" >&6; } if test x"$ax_cv_check_cflags___xc99" = xyes; then : CFLAGS="$CFLAGS -xc99" else : fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wall" >&5 $as_echo_n "checking whether C compiler accepts -Wall... " >&6; } if ${ax_cv_check_cflags___Wall+:} false; then : $as_echo_n "(cached) " >&6 else ax_check_save_flags=$CFLAGS CFLAGS="$CFLAGS -Wall" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ax_cv_check_cflags___Wall=yes else ax_cv_check_cflags___Wall=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS=$ax_check_save_flags fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wall" >&5 $as_echo "$ax_cv_check_cflags___Wall" >&6; } if test x"$ax_cv_check_cflags___Wall" = xyes; then : CFLAGS="$CFLAGS -Wall" else : fi case "$host_os" in linux* ) CFLAGS="$CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE" ;; solaris* ) CFLAGS="$CFLAGS -D__EXTENSIONS__" # for strdup() from ;; darwin* ) CFLAGS="$CFLAGS -D_DARWIN_C_SOURCE" # for strlcpy() from ;; esac # always use ./libtool unless override from commandline (libtool=mylibtool) if test -z "$libtool"; then libtool="`pwd`/libtool" fi case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.2' macro_revision='1.3337' ltmain="$ac_aux_dir/ltmain.sh" # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi link_all_deplibs=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' initial_LIBS="$LIBS" initial_LDFLAGS="$LDFLAGS" # Check whether --enable-rpath was given. if test "${enable_rpath+set}" = set; then : enableval=$enable_rpath; enable_rpath="$enableval" else enable_rpath=yes fi if test "x$enable_rpath" = xno; then ac_config_commands="$ac_config_commands disable-rpath" fi # Check whether --enable-debug-sched was given. if test "${enable_debug_sched+set}" = set; then : enableval=$enable_debug_sched; fi # Check whether --enable-debug-stub was given. if test "${enable_debug_stub+set}" = set; then : enableval=$enable_debug_stub; fi # Check whether --enable-debug-sec was given. if test "${enable_debug_sec+set}" = set; then : enableval=$enable_debug_sec; fi # Check whether --enable-all-debugging was given. if test "${enable_all_debugging+set}" = set; then : enableval=$enable_all_debugging; fi case "$enable_all_debugging" in yes) enable_debug_sched=yes enable_debug_stub=yes enable_debug_sec=yes ;; no|*) ;; esac case "$enable_debug_sched" in yes) cat >>confdefs.h <<_ACEOF #define SCHED_DEBUG 1 _ACEOF ;; no|*) ;; esac case "$enable_debug_stub" in yes) cat >>confdefs.h <<_ACEOF #define STUB_DEBUG 1 _ACEOF ;; no|*) ;; esac case "$enable_debug_sec" in yes) cat >>confdefs.h <<_ACEOF #define SEC_DEBUG 1 _ACEOF ;; no|*) ;; esac # Check whether --enable-tcp-fastopen was given. if test "${enable_tcp_fastopen+set}" = set; then : enableval=$enable_tcp_fastopen; enable_tcp_fastopen="$enableval" else enable_tcp_fastopen=yes fi if test "x$enable_tcp_fastopen" = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: TCP Fast Open is disabled" >&5 $as_echo "$as_me: WARNING: TCP Fast Open is disabled" >&2;} else case `uname` in Linux) ac_fn_c_check_decl "$LINENO" "MSG_FASTOPEN" "ac_cv_have_decl_MSG_FASTOPEN" "#include " if test "x$ac_cv_have_decl_MSG_FASTOPEN" = xyes; then : cat >>confdefs.h <<_ACEOF #define USE_TCP_FASTOPEN 1 _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: TCP Fast Open is not available, continuing without" >&5 $as_echo "$as_me: WARNING: TCP Fast Open is not available, continuing without" >&2;} fi ;; Darwin) ac_fn_c_check_decl "$LINENO" "CONNECT_RESUME_ON_READ_WRITE" "ac_cv_have_decl_CONNECT_RESUME_ON_READ_WRITE" "#include " if test "x$ac_cv_have_decl_CONNECT_RESUME_ON_READ_WRITE" = xyes; then : cat >>confdefs.h <<_ACEOF #define USE_OSX_TCP_FASTOPEN 1 _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: TCP Fast Open is not available, continuing without" >&5 $as_echo "$as_me: WARNING: TCP Fast Open is not available, continuing without" >&2;} fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: TCP Fast Open is not available, continuing without" >&5 $as_echo "$as_me: WARNING: TCP Fast Open is not available, continuing without" >&2;} ;; esac fi # Check whether --enable-native-stub-dnssec was given. if test "${enable_native_stub_dnssec+set}" = set; then : enableval=$enable_native_stub_dnssec; fi case "$enable_native_stub_dnssec" in no) ;; yes|*) cat >>confdefs.h <<_ACEOF #define STUB_NATIVE_DNSSEC 1 _ACEOF ;; esac USE_NSS="no" # openssl if test $USE_NSS = "no"; then # Check whether --with-ssl was given. if test "${with_ssl+set}" = set; then : withval=$with_ssl; else withval="yes" fi withval=$withval if test x_$withval != x_no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL" >&5 $as_echo_n "checking for SSL... " >&6; } if test x_$withval = x_ -o x_$withval = x_yes; then withval="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr" fi for dir in $withval; do ssldir="$dir" if test -f "$dir/include/openssl/ssl.h"; then found_ssl="yes" cat >>confdefs.h <<_ACEOF #define HAVE_SSL /**/ _ACEOF if test "$ssldir" != "/usr"; then CPPFLAGS="$CPPFLAGS -I$ssldir/include" LIBSSL_CPPFLAGS="$LIBSSL_CPPFLAGS -I$ssldir/include" fi break; fi done if test x_$found_ssl != x_yes; then as_fn_error $? "Cannot find the SSL libraries in $withval" "$LINENO" 5 else { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in $ssldir" >&5 $as_echo "found in $ssldir" >&6; } HAVE_SSL=yes if test "$ssldir" != "/usr" -a "$ssldir" != ""; then LDFLAGS="$LDFLAGS -L$ssldir/lib" LIBSSL_LDFLAGS="$LIBSSL_LDFLAGS -L$ssldir/lib" if test "x$enable_rpath" = xyes; then if echo "$ssldir/lib" | grep "^/" >/dev/null; then RUNTIME_PATH="$RUNTIME_PATH -R$ssldir/lib" fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for HMAC_CTX_init in -lcrypto" >&5 $as_echo_n "checking for HMAC_CTX_init in -lcrypto... " >&6; } LIBS="$LIBS -lssl -lcrypto" LIBSSL_LIBS="$LIBSSL_LIBS -lssl -lcrypto" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { int HMAC_CTX_init(void); (void)HMAC_CTX_init(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_HMAC_CTX_INIT 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } # check if -lwsock32 or -lgdi32 are needed. BAKLIBS="$LIBS" BAKSSLLIBS="$LIBSSL_LIBS" LIBS="$LIBS -lgdi32" LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -lgdi32" >&5 $as_echo_n "checking if -lcrypto needs -lgdi32... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { int HMAC_CTX_init(void); (void)HMAC_CTX_init(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define HAVE_HMAC_CTX_INIT 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } LIBS="$BAKLIBS" LIBSSL_LIBS="$BAKSSLLIBS" LIBS="$LIBS -ldl" LIBSSL_LIBS="$LIBSSL_LIBS -ldl" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -ldl" >&5 $as_echo_n "checking if -lcrypto needs -ldl... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { int HMAC_CTX_init(void); (void)HMAC_CTX_init(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define HAVE_HMAC_CTX_INIT 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "OpenSSL found in $ssldir, but version 0.9.7 or higher is required" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi fi for ac_header in openssl/ssl.h do : ac_fn_c_check_header_compile "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default " if test "x$ac_cv_header_openssl_ssl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_SSL_H 1 _ACEOF fi done for ac_header in openssl/err.h do : ac_fn_c_check_header_compile "$LINENO" "openssl/err.h" "ac_cv_header_openssl_err_h" "$ac_includes_default " if test "x$ac_cv_header_openssl_err_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_ERR_H 1 _ACEOF fi done for ac_header in openssl/rand.h do : ac_fn_c_check_header_compile "$LINENO" "openssl/rand.h" "ac_cv_header_openssl_rand_h" "$ac_includes_default " if test "x$ac_cv_header_openssl_rand_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_RAND_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TLSv1_2_client_method in -lssl" >&5 $as_echo_n "checking for TLSv1_2_client_method in -lssl... " >&6; } if ${ac_cv_lib_ssl_TLSv1_2_client_method+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lssl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char TLSv1_2_client_method (); int main () { return TLSv1_2_client_method (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ssl_TLSv1_2_client_method=yes else ac_cv_lib_ssl_TLSv1_2_client_method=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_TLSv1_2_client_method" >&5 $as_echo "$ac_cv_lib_ssl_TLSv1_2_client_method" >&6; } if test "x$ac_cv_lib_ssl_TLSv1_2_client_method" = xyes; then : $as_echo "#define HAVE_TLS_v1_2 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find TLSv1_2_client_method in libssl library. TLS will not be available." >&5 $as_echo "$as_me: WARNING: Cannot find TLSv1_2_client_method in libssl library. TLS will not be available." >&2;} fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_CTX_get0_param in -lssl" >&5 $as_echo_n "checking for SSL_CTX_get0_param in -lssl... " >&6; } if ${ac_cv_lib_ssl_SSL_CTX_get0_param+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lssl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char SSL_CTX_get0_param (); int main () { return SSL_CTX_get0_param (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ssl_SSL_CTX_get0_param=yes else ac_cv_lib_ssl_SSL_CTX_get0_param=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_CTX_get0_param" >&5 $as_echo "$ac_cv_lib_ssl_SSL_CTX_get0_param" >&6; } if test "x$ac_cv_lib_ssl_SSL_CTX_get0_param" = xyes; then : $as_echo "#define HAVE_SSL_HN_AUTH 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find SSL_CTX_get0_param in libssl library. TLS hostname verification will not be available." >&5 $as_echo "$as_me: WARNING: Cannot find SSL_CTX_get0_param in libssl library. TLS hostname verification will not be available." >&2;} fi # check if libssl needs libdl BAKLIBS="$LIBS" LIBS="-lssl $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libssl needs libdl" >&5 $as_echo_n "checking if libssl needs libdl... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char SSL_CTX_new (); int main () { return SSL_CTX_new (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } LIBS="$BAKLIBS" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } LIBS="$BAKLIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 $as_echo_n "checking for library containing dlopen... " >&6; } if ${ac_cv_search_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF for ac_lib in '' dl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_dlopen=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_dlopen+:} false; then : break fi done if ${ac_cv_search_dlopen+:} false; then : else ac_cv_search_dlopen=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 $as_echo "$ac_cv_search_dlopen" >&6; } ac_res=$ac_cv_search_dlopen if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LibreSSL" >&5 $as_echo_n "checking for LibreSSL... " >&6; } if grep VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "LibreSSL" >/dev/null; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LIBRESSL 1" >>confdefs.h # libressl provides these compat functions, but they may also be # declared by the OS in libc. See if they have been declared. ac_fn_c_check_decl "$LINENO" "strlcpy" "ac_cv_have_decl_strlcpy" "$ac_includes_default" if test "x$ac_cv_have_decl_strlcpy" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRLCPY $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "strlcat" "ac_cv_have_decl_strlcat" "$ac_includes_default" if test "x$ac_cv_have_decl_strlcat" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRLCAT $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "arc4random" "ac_cv_have_decl_arc4random" "$ac_includes_default" if test "x$ac_cv_have_decl_arc4random" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_ARC4RANDOM $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "arc4random_uniform" "ac_cv_have_decl_arc4random_uniform" "$ac_includes_default" if test "x$ac_cv_have_decl_arc4random_uniform" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_ARC4RANDOM_UNIFORM $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "reallocarray" "ac_cv_have_decl_reallocarray" "$ac_includes_default" if test "x$ac_cv_have_decl_reallocarray" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_REALLOCARRAY $ac_have_decl _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi for ac_header in openssl/conf.h do : ac_fn_c_check_header_compile "$LINENO" "openssl/conf.h" "ac_cv_header_openssl_conf_h" "$ac_includes_default " if test "x$ac_cv_header_openssl_conf_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_CONF_H 1 _ACEOF fi done for ac_header in openssl/engine.h do : ac_fn_c_check_header_compile "$LINENO" "openssl/engine.h" "ac_cv_header_openssl_engine_h" "$ac_includes_default " if test "x$ac_cv_header_openssl_engine_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_ENGINE_H 1 _ACEOF fi done for ac_func in OPENSSL_config EVP_md5 EVP_sha1 EVP_sha224 EVP_sha256 EVP_sha384 EVP_sha512 FIPS_mode do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_c_check_decl "$LINENO" "SSL_COMP_get_compression_methods" "ac_cv_have_decl_SSL_COMP_get_compression_methods" " $ac_includes_default #ifdef HAVE_OPENSSL_ERR_H #include #endif #ifdef HAVE_OPENSSL_RAND_H #include #endif #ifdef HAVE_OPENSSL_CONF_H #include #endif #ifdef HAVE_OPENSSL_ENGINE_H #include #endif #include #include " if test "x$ac_cv_have_decl_SSL_COMP_get_compression_methods" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "sk_SSL_COMP_pop_free" "ac_cv_have_decl_sk_SSL_COMP_pop_free" " $ac_includes_default #ifdef HAVE_OPENSSL_ERR_H #include #endif #ifdef HAVE_OPENSSL_RAND_H #include #endif #ifdef HAVE_OPENSSL_CONF_H #include #endif #ifdef HAVE_OPENSSL_ENGINE_H #include #endif #include #include " if test "x$ac_cv_have_decl_sk_SSL_COMP_pop_free" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SK_SSL_COMP_POP_FREE $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "SSL_CTX_set_ecdh_auto" "ac_cv_have_decl_SSL_CTX_set_ecdh_auto" " $ac_includes_default #ifdef HAVE_OPENSSL_ERR_H #include #endif #ifdef HAVE_OPENSSL_RAND_H #include #endif #ifdef HAVE_OPENSSL_CONF_H #include #endif #ifdef HAVE_OPENSSL_ENGINE_H #include #endif #include #include " if test "x$ac_cv_have_decl_SSL_CTX_set_ecdh_auto" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SSL_CTX_SET_ECDH_AUTO $ac_have_decl _ACEOF fi # Check whether --enable-sha2 was given. if test "${enable_sha2+set}" = set; then : enableval=$enable_sha2; fi case "$enable_sha2" in no) ;; yes|*) $as_echo "#define USE_SHA2 1" >>confdefs.h ;; esac # check wether gost also works # Check whether --enable-gost was given. if test "${enable_gost+set}" = set; then : enableval=$enable_gost; fi use_gost="no" if test $USE_NSS = "no"; then case "$enable_gost" in no) ;; *) ac_fn_c_check_func "$LINENO" "EVP_PKEY_set_type_str" "ac_cv_func_EVP_PKEY_set_type_str" if test "x$ac_cv_func_EVP_PKEY_set_type_str" = xyes; then : : else as_fn_error $? "OpenSSL 1.0.0 is needed for GOST support" "$LINENO" 5 fi ac_fn_c_check_func "$LINENO" "EC_KEY_new" "ac_cv_func_EC_KEY_new" if test "x$ac_cv_func_EC_KEY_new" = xyes; then : else as_fn_error $? "OpenSSL does not support ECC, needed for GOST support" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if GOST works" >&5 $as_echo_n "checking if GOST works... " >&6; } if test c${cross_compiling} = cno; then BAKCFLAGS="$CFLAGS" if test -n "$ssldir"; then CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib" fi if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include /* routine to load gost (from sldns) */ int load_gost_id(void) { static int gost_id = 0; const EVP_PKEY_ASN1_METHOD* meth; ENGINE* e; if(gost_id) return gost_id; /* see if configuration loaded gost implementation from other engine*/ meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1); if(meth) { EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); return gost_id; } /* see if engine can be loaded already */ e = ENGINE_by_id("gost"); if(!e) { /* load it ourself, in case statically linked */ ENGINE_load_builtin_engines(); ENGINE_load_dynamic(); e = ENGINE_by_id("gost"); } if(!e) { /* no gost engine in openssl */ return 0; } if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) { ENGINE_finish(e); ENGINE_free(e); return 0; } meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1); if(!meth) { /* algo not found */ ENGINE_finish(e); ENGINE_free(e); return 0; } EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); return gost_id; } int main(void) { EVP_MD_CTX* ctx; const EVP_MD* md; unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */ const char* str = "Hello world"; const unsigned char check[] = { 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 , 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 , 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d , 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d }; OPENSSL_config(NULL); (void)load_gost_id(); md = EVP_get_digestbyname("md_gost94"); if(!md) return 1; memset(digest, 0, sizeof(digest)); ctx = EVP_MD_CTX_create(); if(!ctx) return 2; if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3; if(!EVP_DigestUpdate(ctx, str, 10)) return 4; if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5; /* uncomment to see the hash calculated. {int i; for(i=0; i<32; i++) printf(" %2.2x", (int)digest[i]); printf("\n");} */ if(memcmp(digest, check, sizeof(check)) != 0) return 6; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : eval "ac_cv_c_gost_works=yes" else eval "ac_cv_c_gost_works=no" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi CFLAGS="$BAKCFLAGS" else eval "ac_cv_c_gost_works=maybe" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_gost_works" >&5 $as_echo "$ac_cv_c_gost_works" >&6; } if test "$ac_cv_c_gost_works" != no; then use_gost="yes" $as_echo "#define USE_GOST 1" >>confdefs.h fi ;; esac fi # Check whether --enable-ecdsa was given. if test "${enable_ecdsa+set}" = set; then : enableval=$enable_ecdsa; fi use_ecdsa="no" case "$enable_ecdsa" in no) ;; *) if test $USE_NSS = "no"; then ac_fn_c_check_func "$LINENO" "ECDSA_sign" "ac_cv_func_ECDSA_sign" if test "x$ac_cv_func_ECDSA_sign" = xyes; then : else as_fn_error $? "OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa" "$LINENO" 5 fi ac_fn_c_check_func "$LINENO" "SHA384_Init" "ac_cv_func_SHA384_Init" if test "x$ac_cv_func_SHA384_Init" = xyes; then : else as_fn_error $? "OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa" "$LINENO" 5 fi ac_fn_c_check_decl "$LINENO" "NID_X9_62_prime256v1" "ac_cv_have_decl_NID_X9_62_prime256v1" "$ac_includes_default #include " if test "x$ac_cv_have_decl_NID_X9_62_prime256v1" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_NID_X9_62_PRIME256V1 $ac_have_decl _ACEOF if test $ac_have_decl = 1; then : else as_fn_error $? "OpenSSL does not support the ECDSA curves: please upgrade or rerun with --disable-ecdsa" "$LINENO" 5 fi ac_fn_c_check_decl "$LINENO" "NID_secp384r1" "ac_cv_have_decl_NID_secp384r1" "$ac_includes_default #include " if test "x$ac_cv_have_decl_NID_secp384r1" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_NID_SECP384R1 $ac_have_decl _ACEOF if test $ac_have_decl = 1; then : else as_fn_error $? "OpenSSL does not support the ECDSA curves: please upgrade or rerun with --disable-ecdsa" "$LINENO" 5 fi # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if openssl supports SHA2 and ECDSA with EVP" >&5 $as_echo_n "checking if openssl supports SHA2 and ECDSA with EVP... " >&6; } if grep OPENSSL_VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "OpenSSL" >/dev/null; then if grep OPENSSL_VERSION_NUMBER $ssldir/include/openssl/opensslv.h | grep 0x0 >/dev/null; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } cat >>confdefs.h <<_ACEOF #define USE_ECDSA_EVP_WORKAROUND 1 _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi else # not OpenSSL, thus likely LibreSSL, which supports it { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi fi # we now know we have ECDSA and the required curves. cat >>confdefs.h <<_ACEOF #define USE_ECDSA 1 _ACEOF use_ecdsa="yes" ;; esac # Check whether --enable-draft-dnssec-roadblock-avoidance was given. if test "${enable_draft_dnssec_roadblock_avoidance+set}" = set; then : enableval=$enable_draft_dnssec_roadblock_avoidance; fi # Check whether --enable-draft-edns-cookies was given. if test "${enable_draft_edns_cookies+set}" = set; then : enableval=$enable_draft_edns_cookies; fi # Check whether --enable-all-drafts was given. if test "${enable_all_drafts+set}" = set; then : enableval=$enable_all_drafts; fi 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) cat >>confdefs.h <<_ACEOF #define DNSSEC_ROADBLOCK_AVOIDANCE 1 _ACEOF ;; no|*) ;; esac case "$enable_draft_edns_cookies" in yes) if test "x_$HAVE_SSL" != "x_yes"; then as_fn_error $? "edns cookies need openssl libcrypto which is not available, please rerun without --enable-draft-edns-cookies" "$LINENO" 5 fi cat >>confdefs.h <<_ACEOF #define EDNS_COOKIES 1 _ACEOF ;; no|*) ;; esac cat >>confdefs.h <<_ACEOF #define EDNS_COOKIE_OPCODE 10 _ACEOF cat >>confdefs.h <<_ACEOF #define EDNS_COOKIE_ROLLOVER_TIME (24 * 60 * 60) _ACEOF cat >>confdefs.h <<_ACEOF #define MAXIMUM_UPSTREAM_OPTION_SPACE 3000 _ACEOF cat >>confdefs.h <<_ACEOF #define EDNS_PADDING_OPCODE 12 _ACEOF my_with_libunbound=1 # Check whether --enable-stub-only was given. if test "${enable_stub_only+set}" = set; then : enableval=$enable_stub_only; fi case "$enable_stub_only" in yes) my_with_libunbound=0 ;; no|*) ;; esac # search to set include and library paths right # find libidn (no libidn on windows though) for ac_header in windows.h winsock.h stdio.h winsock2.h ws2tcpip.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo" >&5 $as_echo_n "checking for getaddrinfo... " >&6; } ac_cv_func_getaddrinfo=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" { #endif char* getaddrinfo(); char* (*f) () = getaddrinfo; #ifdef __cplusplus } #endif int main() { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_getaddrinfo="yes" if test "$ac_cv_header_windows_h" = "yes"; then $as_echo "#define USE_WINSOCK 1" >>confdefs.h USE_WINSOCK="1" LIBS="$LIBS -lws2_32" fi else ORIGLIBS="$LIBS" LIBS="$LIBS -lws2_32" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _WIN32_WINNT 0x0501 #ifdef HAVE_WINDOWS_H #include #endif #ifdef HAVE_WINSOCK_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #include #ifdef HAVE_WS2TCPIP_H #include #endif int main () { (void)getaddrinfo(NULL, NULL, NULL, NULL); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_getaddrinfo="yes" $as_echo "#define USE_WINSOCK 1" >>confdefs.h USE_WINSOCK="1" else ac_cv_func_getaddrinfo="no" LIBS="$ORIGLIBS" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getaddrinfo" >&5 $as_echo "$ac_cv_func_getaddrinfo" >&6; } if test $ac_cv_func_getaddrinfo = yes; then $as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h fi if test "$USE_WINSOCK" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: Building on Windows ... YES! " >&5 $as_echo "$as_me: Building on Windows ... YES! " >&6;} cat >>confdefs.h <<_ACEOF #define GETDNS_ON_WINDOWS 1 _ACEOF cat >>confdefs.h <<_ACEOF #define STUB_NATIVE_DNSSEC 1 _ACEOF LIBS="$LIBS -lgdi32 -liphlpapi" my_with_libunbound=0 my_with_libidn=0 else my_with_libidn=1 fi if test $my_with_libidn = 1 then # Check whether --with-libidn was given. if test "${with_libidn+set}" = set; then : withval=$with_libidn; else withval="yes" fi if test x_$withval = x_yes; then for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do if test -f "$dir/include/idna.h"; then CFLAGS="$CFLAGS -I$dir/include" LDFLAGS="$LDFLAGS -L$dir/lib" { $as_echo "$as_me:${as_lineno-$LINENO}: Found libidn in $dir" >&5 $as_echo "$as_me: Found libidn in $dir" >&6;} break fi if test -f "$dir/include/idn/idna.h"; then CFLAGS="$CFLAGS -I$dir/include/idn" LDFLAGS="$LDFLAGS -L$dir/lib" { $as_echo "$as_me:${as_lineno-$LINENO}: Found libidn in $dir" >&5 $as_echo "$as_me: Found libidn in $dir" >&6;} break fi done if test -f "/usr/include/idn/idna.h"; then CFLAGS="$CFLAGS -I/usr/include/idn" #LDFLAGS="$LDFLAGS -L/usr/lib" { $as_echo "$as_me:${as_lineno-$LINENO}: Found libidn in /usr" >&5 $as_echo "$as_me: Found libidn in /usr" >&6;} fi else if test x_$withval != x_no; then CFLAGS="$CFLAGS -I$withval/include" LDFLAGS="$LDFLAGS -L$withval/lib" else my_with_libidn=0 fi fi fi if test $my_with_libunbound = 1 then # find libunbound # Check whether --with-libunbound was given. if test "${with_libunbound+set}" = set; then : withval=$with_libunbound; else withval="yes" fi if test x_$withval = x_yes; then for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do if test -f "$dir/include/unbound.h"; then CFLAGS="$CFLAGS -I$dir/include" LDFLAGS="$LDFLAGS -L$dir/lib" { $as_echo "$as_me:${as_lineno-$LINENO}: Found libunbound in $dir" >&5 $as_echo "$as_me: Found libunbound in $dir" >&6;} break fi done else if test x_$withval != x_no; then CFLAGS="$CFLAGS -I$withval/include" LDFLAGS="$LDFLAGS -L$withval/lib" else cat >>confdefs.h <<_ACEOF #define DISABLE_RESOLUTION_RECURSING 1 _ACEOF my_with_libunbound=0 fi fi fi # Checks for libraries. found_all_libs=1 if test $my_with_libidn = 1 then { $as_echo "$as_me:${as_lineno-$LINENO}: Checking for dependency libidn" >&5 $as_echo "$as_me: Checking for dependency libidn" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for idna_to_ascii_8z in -lidn" >&5 $as_echo_n "checking for idna_to_ascii_8z in -lidn... " >&6; } if ${ac_cv_lib_idn_idna_to_ascii_8z+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lidn $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char idna_to_ascii_8z (); int main () { return idna_to_ascii_8z (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_idn_idna_to_ascii_8z=yes else ac_cv_lib_idn_idna_to_ascii_8z=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_idn_idna_to_ascii_8z" >&5 $as_echo "$ac_cv_lib_idn_idna_to_ascii_8z" >&6; } if test "x$ac_cv_lib_idn_idna_to_ascii_8z" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBIDN 1 _ACEOF LIBS="-lidn $LIBS" else found_all_libs=0 fi fi if test $my_with_libunbound = 1 then { $as_echo "$as_me:${as_lineno-$LINENO}: Checking for dependency libunbound" >&5 $as_echo "$as_me: Checking for dependency libunbound" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ub_fd in -lunbound" >&5 $as_echo_n "checking for ub_fd in -lunbound... " >&6; } if ${ac_cv_lib_unbound_ub_fd+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lunbound $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ub_fd (); int main () { return ub_fd (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_unbound_ub_fd=yes else ac_cv_lib_unbound_ub_fd=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_unbound_ub_fd" >&5 $as_echo "$ac_cv_lib_unbound_ub_fd" >&6; } if test "x$ac_cv_lib_unbound_ub_fd" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBUNBOUND 1 _ACEOF LIBS="-lunbound $LIBS" else found_all_libs=0 fi fi if test $found_all_libs = 0 then as_fn_error $? "One more dependencies is missing" "$LINENO" 5 fi # Extract the first word of "doxygen", so it can be a program name with args. set dummy doxygen; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DOXYGEN+:} false; then : $as_echo_n "(cached) " >&6 else case $DOXYGEN in [\\/]* | ?:[\\/]*) ac_cv_path_DOXYGEN="$DOXYGEN" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DOXYGEN="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DOXYGEN=$ac_cv_path_DOXYGEN if test -n "$DOXYGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DOXYGEN" >&5 $as_echo "$DOXYGEN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$DOXYGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: doxygen not found, continuing without" >&5 $as_echo "$as_me: WARNING: doxygen not found, continuing without" >&2;} fi # Checks for header files. for ac_header in inttypes.h netinet/in.h stdint.h stdlib.h string.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t" case $ac_cv_c_uint16_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define uint16_t $ac_cv_c_uint16_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" case $ac_cv_c_uint32_t in #( no|yes) ;; #( *) $as_echo "#define _UINT32_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint32_t $ac_cv_c_uint32_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" case $ac_cv_c_uint64_t in #( no|yes) ;; #( *) $as_echo "#define _UINT64_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint64_t $ac_cv_c_uint64_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" case $ac_cv_c_uint8_t in #( no|yes) ;; #( *) $as_echo "#define _UINT8_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint8_t $ac_cv_c_uint8_t _ACEOF ;; esac ac_fn_c_check_type "$LINENO" "u_char" "ac_cv_type_u_char" "$ac_includes_default" if test "x$ac_cv_type_u_char" = xyes; then : fi for ac_func in fcntl do : ac_fn_c_check_func "$LINENO" "fcntl" "ac_cv_func_fcntl" if test "x$ac_cv_func_fcntl" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_FCNTL 1 _ACEOF fi done # check ioctlsocket { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ioctlsocket" >&5 $as_echo_n "checking for ioctlsocket... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_WINSOCK2_H #include #endif int main () { (void)ioctlsocket(0, 0, NULL); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_IOCTLSOCKET 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # Check for libraries for other things than libgetdns after this point, # so the getdns libraries can be reset with: # # LIBS="$getdns_LIBS" # LDFLAGS="$getdns_LDFLAGS" # # afterwards. getdns_LIBS="$LIBS" getdns_LDFLAGS="$LDFLAGS" getdns_CFLAGS="$CFLAGS" #-------------------- libraries needed for libcheck LIBS="$initial_LIBS" CHECK_GETDNS="" CHECK_LIBS="" CHECK_CFLAGS="" if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CHECK" >&5 $as_echo_n "checking for CHECK... " >&6; } if test -n "$CHECK_CFLAGS"; then pkg_cv_CHECK_CFLAGS="$CHECK_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"check >= 0.9.6\""; } >&5 ($PKG_CONFIG --exists --print-errors "check >= 0.9.6") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_CHECK_CFLAGS=`$PKG_CONFIG --cflags "check >= 0.9.6" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$CHECK_LIBS"; then pkg_cv_CHECK_LIBS="$CHECK_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"check >= 0.9.6\""; } >&5 ($PKG_CONFIG --exists --print-errors "check >= 0.9.6") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_CHECK_LIBS=`$PKG_CONFIG --libs "check >= 0.9.6" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then CHECK_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "check >= 0.9.6" 2>&1` else CHECK_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "check >= 0.9.6" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$CHECK_PKG_ERRORS" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing floor" >&5 $as_echo_n "checking for library containing floor... " >&6; } if ${ac_cv_search_floor+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char floor (); int main () { return floor (); ; return 0; } _ACEOF for ac_lib in '' m; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_floor=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_floor+:} false; then : break fi done if ${ac_cv_search_floor+:} false; then : else ac_cv_search_floor=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_floor" >&5 $as_echo "$ac_cv_search_floor" >&6; } ac_res=$ac_cv_search_floor if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing timer_create" >&5 $as_echo_n "checking for library containing timer_create... " >&6; } if ${ac_cv_search_timer_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char timer_create (); int main () { return timer_create (); ; return 0; } _ACEOF for ac_lib in '' rt; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_timer_create=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_timer_create+:} false; then : break fi done if ${ac_cv_search_timer_create+:} false; then : else ac_cv_search_timer_create=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_timer_create" >&5 $as_echo "$ac_cv_search_timer_create" >&6; } ac_res=$ac_cv_search_timer_create if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5 $as_echo_n "checking for library containing pthread_create... " >&6; } if ${ac_cv_search_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF for ac_lib in '' pthread; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_pthread_create=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_pthread_create+:} false; then : break fi done if ${ac_cv_search_pthread_create+:} false; then : else ac_cv_search_pthread_create=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_create" >&5 $as_echo "$ac_cv_search_pthread_create" >&6; } ac_res=$ac_cv_search_pthread_create if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing srunner_create" >&5 $as_echo_n "checking for library containing srunner_create... " >&6; } if ${ac_cv_search_srunner_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char srunner_create (); int main () { return srunner_create (); ; return 0; } _ACEOF for ac_lib in '' check check_pic; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_srunner_create=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_srunner_create+:} false; then : break fi done if ${ac_cv_search_srunner_create+:} false; then : else ac_cv_search_srunner_create=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_srunner_create" >&5 $as_echo "$ac_cv_search_srunner_create" >&6; } ac_res=$ac_cv_search_srunner_create if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" CHECK_GETDNS="check_getdns" CHECK_LIBS="$LIBS" else NOLIBCHECK=nolibcheck { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcheck not found or usable; unit tests will not be compiled and run" >&5 $as_echo "$as_me: WARNING: libcheck not found or usable; unit tests will not be compiled and run" >&2;} fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing floor" >&5 $as_echo_n "checking for library containing floor... " >&6; } if ${ac_cv_search_floor+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char floor (); int main () { return floor (); ; return 0; } _ACEOF for ac_lib in '' m; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_floor=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_floor+:} false; then : break fi done if ${ac_cv_search_floor+:} false; then : else ac_cv_search_floor=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_floor" >&5 $as_echo "$ac_cv_search_floor" >&6; } ac_res=$ac_cv_search_floor if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing timer_create" >&5 $as_echo_n "checking for library containing timer_create... " >&6; } if ${ac_cv_search_timer_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char timer_create (); int main () { return timer_create (); ; return 0; } _ACEOF for ac_lib in '' rt; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_timer_create=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_timer_create+:} false; then : break fi done if ${ac_cv_search_timer_create+:} false; then : else ac_cv_search_timer_create=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_timer_create" >&5 $as_echo "$ac_cv_search_timer_create" >&6; } ac_res=$ac_cv_search_timer_create if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5 $as_echo_n "checking for library containing pthread_create... " >&6; } if ${ac_cv_search_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF for ac_lib in '' pthread; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_pthread_create=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_pthread_create+:} false; then : break fi done if ${ac_cv_search_pthread_create+:} false; then : else ac_cv_search_pthread_create=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_create" >&5 $as_echo "$ac_cv_search_pthread_create" >&6; } ac_res=$ac_cv_search_pthread_create if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing srunner_create" >&5 $as_echo_n "checking for library containing srunner_create... " >&6; } if ${ac_cv_search_srunner_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char srunner_create (); int main () { return srunner_create (); ; return 0; } _ACEOF for ac_lib in '' check check_pic; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_srunner_create=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_srunner_create+:} false; then : break fi done if ${ac_cv_search_srunner_create+:} false; then : else ac_cv_search_srunner_create=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_srunner_create" >&5 $as_echo "$ac_cv_search_srunner_create" >&6; } ac_res=$ac_cv_search_srunner_create if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" CHECK_GETDNS="check_getdns" CHECK_LIBS="$LIBS" else NOLIBCHECK=nolibcheck { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcheck not found or usable; unit tests will not be compiled and run" >&5 $as_echo "$as_me: WARNING: libcheck not found or usable; unit tests will not be compiled and run" >&2;} fi else CHECK_CFLAGS=$pkg_cv_CHECK_CFLAGS CHECK_LIBS=$pkg_cv_CHECK_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CHECK_GETDNS="check_getdns" fi LIBS="$getdns_LIBS" # end libraries needed for libcheck # find libldns LIBS="$initial_LIBS" LDNS_LIBS="" LDNS_CFLAGS="" LDNS_LDFLAGS="" NOLIBLDNS="" # Check whether --with-libldns was given. if test "${with_libldns+set}" = set; then : withval=$with_libldns; else withval="yes" fi if test x_$withval = x_yes; then for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do if test -f "$dir/include/ldns/ldns.h"; then LDNS_CFLAGS="-I$dir/include" LDNS_LDFLAGS="-L$dir/lib" CFLAGS="$CFLAGS $LDNS_CFLAGS" LDFLAGS="$LDFLAGS $LDNS_LDFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: Found libldns in $dir" >&5 $as_echo "$as_me: Found libldns in $dir" >&6;} break fi done else if test x_$withval != x_no; then LDNS_CFLAGS="-I$withval/include" LDNS_LDFLAGS="-L$withval/lib" CFLAGS="$CFLAGS $LDNS_CFLAGS" LDFLAGS="$LDFLAGS $LDNS_LDFLAGS" else NOLIBLDNS="nolibldns" { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libldns not found or usable; unit tests will not be compiled and run" >&5 $as_echo "$as_me: WARNING: libldns not found or usable; unit tests will not be compiled and run" >&2;} fi fi if test x$NOLIBLDNS = x then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldns_dname_new_frm_str in -lldns" >&5 $as_echo_n "checking for ldns_dname_new_frm_str in -lldns... " >&6; } if ${ac_cv_lib_ldns_ldns_dname_new_frm_str+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lldns $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ldns_dname_new_frm_str (); int main () { return ldns_dname_new_frm_str (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ldns_ldns_dname_new_frm_str=yes else ac_cv_lib_ldns_ldns_dname_new_frm_str=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ldns_ldns_dname_new_frm_str" >&5 $as_echo "$ac_cv_lib_ldns_ldns_dname_new_frm_str" >&6; } if test "x$ac_cv_lib_ldns_ldns_dname_new_frm_str" = xyes; then : LDNS_LIBS="-lldns" cat >>confdefs.h <<_ACEOF #define HAVE_LIBLDNS 1 _ACEOF else NOLIBLDNS="nolibldns" { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libldns not found or usable; unit tests will not be compiled and run" >&5 $as_echo "$as_me: WARNING: libldns not found or usable; unit tests will not be compiled and run" >&2;} fi fi LIBS="$getdns_LIBS" CFLAGS="$getdns_CFLAGS" LDFLAGS="$getdns_LDFLAGS" #-------------------- libevent extension # Check whether --with-libevent was given. if test "${with_libevent+set}" = set; then : withval=$with_libevent; with_libevent=search else withval=no fi # libevent 1.x requires a u_char typedef which is not always available # on some systems so our check is a little complicated # we further need to ensure that this is included in the getdns headers # that get installed later so some users may not be building in an # environment that has the generated config.h SO we need to generate # this one extra header in that case have_libevent=0 EXTENSION_LIBEVENT_EXT_LIBS="" EXTENSION_LIBEVENT_LIB="" EXTENSION_LIBEVENT_LDFLAGS="" CHECK_EVENT_PROG="" if test x_$withval = x_no; then : else if test x_$withval = x_yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing event_loop" >&5 $as_echo_n "checking for library containing event_loop... " >&6; } if ${ac_cv_search_event_loop+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char event_loop (); int main () { return event_loop (); ; return 0; } _ACEOF for ac_lib in '' event_core event; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_event_loop=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_event_loop+:} false; then : break fi done if ${ac_cv_search_event_loop+:} false; then : else ac_cv_search_event_loop=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_event_loop" >&5 $as_echo "$ac_cv_search_event_loop" >&6; } ac_res=$ac_cv_search_event_loop if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" for ac_func in event_base_new event_base_free do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in event2/event.h do : ac_fn_c_check_header_compile "$LINENO" "event2/event.h" "ac_cv_header_event2_event_h" "$ac_includes_default " if test "x$ac_cv_header_event2_event_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_EVENT2_EVENT_H 1 _ACEOF have_libevent=1 if test "x_$ac_cv_search_event_loop" = "x_none required"; then : else EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop" fi else for ac_header in event.h do : ac_fn_c_check_header_compile "$LINENO" "event.h" "ac_cv_header_event_h" "$ac_includes_default #if HAVE_U_CHAR == 0 typedef unsigned char u_char; #endif " if test "x$ac_cv_header_event_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_EVENT_H 1 _ACEOF have_libevent=1 if test "x_$ac_cv_search_event_loop" = "x_none required"; then : else EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop" fi else as_fn_error $? "event2/event.h and event.h missing, try without libevent" "$LINENO" 5 have_libevent=0 fi done fi done else as_fn_error $? "libevent missing, try without libevent" "$LINENO" 5 fi else have_libevent=1 { $as_echo "$as_me:${as_lineno-$LINENO}: assuming libevent in $withval" >&5 $as_echo "$as_me: assuming libevent in $withval" >&6;} CFLAGS="$CFLAGS -I$withval/include" EXTENSION_LIBEVENT_LDFLAGS="-L$withval/lib" EXTENSION_LIBEVENT_EXT_LIBS="-levent" fi fi if test x_$have_libevent = x_1; then : EXTENSION_LIBEVENT_LIB="libgetdns_ext_event.la" CHECK_EVENT_PROG=check_getdns_event # libunbound version 1.4.22 and older, not linked against libevent, on FreeBSD, # ============================================================================= # cannot be linked against a program that also links libevent, because of # symbol clash. Libunbound has a libevent clone (called mini_event) build when # not linked against libevent that uses the same symbols as libevent. # First detect if the libevent symbols are visible when linking with libunbound LIBS="$getdns_LIBS" LDFLAGS="$getdns_LDFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if event_get_version symbol is leaking from libunbound" >&5 $as_echo_n "checking if event_get_version symbol is leaking from libunbound... " >&6; } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ const char *event_get_version(void); int main () { const char *v = event_get_version(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libunbound is linked against libevent" >&5 $as_echo_n "checking if libunbound is linked against libevent... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ const char *event_get_version(void); int main () { const char *v = event_get_version(); return v[0] == 'm' && v[1] == 'i' && v[2] == 'n' && v[3] == 'i' ? 1 : 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? " *** *** On this system, when using libevent, libunbound must *** also have been compiled with libevent. Please recompile *** libunbound with libevent, or configure --without-libevent. *** See \`config.log' for more details" "$LINENO" 5; } fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi if test "x$have_libcheck" = x1; then : fi LIBS="$getdns_LIBS" LDFLAGS="$getdns_LDFLAGS" # end libevent extension #-------------------- libuv extension # if user says nothing about libuv, or specifies --with-libuv=no or --without-libuv # then we do not want libuv extensions built # if user specifies --with-libuv then search for it # if user specifies --with-libuv=/path then check the lib at that path # Check whether --with-libuv was given. if test "${with_libuv+set}" = set; then : withval=$with_libuv; with_libuv=search else withval=no fi have_libuv=0 EXTENSION_LIBUV_EXT_LIBS="" EXTENSION_LIBUV_LIB="" EXTENSION_LIBUV_LDFLAGS="" CHECK_UV_PROG="" if test x_$withval = x_no; then : else if test x_$withval = x_yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing uv_run" >&5 $as_echo_n "checking for library containing uv_run... " >&6; } if ${ac_cv_search_uv_run+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char uv_run (); int main () { return uv_run (); ; return 0; } _ACEOF for ac_lib in '' uv; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_uv_run=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_uv_run+:} false; then : break fi done if ${ac_cv_search_uv_run+:} false; then : else ac_cv_search_uv_run=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_uv_run" >&5 $as_echo "$ac_cv_search_uv_run" >&6; } ac_res=$ac_cv_search_uv_run if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" for ac_header in uv.h do : ac_fn_c_check_header_compile "$LINENO" "uv.h" "ac_cv_header_uv_h" "$ac_includes_default " if test "x$ac_cv_header_uv_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UV_H 1 _ACEOF have_libuv=1 EXTENSION_LIBUV_EXT_LIBS="$ac_cv_search_uv_run" else as_fn_error $? "uv.h missing, try without libuv" "$LINENO" 5 have_libuv=0 fi done else as_fn_error $? "libuv missing, try without libuv" "$LINENO" 5 fi else have_libuv=1 { $as_echo "$as_me:${as_lineno-$LINENO}: assuming libuv in $withval" >&5 $as_echo "$as_me: assuming libuv in $withval" >&6;} CFLAGS="$CFLAGS -I$withval/include" EXTENSION_LIBUV_LDFLAGS="-L$withval/lib" EXTENSION_LIBUV_EXT_LIBS="-luv" fi fi if test x_$have_libuv = x_1; then : EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la" CHECK_UV_PROG=check_getdns_uv { $as_echo "$as_me:${as_lineno-$LINENO}: checking for new signature of uv_timer_cb" >&5 $as_echo_n "checking for new signature of uv_timer_cb... " >&6; } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include void test_cb(uv_timer_t *handle); int main () { uv_timer_cb cb = test_cb; (*cb)(0); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_NEW_UV_TIMER_CB 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi if test "x$have_libcheck" = x1; then : fi LIBS="$getdns_LIBS" LDFLAGS="$getdns_LDFLAGS" # end libuv extension #-------------------- libev extension # Check whether --with-libev was given. if test "${with_libev+set}" = set; then : withval=$with_libev; with_libev=search else withval=no fi have_libev=0 EXTENSION_LIBEV_EXT_LIBS="" EXTENSION_LIBEV_LIB="" EXTENSION_LIBEV_LDFLAGS="" CHECK_EV_PROG="" if test x_$withval = x_no; then : else if test x_$withval = x_yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ev_run" >&5 $as_echo_n "checking for library containing ev_run... " >&6; } if ${ac_cv_search_ev_run+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ev_run (); int main () { return ev_run (); ; return 0; } _ACEOF for ac_lib in '' ev; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_ev_run=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_ev_run+:} false; then : break fi done if ${ac_cv_search_ev_run+:} false; then : else ac_cv_search_ev_run=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ev_run" >&5 $as_echo "$ac_cv_search_ev_run" >&6; } ac_res=$ac_cv_search_ev_run if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" for ac_header in ev.h do : ac_fn_c_check_header_compile "$LINENO" "ev.h" "ac_cv_header_ev_h" "$ac_includes_default " if test "x$ac_cv_header_ev_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_EV_H 1 _ACEOF have_libev=1 EXTENSION_LIBEV_EXT_LIBS="$ac_cv_search_ev_run" else for ac_header in libev/ev.h do : ac_fn_c_check_header_compile "$LINENO" "libev/ev.h" "ac_cv_header_libev_ev_h" "$ac_includes_default " if test "x$ac_cv_header_libev_ev_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBEV_EV_H 1 _ACEOF have_libev=1 EXTENSION_LIBEV_EXT_LIBS="$ac_cv_search_ev_run" else as_fn_error $? "ev.h missing, try without libev" "$LINENO" 5 have_libev=0 fi done fi done else as_fn_error $? "libev missing, try without libev" "$LINENO" 5 fi else have_libev=1 { $as_echo "$as_me:${as_lineno-$LINENO}: assuming libev in $withval" >&5 $as_echo "$as_me: assuming libev in $withval" >&6;} CFLAGS="$CFLAGS -I$withval/include" EXTENSION_LIBEV_LDFLAGS="-L$withval/lib" EXTENSION_LIBEV_EXT_LIBS="-lev" fi fi if test x_$have_libev = x_1; then : EXTENSION_LIBEV_LIB="libgetdns_ext_ev.la" CHECK_EV_PROG=check_getdns_ev fi if test "x$have_libcheck" = x1; then : fi LIBS="$getdns_LIBS" LDFLAGS="$getdns_LDFLAGS" # end libev extension # --with-trust-anchor= $as_echo "#define SYSCONFDIR sysconfdir" >>confdefs.h # Check whether --with-trust-anchor was given. if test "${with_trust_anchor+set}" = set; then : withval=$with_trust_anchor; TRUST_ANCHOR_FILE="$withval" else if test "x$TRUST_ANCHOR_FILE" = "x"; then if test "x$sysconfdir" = 'x${prefix}/etc' ; then if test "x$prefix" = 'xNONE' ; then TRUST_ANCHOR_FILE="/etc/unbound/getdns-root.key" else TRUST_ANCHOR_FILE="${prefix}/etc/unbound/getdns-root.key" fi else TRUST_ANCHOR_FILE="${sysconfdir}/unbound/getdns-root.key" fi fi fi cat >>confdefs.h <<_ACEOF #define TRUST_ANCHOR_FILE "$TRUST_ANCHOR_FILE" _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: Default trust anchor: $TRUST_ANCHOR_FILE" >&5 $as_echo "$as_me: Default trust anchor: $TRUST_ANCHOR_FILE" >&6;} # Check whether --with-getdns_query was given. if test "${with_getdns_query+set}" = set; then : withval=$with_getdns_query; else withval="no" fi if test x_$withval = x_no; then GETDNS_QUERY="" INSTALL_GETDNS_QUERY="" UNINSTALL_GETDNS_QUERY="" else GETDNS_QUERY="getdns_query" INSTALL_GETDNS_QUERY="install-getdns_query" UNINSTALL_GETDNS_QUERY="uninstall-getdns_query" fi ac_config_files="$ac_config_files Makefile src/Makefile src/version.c src/getdns/getdns.h src/getdns/getdns_extra.h spec/example/Makefile src/test/Makefile doc/Makefile getdns.pc" if test -n "$DOXYGEN" then ac_config_files="$ac_config_files src/Doxyfile" fi for ac_header in stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h bsd/string.h sys/select.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler (${CC-cc}) accepts the \"format\" attribute" >&5 $as_echo_n "checking whether the C compiler (${CC-cc}) accepts the \"format\" attribute... " >&6; } if ${ac_cv_c_format_attribute+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_format_attribute=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include void f (char *format, ...) __attribute__ ((format (printf, 1, 2))); void (*pf) (char *format, ...) __attribute__ ((format (printf, 1, 2))); int main () { f ("%s", "str"); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_format_attribute="yes" else ac_cv_c_format_attribute="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_format_attribute" >&5 $as_echo "$ac_cv_c_format_attribute" >&6; } if test $ac_cv_c_format_attribute = yes; then $as_echo "#define HAVE_ATTR_FORMAT 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler (${CC-cc}) accepts the \"unused\" attribute" >&5 $as_echo_n "checking whether the C compiler (${CC-cc}) accepts the \"unused\" attribute... " >&6; } if ${ac_cv_c_unused_attribute+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_unused_attribute=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include void f (char *u __attribute__((unused))); int main () { f ("x"); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_unused_attribute="yes" else ac_cv_c_unused_attribute="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_unused_attribute" >&5 $as_echo "$ac_cv_c_unused_attribute" >&6; } if test $ac_cv_c_unused_attribute = yes; then $as_echo "#define HAVE_ATTR_UNUSED 1" >>confdefs.h fi ac_fn_c_check_decl "$LINENO" "strlcpy" "ac_cv_have_decl_strlcpy" "$ac_includes_default" if test "x$ac_cv_have_decl_strlcpy" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRLCPY $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "arc4random" "ac_cv_have_decl_arc4random" "$ac_includes_default" if test "x$ac_cv_have_decl_arc4random" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_ARC4RANDOM $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "arc4random_uniform" "ac_cv_have_decl_arc4random_uniform" "$ac_includes_default" if test "x$ac_cv_have_decl_arc4random_uniform" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_ARC4RANDOM_UNIFORM $ac_have_decl _ACEOF ac_fn_c_check_func "$LINENO" "inet_pton" "ac_cv_func_inet_pton" if test "x$ac_cv_func_inet_pton" = xyes; then : $as_echo "#define HAVE_INET_PTON 1" >>confdefs.h else case " $LIBOBJS " in *" inet_pton.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS inet_pton.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "inet_ntop" "ac_cv_func_inet_ntop" if test "x$ac_cv_func_inet_ntop" = xyes; then : $as_echo "#define HAVE_INET_NTOP 1" >>confdefs.h else case " $LIBOBJS " in *" inet_ntop.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS inet_ntop.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" if test "x$ac_cv_func_strlcpy" = xyes; then : $as_echo "#define HAVE_STRLCPY 1" >>confdefs.h else case " $LIBOBJS " in *" strlcpy.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strlcpy.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "arc4random" "ac_cv_func_arc4random" if test "x$ac_cv_func_arc4random" = xyes; then : $as_echo "#define HAVE_ARC4RANDOM 1" >>confdefs.h else case " $LIBOBJS " in *" arc4random.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS arc4random.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "arc4random_uniform" "ac_cv_func_arc4random_uniform" if test "x$ac_cv_func_arc4random_uniform" = xyes; then : $as_echo "#define HAVE_ARC4RANDOM_UNIFORM 1" >>confdefs.h else case " $LIBOBJS " in *" arc4random_uniform.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS arc4random_uniform.$ac_objext" ;; esac fi if test "$ac_cv_func_arc4random" = "no"; then case " $LIBOBJS " in *" explicit_bzero.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS explicit_bzero.$ac_objext" ;; esac case " $LIBOBJS " in *" arc4_lock.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS arc4_lock.$ac_objext" ;; esac for ac_func in getentropy do : ac_fn_c_check_func "$LINENO" "getentropy" "ac_cv_func_getentropy" if test "x$ac_cv_func_getentropy" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETENTROPY 1 _ACEOF else if test "$USE_WINSOCK" = 1; then case " $LIBOBJS " in *" getentropy_win.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getentropy_win.$ac_objext" ;; esac else case `uname` in Darwin) case " $LIBOBJS " in *" getentropy_osx.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getentropy_osx.$ac_objext" ;; esac ;; SunOS) case " $LIBOBJS " in *" getentropy_solaris.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getentropy_solaris.$ac_objext" ;; esac for ac_header in sys/sha2.h do : ac_fn_c_check_header_compile "$LINENO" "sys/sha2.h" "ac_cv_header_sys_sha2_h" "$ac_includes_default " if test "x$ac_cv_header_sys_sha2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SHA2_H 1 _ACEOF else for ac_func in SHA512_Update do : ac_fn_c_check_func "$LINENO" "SHA512_Update" "ac_cv_func_SHA512_Update" if test "x$ac_cv_func_SHA512_Update" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SHA512_UPDATE 1 _ACEOF else case " $LIBOBJS " in *" sha512.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS sha512.$ac_objext" ;; esac fi done fi done if test "$ac_cv_header_sys_sha2_h" = "yes"; then # this lib needed for sha2 on solaris LIBS="$LIBS -lmd" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 $as_echo_n "checking for library containing clock_gettime... " >&6; } if ${ac_cv_search_clock_gettime+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char clock_gettime (); int main () { return clock_gettime (); ; return 0; } _ACEOF for ac_lib in '' rt; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_clock_gettime=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_clock_gettime+:} false; then : break fi done if ${ac_cv_search_clock_gettime+:} false; then : else ac_cv_search_clock_gettime=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 $as_echo "$ac_cv_search_clock_gettime" >&6; } ac_res=$ac_cv_search_clock_gettime if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi ;; Linux|*) case " $LIBOBJS " in *" getentropy_linux.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getentropy_linux.$ac_objext" ;; esac for ac_header in sys/sysctl.h do : ac_fn_c_check_header_compile "$LINENO" "sys/sysctl.h" "ac_cv_header_sys_sysctl_h" "$ac_includes_default " if test "x$ac_cv_header_sys_sysctl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SYSCTL_H 1 _ACEOF fi done for ac_func in getauxval do : ac_fn_c_check_func "$LINENO" "getauxval" "ac_cv_func_getauxval" if test "x$ac_cv_func_getauxval" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETAUXVAL 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 $as_echo_n "checking for library containing clock_gettime... " >&6; } if ${ac_cv_search_clock_gettime+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char clock_gettime (); int main () { return clock_gettime (); ; return 0; } _ACEOF for ac_lib in '' rt; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_clock_gettime=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_clock_gettime+:} false; then : break fi done if ${ac_cv_search_clock_gettime+:} false; then : else ac_cv_search_clock_gettime=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 $as_echo "$ac_cv_search_clock_gettime" >&6; } ac_res=$ac_cv_search_clock_gettime if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi ;; esac fi fi done fi $as_echo "#define USE_MINI_EVENT 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } if ${ac_cv_type_signal+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF case `uname` in FreeBSD) C99COMPATFLAGS="" ;; *) C99COMPATFLAGS="-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600" ;; esac ac_config_headers="$ac_config_headers src/config.h" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by getdns $as_me 0.9.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to . getdns home page: ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ getdns config.status 0.9.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "disable-rpath") CONFIG_COMMANDS="$CONFIG_COMMANDS disable-rpath" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "src/version.c") CONFIG_FILES="$CONFIG_FILES src/version.c" ;; "src/getdns/getdns.h") CONFIG_FILES="$CONFIG_FILES src/getdns/getdns.h" ;; "src/getdns/getdns_extra.h") CONFIG_FILES="$CONFIG_FILES src/getdns/getdns_extra.h" ;; "spec/example/Makefile") CONFIG_FILES="$CONFIG_FILES spec/example/Makefile" ;; "src/test/Makefile") CONFIG_FILES="$CONFIG_FILES src/test/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "getdns.pc") CONFIG_FILES="$CONFIG_FILES getdns.pc" ;; "src/Doxyfile") CONFIG_FILES="$CONFIG_FILES src/Doxyfile" ;; "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="" # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ func_stripname ()\ {\ \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ \ # positional parameters, so assign one to ordinary parameter first.\ \ func_stripname_result=${3}\ \ func_stripname_result=${func_stripname_result#"${1}"}\ \ func_stripname_result=${func_stripname_result%"${2}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; "disable-rpath":C) sed < libtool > libtool-2 \ 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_RPATH_SED__ "/' mv libtool-2 libtool chmod 755 libtool libtool="./libtool" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi getdns-0.9.0/ltmain.sh0000644000175100017510000105203012641212403011543 00000000000000 # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.11 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION="2.4.2 Debian-2.4.2-1.11" TIMESTAMP="" package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type \`$version_type'" ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 getdns-0.9.0/src/0000775000175100017510000000000012641212403010573 500000000000000getdns-0.9.0/src/request-internal.c0000664000175100017510000007352512641212403014175 00000000000000/** * * /brief getdns contect management functions * * This is the meat of the API * Originally taken from the getdns API description pseudo implementation. * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "types-internal.h" #include "util-internal.h" #include "gldns/rrdef.h" #include "gldns/str2wire.h" #include "gldns/gbuffer.h" #include "gldns/pkthdr.h" #include "dict.h" #include "debug.h" /* MAXIMUM_TSIG_SPACE = TSIG name (dname) : 256 * TSIG type (uint16_t) : 2 * TSIG class (uint16_t) : 2 * TSIG TTL (uint32_t) : 4 * RdLen (uint16_t) : 2 * Algorithm name (dname) : 256 * Time Signed (uint48_t) : 6 * Fudge (uint16_t) : 2 * Mac Size (uint16_t) : 2 * Mac (variable) : EVP_MAX_MD_SIZE * Original Id (uint16_t) : 2 * Error (uint16_t) : 2 * Other Len (uint16_t) : 2 * Other Data (nothing) : 0 * ---- + * 538 + EVP_MAX_MD_SIZE */ #define MAXIMUM_TSIG_SPACE (538 + EVP_MAX_MD_SIZE) getdns_dict dnssec_ok_checking_disabled_spc = { { RBTREE_NULL, 0, (int (*)(const void *, const void *)) strcmp }, { 0 } }; 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 } }; 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 } }; getdns_dict *dnssec_ok_checking_disabled_avoid_roadblocks = &dnssec_ok_checking_disabled_avoid_roadblocks_spc; static int is_extension_set(getdns_dict *extensions, const char *extension) { getdns_return_t r; uint32_t value; if (! extensions) return 0; else if (extensions == dnssec_ok_checking_disabled || extensions == dnssec_ok_checking_disabled_roadblock_avoidance || extensions == dnssec_ok_checking_disabled_avoid_roadblocks) return 0; r = getdns_dict_get_int(extensions, extension, &value); return r == GETDNS_RETURN_GOOD && value == GETDNS_EXTENSION_TRUE; } static void network_req_cleanup(getdns_network_req *net_req) { assert(net_req); if (net_req->response && (net_req->response < net_req->wire_data || net_req->response > net_req->wire_data+ net_req->wire_data_sz)) GETDNS_FREE(net_req->owner->my_mf, net_req->response); } static uint8_t * netreq_reset(getdns_network_req *net_req) { uint8_t *buf; /* variables that need to be reset on reinit */ net_req->unbound_id = -1; net_req->state = NET_REQ_NOT_SENT; net_req->dnssec_status = GETDNS_DNSSEC_INDETERMINATE; net_req->tsig_status = GETDNS_DNSSEC_INDETERMINATE; net_req->query_id = 0; net_req->response_len = 0; /* Some fields to record info for return_call_reporting */ net_req->debug_start_time = 0; net_req->debug_end_time = 0; if (!net_req->query) return NULL; buf = net_req->query + GLDNS_HEADER_SIZE; (void) memcpy(buf, net_req->owner->name, net_req->owner->name_len); buf += net_req->owner->name_len; gldns_write_uint16(buf, net_req->request_type); gldns_write_uint16(buf + 2, net_req->owner->request_class); return buf + 4; } static int network_req_init(getdns_network_req *net_req, getdns_dns_req *owner, uint16_t request_type, int dnssec_extension_set, int with_opt, int edns_maximum_udp_payload_size, uint8_t edns_extended_rcode, uint8_t edns_version, int edns_do_bit, uint16_t opt_options_size, size_t noptions, getdns_list *options, size_t wire_data_sz, size_t max_query_sz) { uint8_t *buf; getdns_dict *option; uint32_t option_code; getdns_bindata *option_data; size_t i; int r = 0; /* variables that stay the same on reinit, don't touch */ net_req->request_type = request_type; net_req->owner = owner; net_req->edns_maximum_udp_payload_size = edns_maximum_udp_payload_size; net_req->max_udp_payload_size = edns_maximum_udp_payload_size != -1 ? edns_maximum_udp_payload_size : 1432; net_req->base_query_option_sz = opt_options_size; net_req->wire_data_sz = wire_data_sz; net_req->transport_count = owner->context->dns_transport_count; memcpy(net_req->transports, owner->context->dns_transports, net_req->transport_count * sizeof(getdns_transport_list_t)); net_req->tls_auth_min = owner->context->tls_auth_min; /* state variables from the resolver, don't touch */ net_req->upstream = NULL; net_req->fd = -1; net_req->transport_current = 0; memset(&net_req->event, 0, sizeof(net_req->event)); memset(&net_req->tcp, 0, sizeof(net_req->tcp)); net_req->keepalive_sent = 0; net_req->write_queue_tail = NULL; /* Some fields to record info for return_call_reporting */ net_req->debug_tls_auth_status = 0; net_req->debug_udp = 0; if (max_query_sz == 0) { net_req->query = NULL; net_req->opt = NULL; net_req->response = net_req->wire_data; netreq_reset(net_req); return r; } /* first two bytes will contain query length (for tcp) */ net_req->query = net_req->wire_data + 2; buf = net_req->query; gldns_write_uint16(buf + 2, 0); /* reset all flags */ GLDNS_RD_SET(buf); if (dnssec_extension_set) /* We will do validation ourselves */ GLDNS_CD_SET(buf); GLDNS_OPCODE_SET(buf, GLDNS_PACKET_QUERY); gldns_write_uint16(buf + GLDNS_QDCOUNT_OFF, 1); /* 1 query */ gldns_write_uint16(buf + GLDNS_ANCOUNT_OFF, 0); /* 0 answers */ gldns_write_uint16(buf + GLDNS_NSCOUNT_OFF, 0); /* 0 authorities */ gldns_write_uint16(buf + GLDNS_ARCOUNT_OFF, with_opt ? 1 : 0); buf = netreq_reset(net_req); if (with_opt) { net_req->opt = buf; buf[0] = 0; /* dname for . */ gldns_write_uint16(buf + 1, GLDNS_RR_TYPE_OPT); gldns_write_uint16(net_req->opt + 3, net_req->max_udp_payload_size); buf[5] = edns_extended_rcode; buf[6] = edns_version; buf[7] = edns_do_bit ? 0x80 : 0; buf[8] = 0; gldns_write_uint16(buf + 9, opt_options_size); buf += 11; for (i = 0; i < noptions; i++) { if (getdns_list_get_dict(options, i, &option)) continue; if (getdns_dict_get_int( option, "option_code", &option_code)) continue; if (getdns_dict_get_bindata( option, "option_data", &option_data)) continue; gldns_write_uint16(buf, (uint16_t) option_code); gldns_write_uint16(buf + 2, (uint16_t) option_data->size); (void) memcpy(buf + 4, option_data->data, option_data->size); buf += option_data->size + 4; } } else net_req->opt = NULL; net_req->response = buf; gldns_write_uint16(net_req->wire_data, net_req->response - net_req->query); return r; } /* req->opt + 9 is the length; req->opt + 11 is the start of the options. clear_upstream_options() goes back to the per-query options. */ void _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); req->response = req->opt + 11 + req->base_query_option_sz; pktlen = req->response - req->query; gldns_write_uint16(req->query - 2, pktlen); } } void _getdns_netreq_reinit(getdns_network_req *netreq) { uint8_t *base_opt_backup; size_t base_opt_rr_sz; if (!netreq->query) { (void) netreq_reset(netreq); return; } else if (!netreq->opt) { /* Remove TSIG (if any) */ gldns_write_uint16(netreq->query + GLDNS_ARCOUNT_OFF, 0); netreq->response = netreq_reset(netreq); gldns_write_uint16(netreq->wire_data, netreq->response - netreq->query); return; } _getdns_network_req_clear_upstream_options(netreq); base_opt_rr_sz = netreq->base_query_option_sz + 11; base_opt_backup = netreq->wire_data + netreq->wire_data_sz - base_opt_rr_sz; (void) memcpy(base_opt_backup, netreq->opt, base_opt_rr_sz); netreq->opt = netreq_reset(netreq); (void) memcpy(netreq->opt, base_opt_backup, base_opt_rr_sz); netreq->response = netreq->opt + base_opt_rr_sz; /* Remove TSIG (if any), but leave the opt RR */ gldns_write_uint16(netreq->query + GLDNS_ARCOUNT_OFF, 1); gldns_write_uint16(netreq->wire_data, netreq->response - netreq->query); } /* add_upstream_option appends an option that is derived at send time. (you can send data as NULL and it will fill with all zeros) */ getdns_return_t _getdns_network_req_add_upstream_option(getdns_network_req * req, uint16_t code, uint16_t sz, const void* data) { uint16_t oldlen; uint32_t newlen; uint32_t pktlen; size_t cur_upstream_option_sz; /* if no options are set, we can't add upstream options */ if (!req->opt) return GETDNS_RETURN_GENERIC_ERROR; /* if TCP, no overflow allowed for length field https://tools.ietf.org/html/rfc1035#section-4.2.2 */ pktlen = req->response - req->query; pktlen += 4 + sz; if (pktlen > UINT16_MAX) return GETDNS_RETURN_GENERIC_ERROR; /* no overflow allowed for OPT size either (maybe this is overkill given the above check?) */ oldlen = gldns_read_uint16(req->opt + 9); newlen = oldlen + 4 + sz; if (newlen > UINT16_MAX) return GETDNS_RETURN_GENERIC_ERROR; /* avoid overflowing MAXIMUM_UPSTREAM_OPTION_SPACE */ cur_upstream_option_sz = (size_t)oldlen - req->base_query_option_sz; if (cur_upstream_option_sz + 4 + sz > MAXIMUM_UPSTREAM_OPTION_SPACE) return GETDNS_RETURN_GENERIC_ERROR; /* actually add the option: */ gldns_write_uint16(req->opt + 11 + oldlen, code); gldns_write_uint16(req->opt + 11 + oldlen + 2, sz); if (data != NULL) memcpy(req->opt + 11 + oldlen + 4, data, sz); else memset(req->opt + 11 + oldlen + 4, 0, sz); gldns_write_uint16(req->opt + 9, newlen); /* the response should start right after the options end: */ req->response = req->opt + 11 + newlen; /* for TCP, adjust the size of the wire format itself: */ gldns_write_uint16(req->query - 2, pktlen); return GETDNS_RETURN_GOOD; } size_t _getdns_network_req_add_tsig(getdns_network_req *req) { getdns_upstream *upstream = req->upstream; gldns_buffer gbuf; uint16_t arcount; const getdns_tsig_info *tsig_info; uint8_t md_buf[EVP_MAX_MD_SIZE]; unsigned int md_len = EVP_MAX_MD_SIZE; const EVP_MD *digester; /* Should only be called when in stub mode */ assert(req->query); if (upstream->tsig_alg == GETDNS_NO_TSIG || !upstream->tsig_dname_len) return req->response - req->query; arcount = gldns_read_uint16(req->query + 10); #if defined(STUB_DEBUG) && STUB_DEBUG /* TSIG should not have been written yet. */ if (req->opt) { assert(arcount == 1); assert(req->opt + 11 + gldns_read_uint16(req->opt + 9) == req->response); } else assert(arcount == 0); #endif tsig_info = _getdns_get_tsig_info(upstream->tsig_alg); gldns_buffer_init_frm_data(&gbuf, req->response, MAXIMUM_TSIG_SPACE); gldns_buffer_write(&gbuf, upstream->tsig_dname, upstream->tsig_dname_len); /* Name */ gldns_buffer_write_u16(&gbuf, GETDNS_RRCLASS_ANY); /* Class */ gldns_buffer_write_u32(&gbuf, 0); /* TTL */ gldns_buffer_write(&gbuf, tsig_info->dname, tsig_info->dname_len); /* Algorithm Name */ gldns_buffer_write_u48(&gbuf, time(NULL)); /* Time Signed */ gldns_buffer_write_u16(&gbuf, 300); /* Fudge */ gldns_buffer_write_u16(&gbuf, 0); /* Error */ gldns_buffer_write_u16(&gbuf, 0); /* Other len */ switch (upstream->tsig_alg) { #ifdef HAVE_EVP_MD5 case GETDNS_HMAC_MD5 : digester = EVP_md5() ; break; #endif #ifdef HAVE_EVP_SHA1 case GETDNS_HMAC_SHA1 : digester = EVP_sha1() ; break; #endif #ifdef HAVE_EVP_SHA224 case GETDNS_HMAC_SHA224: digester = EVP_sha224(); break; #endif #ifdef HAVE_EVP_SHA256 case GETDNS_HMAC_SHA256: digester = EVP_sha256(); break; #endif #ifdef HAVE_EVP_SHA384 case GETDNS_HMAC_SHA384: digester = EVP_sha384(); break; #endif #ifdef HAVE_EVP_SHA512 case GETDNS_HMAC_SHA512: digester = EVP_sha512(); break; #endif default : return req->response - req->query; } (void) HMAC(digester, upstream->tsig_key, upstream->tsig_size, (void *)req->query, gldns_buffer_current(&gbuf) - req->query, md_buf, &md_len); gldns_buffer_rewind(&gbuf); gldns_buffer_write(&gbuf, upstream->tsig_dname, upstream->tsig_dname_len); /* Name */ gldns_buffer_write_u16(&gbuf, GETDNS_RRTYPE_TSIG); /* Type*/ 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 */ gldns_buffer_write(&gbuf, tsig_info->dname, tsig_info->dname_len); /* Algorithm Name */ gldns_buffer_write_u48(&gbuf, time(NULL)); /* Time Signed */ gldns_buffer_write_u16(&gbuf, 300); /* Fudge */ gldns_buffer_write_u16(&gbuf, md_len); /* MAC Size */ gldns_buffer_write(&gbuf, md_buf, md_len); /* MAC*/ gldns_buffer_write(&gbuf, req->query, 2); /* Original ID */ gldns_buffer_write_u16(&gbuf, 0); /* Error */ gldns_buffer_write_u16(&gbuf, 0); /* Other len */ if (gldns_buffer_position(&gbuf) > gldns_buffer_limit(&gbuf)) return req->response - req->query; DEBUG_STUB("Sending with TSIG, mac length: %d\n", (int)md_len); req->tsig_status = GETDNS_DNSSEC_INSECURE; gldns_write_uint16(req->query + 10, arcount + 1); req->response = gldns_buffer_current(&gbuf); return req->response - req->query; } void _getdns_network_validate_tsig(getdns_network_req *req) { _getdns_rr_iter rr_spc, *rr; _getdns_rdf_iter rdf_spc, *rdf; const uint8_t *request_mac; uint16_t request_mac_len; uint8_t tsig_vars[MAXIMUM_TSIG_SPACE]; gldns_buffer gbuf; const uint8_t *dname; size_t dname_len; const uint8_t *response_mac; uint16_t response_mac_len; uint8_t other_len; uint8_t result_mac[EVP_MAX_MD_SIZE]; unsigned int result_mac_len = EVP_MAX_MD_SIZE; uint16_t original_id; const EVP_MD *digester; HMAC_CTX ctx; DEBUG_STUB("Validate TSIG\n"); for ( rr = _getdns_rr_iter_init(&rr_spc, req->query, (req->response - req->query)) ; rr ; rr = _getdns_rr_iter_next(rr)) { if (_getdns_rr_iter_section(rr) == GLDNS_SECTION_ADDITIONAL && gldns_read_uint16(rr->rr_type) == GETDNS_RRTYPE_TSIG) break; } if (!rr || !(rdf = _getdns_rdf_iter_init_at(&rdf_spc, rr, 3))) return; /* No good TSIG sent, so nothing expected on reply */ request_mac_len = gldns_read_uint16(rdf->pos); if (request_mac_len != rdf->nxt - rdf->pos - 2) return; DEBUG_STUB("Request MAC found length: %d\n", (int)(request_mac_len)); request_mac = rdf->pos + 2; /* Now we expect a TSIG on the response! */ req->tsig_status = GETDNS_DNSSEC_BOGUS; for ( rr = _getdns_rr_iter_init( &rr_spc, req->response, req->response_len) ; rr ; rr = _getdns_rr_iter_next(rr)) { if (_getdns_rr_iter_section(rr) == GLDNS_SECTION_ADDITIONAL && gldns_read_uint16(rr->rr_type) == GETDNS_RRTYPE_TSIG) break; } if (!rr || !(rdf = _getdns_rdf_iter_init(&rdf_spc, rr))) return; gldns_buffer_init_frm_data(&gbuf, tsig_vars, MAXIMUM_TSIG_SPACE); dname_len = gldns_buffer_remaining(&gbuf); if (!(dname = _getdns_owner_if_or_as_decompressed( rr, gldns_buffer_current(&gbuf), &dname_len))) return; if (dname == gldns_buffer_current(&gbuf)) gldns_buffer_skip(&gbuf, dname_len); else gldns_buffer_write(&gbuf, dname, dname_len); gldns_buffer_write(&gbuf, rr->rr_type + 2, 2); /* Class */ gldns_buffer_write(&gbuf, rr->rr_type + 4, 4); /* TTL */ dname_len = gldns_buffer_remaining(&gbuf); if (!(dname = _getdns_rdf_if_or_as_decompressed( rdf, gldns_buffer_current(&gbuf), &dname_len))) return; if (dname == gldns_buffer_current(&gbuf)) gldns_buffer_skip(&gbuf, dname_len); else gldns_buffer_write(&gbuf, dname, dname_len); if (!(rdf = _getdns_rdf_iter_next(rdf)) || rdf->nxt - rdf->pos != 6) return; gldns_buffer_write(&gbuf, rdf->pos, 6); /* Time Signed */ if (!(rdf = _getdns_rdf_iter_next(rdf)) || rdf->nxt - rdf->pos != 2) return; gldns_buffer_write(&gbuf, rdf->pos, 2); /* Fudge */ if (!(rdf = _getdns_rdf_iter_next(rdf))) /* mac */ return; response_mac_len = gldns_read_uint16(rdf->pos); if (response_mac_len != rdf->nxt - rdf->pos - 2) return; DEBUG_STUB("Response MAC found length: %d\n", (int)(response_mac_len)); response_mac = rdf->pos + 2; if (!(rdf = _getdns_rdf_iter_next(rdf)) || rdf->nxt -rdf->pos != 2) /* Original ID */ return; original_id = gldns_read_uint16(rdf->pos); if (!(rdf = _getdns_rdf_iter_next(rdf)) || rdf->nxt - rdf->pos != 2) return; gldns_buffer_write(&gbuf, rdf->pos, 2); /* Error */ if (!(rdf = _getdns_rdf_iter_next(rdf))) /* Other */ return; gldns_buffer_write_u16(&gbuf, 0); /* Other len */ other_len = gldns_read_uint16(rdf->pos); if (other_len != rdf->nxt - rdf->pos - 2) return; if (other_len) gldns_buffer_write(&gbuf, rdf->pos, other_len); /* TSIG found */ DEBUG_STUB("TSIG found, original ID: %d\n", (int)original_id); gldns_write_uint16(req->response + 10, gldns_read_uint16(req->response + 10) - 1); gldns_write_uint16(req->response, original_id); switch (req->upstream->tsig_alg) { #ifdef HAVE_EVP_MD5 case GETDNS_HMAC_MD5 : digester = EVP_md5() ; break; #endif #ifdef HAVE_EVP_SHA1 case GETDNS_HMAC_SHA1 : digester = EVP_sha1() ; break; #endif #ifdef HAVE_EVP_SHA224 case GETDNS_HMAC_SHA224: digester = EVP_sha224(); break; #endif #ifdef HAVE_EVP_SHA256 case GETDNS_HMAC_SHA256: digester = EVP_sha256(); break; #endif #ifdef HAVE_EVP_SHA384 case GETDNS_HMAC_SHA384: digester = EVP_sha384(); break; #endif #ifdef HAVE_EVP_SHA512 case GETDNS_HMAC_SHA512: digester = EVP_sha512(); break; #endif default : return; } HMAC_CTX_init(&ctx); (void) HMAC_Init_ex(&ctx, req->upstream->tsig_key, req->upstream->tsig_size, digester, NULL); (void) HMAC_Update(&ctx, request_mac - 2, request_mac_len + 2); (void) HMAC_Update(&ctx, req->response, rr->pos - req->response); (void) HMAC_Update(&ctx, tsig_vars, gldns_buffer_position(&gbuf)); HMAC_Final(&ctx, result_mac, &result_mac_len); DEBUG_STUB("Result MAC length: %d\n", (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; HMAC_CTX_cleanup(&ctx); gldns_write_uint16(req->response, gldns_read_uint16(req->query)); gldns_write_uint16(req->response + 10, gldns_read_uint16(req->response + 10) + 1); } void _getdns_dns_req_free(getdns_dns_req * req) { getdns_network_req **net_req; if (!req) { return; } _getdns_upstreams_dereference(req->upstreams); /* cleanup network requests */ for (net_req = req->netreqs; *net_req; net_req++) network_req_cleanup(*net_req); /* clear timeout event */ if (req->timeout.timeout_cb) { req->loop->vmt->clear(req->loop, &req->timeout); req->timeout.timeout_cb = NULL; } GETDNS_FREE(req->my_mf, req); } static const uint8_t no_suffixes[] = { 1, 0 }; /* create a new dns req to be submitted */ getdns_dns_req * _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop, const char *name, uint16_t request_type, getdns_dict *extensions) { int dnssec_return_status = context->return_dnssec_status == GETDNS_EXTENSION_TRUE || is_extension_set(extensions, "dnssec_return_status"); int dnssec_return_only_secure = is_extension_set(extensions, "dnssec_return_only_secure"); int dnssec_return_validation_chain = is_extension_set(extensions, "dnssec_return_validation_chain"); int edns_cookies = is_extension_set(extensions, "edns_cookies"); #ifdef DNSSEC_ROADBLOCK_AVOIDANCE int avoid_dnssec_roadblocks = (extensions == dnssec_ok_checking_disabled_avoid_roadblocks); int dnssec_roadblock_avoidance = is_extension_set(extensions, "dnssec_roadblock_avoidance") || (extensions == dnssec_ok_checking_disabled_roadblock_avoidance) || avoid_dnssec_roadblocks; #endif int dnssec_extension_set = dnssec_return_status || dnssec_return_only_secure || dnssec_return_validation_chain || (extensions == dnssec_ok_checking_disabled) || (extensions == dnssec_ok_checking_disabled_roadblock_avoidance) || (extensions == dnssec_ok_checking_disabled_avoid_roadblocks) #ifdef DNSSEC_ROADBLOCK_AVOIDANCE || dnssec_roadblock_avoidance #endif ; uint32_t edns_do_bit; int edns_maximum_udp_payload_size; uint32_t get_edns_maximum_udp_payload_size; uint32_t edns_extended_rcode; uint32_t edns_version; getdns_dict *add_opt_parameters; int have_add_opt_parameters; getdns_list *options; size_t noptions = 0; size_t i; getdns_dict *option; uint32_t option_code; getdns_bindata *option_data; size_t opt_options_size = 0; int with_opt; getdns_dns_req *result = NULL; uint32_t klass = GLDNS_RR_CLASS_IN; int a_aaaa_query = is_extension_set(extensions, "return_both_v4_and_v6") && ( request_type == GETDNS_RRTYPE_A || request_type == GETDNS_RRTYPE_AAAA ); /* Reserve for the buffer at least one more byte * (to test for udp overflow) (hence the + 1), * And align on the 8 byte boundry (hence the (x + 7) / 8 * 8) */ size_t max_query_sz, max_response_sz, netreq_sz, dnsreq_base_sz; uint8_t *region, *suffixes; if (extensions == dnssec_ok_checking_disabled || extensions == dnssec_ok_checking_disabled_roadblock_avoidance || extensions == dnssec_ok_checking_disabled_avoid_roadblocks) extensions = NULL; have_add_opt_parameters = getdns_dict_get_dict(extensions, "add_opt_parameters", &add_opt_parameters) == GETDNS_RETURN_GOOD; if (dnssec_extension_set) { edns_maximum_udp_payload_size = -1; edns_extended_rcode = 0; edns_version = 0; edns_do_bit = 1; } else { edns_maximum_udp_payload_size = context->edns_maximum_udp_payload_size; edns_extended_rcode = context->edns_extended_rcode; edns_version = context->edns_version; edns_do_bit = context->edns_do_bit; if (have_add_opt_parameters) { if (!getdns_dict_get_int(add_opt_parameters, "maximum_udp_payload_size", &get_edns_maximum_udp_payload_size)) edns_maximum_udp_payload_size = get_edns_maximum_udp_payload_size; (void) getdns_dict_get_int(add_opt_parameters, "extended_rcode", &edns_extended_rcode); (void) getdns_dict_get_int(add_opt_parameters, "version", &edns_version); (void) getdns_dict_get_int(add_opt_parameters, "do_bit", &edns_do_bit); } } if (have_add_opt_parameters && getdns_dict_get_list( add_opt_parameters, "options", &options) == GETDNS_RETURN_GOOD) (void) getdns_list_get_length(options, &noptions); with_opt = edns_do_bit != 0 || edns_maximum_udp_payload_size != 512 || edns_extended_rcode != 0 || edns_version != 0 || noptions || edns_cookies || context->edns_client_subnet_private || context->tls_query_padding_blocksize > 1; edns_maximum_udp_payload_size = with_opt && ( edns_maximum_udp_payload_size == -1 || edns_maximum_udp_payload_size > 512 ) ? edns_maximum_udp_payload_size : 512; /* (x + 7) / 8 * 8 to align on 8 byte boundries */ #ifdef DNSSEC_ROADBLOCK_AVOIDANCE if (context->resolution_type == GETDNS_RESOLUTION_RECURSING && (!dnssec_roadblock_avoidance || avoid_dnssec_roadblocks)) #else if (context->resolution_type == GETDNS_RESOLUTION_RECURSING) #endif max_query_sz = 0; else { for (i = 0; i < noptions; i++) { if (getdns_list_get_dict(options, i, &option)) continue; if (getdns_dict_get_int( option, "option_code", &option_code)) continue; if (getdns_dict_get_bindata( option, "option_data", &option_data)) continue; opt_options_size += option_data->size + 2 /* option-code */ + 2 /* option-length */ ; } max_query_sz = ( GLDNS_HEADER_SIZE + 256 + 4 /* dname maximum 255 bytes (256 with mdns)*/ + 12 + opt_options_size /* space needed for OPT (if needed) */ + MAXIMUM_UPSTREAM_OPTION_SPACE + MAXIMUM_TSIG_SPACE + 7) / 8 * 8; } max_response_sz = (( edns_maximum_udp_payload_size != -1 ? edns_maximum_udp_payload_size : 1432 ) + 1 /* +1 for udp overflow detection */ + 7 ) / 8 * 8; netreq_sz = ( sizeof(getdns_network_req) + max_query_sz + max_response_sz + 7 ) / 8 * 8; dnsreq_base_sz = (( sizeof(getdns_dns_req) + (a_aaaa_query ? 3 : 2) * sizeof(getdns_network_req*) + context->suffixes_len ) + 7) / 8 * 8; if (! (region = GETDNS_XMALLOC(context->mf, uint8_t, dnsreq_base_sz + (a_aaaa_query ? 2 : 1) * netreq_sz))) return NULL; result = (getdns_dns_req *)region; result->netreqs[0] = (getdns_network_req *)(region + dnsreq_base_sz); if (a_aaaa_query) { result->netreqs[1] = (getdns_network_req *) (region + dnsreq_base_sz + netreq_sz); result->netreqs[2] = NULL; } else result->netreqs[1] = NULL; result->my_mf = context->mf; suffixes = region + dnsreq_base_sz - context->suffixes_len; assert(context->suffixes); assert(context->suffixes_len); memcpy(suffixes, context->suffixes, context->suffixes_len); result->append_name = context->append_name; if (!strlen(name) || name[strlen(name)-1] == '.' || result->append_name == GETDNS_APPEND_NAME_NEVER) { /* Absolute query string, no appending */ result->suffix_len = no_suffixes[0]; result->suffix = no_suffixes + 1; result->suffix_appended = 1; } else { result->suffix_len = suffixes[0]; result->suffix = suffixes + 1; result->suffix_appended = 0; } result->name_len = sizeof(result->name); if (gldns_str2wire_dname_buf(name, result->name, &result->name_len)) { GETDNS_FREE(result->my_mf, result); return NULL; } if (result->append_name == GETDNS_APPEND_NAME_ALWAYS) { for ( ; result->suffix_len > 1 && *result->suffix ; result->suffix += result->suffix_len , result->suffix_len = *result->suffix++) { if (result->suffix_len + result->name_len - 1 < sizeof(result->name)) { memcpy(result->name + result->name_len - 1, result->suffix, result->suffix_len); result->name_len += result->suffix_len - 1; result->suffix_appended = 1; break; } } } else if (result->append_name == GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE && result->name[result->name[0]+1] != 0) { /* We have multiple labels, no appending */ result->suffix_len = no_suffixes[0]; result->suffix = no_suffixes + 1; result->suffix_appended = 1; } result->context = context; result->loop = loop; result->canceled = 0; result->trans_id = (((uint64_t)arc4random()) << 32) | ((uint64_t)arc4random()); result->dnssec_return_status = dnssec_return_status; result->dnssec_return_only_secure = dnssec_return_only_secure; result->dnssec_return_validation_chain = dnssec_return_validation_chain; result->edns_cookies = edns_cookies; #ifdef DNSSEC_ROADBLOCK_AVOIDANCE result->dnssec_roadblock_avoidance = dnssec_roadblock_avoidance; result->avoid_dnssec_roadblocks = avoid_dnssec_roadblocks; #endif result->edns_client_subnet_private = context->edns_client_subnet_private; result->tls_query_padding_blocksize = context->tls_query_padding_blocksize; result->return_call_reporting = is_extension_set(extensions, "return_call_reporting"); result->add_warning_for_bad_dns = is_extension_set(extensions, "add_warning_for_bad_dns"); /* will be set by caller */ result->user_pointer = NULL; result->user_callback = NULL; memset(&result->timeout, 0, sizeof(result->timeout)); /* check the specify_class extension */ (void) getdns_dict_get_int(extensions, "specify_class", &klass); result->request_class = klass; result->upstreams = context->upstreams; if (result->upstreams) result->upstreams->referenced++; network_req_init(result->netreqs[0], result, request_type, dnssec_extension_set, with_opt, edns_maximum_udp_payload_size, edns_extended_rcode, edns_version, edns_do_bit, opt_options_size, noptions, options, netreq_sz - sizeof(getdns_network_req), max_query_sz); if (a_aaaa_query) network_req_init(result->netreqs[1], result, ( request_type == GETDNS_RRTYPE_A ? GETDNS_RRTYPE_AAAA : GETDNS_RRTYPE_A ), dnssec_extension_set, with_opt, edns_maximum_udp_payload_size, edns_extended_rcode, edns_version, edns_do_bit, opt_options_size, noptions, options, netreq_sz - sizeof(getdns_network_req), max_query_sz); return result; } getdns-0.9.0/src/dnssec.c0000664000175100017510000032204412641212403012143 00000000000000/** * * /brief functions for DNSSEC * * In this file, the "dnssec_return_validation_chain" extension is implemented * (with the _getdns_get_validation_chain() function) * Also the function getdns_validate_dnssec is implemented. * DNSSEC validation as a stub combines those two functionalities, by first * fetching all the records that are necessary to be able to validate a * request (i.e. the "dnssec_return_validation_chain" extension) and then * performing DNSSEC validation for a request with those support records * (and a trust anchor of course). */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * From the API: * * The "dnssec_return_validation_chain" extension as explained in section 3.1: * * Applications that want to do their own validation will want to have the * DNSSEC-related records for a particular response. Use the * dnssec_return_validation_chain extension. The extension's value * (an int) is set to GETDNS_EXTENSION_TRUE to cause a set of additional * DNSSEC-related records needed for validation to be returned in the * response object. This set comes as validation_chain (a list) at the top * level of the response object. This list includes all resource record * dicts for all the resource records (DS, DNSKEY and their RRSIGs) that * are needed to perform the validation from the root up. * * * The getdns_validate_dnssec() function as explained in section 7: * * If an application wants the API do perform DNSSEC validation without * using the extensions, it can use the getdns_validate_dnssec() helper * function. * * getdns_return_t * getdns_validate_dnssec( * getdns_list *record_to_validate, * getdns_list *bundle_of_support_records, * getdns_list *trust_anchor_records * ); * * The record_to_validate is the resource record being validated together * with the associated signatures. The API will use the resource records * in bundle_of_support_records to construct the validation chain and the * DNSKEY or DS records in trust_anchor_records as trust anchors. The * function returns one of GETDNS_DNSSEC_SECURE, GETDNS_DNSSEC_BOGUS, * GETDNS_DNSSEC_INDETERMINATE, or GETDNS_DNSSEC_INSECURE. */ /* Outline of operations in this file * ================================== * * Data structure to represent the delegation/referal hierarchy * ------------------------------------------------------------ * Both the "dnssec_return_validation_chain" extension, and the * getdns_validate_dnssec() function use the same structs to represent the * involved pieces of the DNS in a hierarchical manner. * * However, the tree is not represented from the root, but from the RRsets that * need to be validated. The RRset to validate is a member of the chain_head * struct for this. The chain_head struct has a "next" member to form a linked * list of RRsets to validate. * * The chain_head struct also has a "parent" member to a linked list of * chain_node structs (linked with the "parent" member of those chain_nodes). * For each label in the name of the rrset in a chain_head, is a chain_node, * all the way to the root. The last chain_node is thus always the root, for * every chain_head. * * The construction functions for this datastructure make sure there is always * a single chain_node representing the same name. They also make sure space * for chain_head + the number of extra chain_nodes needed is allocated in a * single region, so that on destruction one only has to free the chain_heads. * * A chain_node contains two RRset members, "dnskey" and "ds" which represent * the potential client side DNSKEYs and the parent side DS records of a * potential zonecut at this point. Whether or not there is an actual zone * cut is determined separately. With the "dnssec_return_validation_chain" * extension by scheduling queries, and with the getdns_validation_dnssec() * function by provisioning the support records at the chain nodes. * * In the construction functions a chain_head is created for every RRset in * the answer and authority section of a given packet (except for synthesized * CNAMEs). Furthermore, if the queries for name/class/type is not in the * packet, a chain_head for the non-existent rrset is created too, to that * it will be evaluated for non-existence later in the validation process. * * The chain_head and chain_node structs are defined in section: * "Validation Chain Data Structs". The functions to construct the hierarchy * are defined in section "Validation Chain Construction". When the * construction functions are called for the purpose of the * "dnssec_return_validation_chain" extension, queries to provision the * chain_nodes are scheduled. Function theretofore are in section: * "Schedule Queries to Provision Validation Chain" * * * getdns_rrset * ------------ * RRsets used in the structure described above are represented by the * getdns_rrset struct. They consist of name/rr_class and rr_type members * plus a reference to the wireformat packet that should contain the RRset. * * The actual RR's in the rrset and the signatures are only accessed via * iterators; substantiated with the rrtype_iter struct to iterate over RRs * in a getdns_rrset, and the rrsig_iter to iterate over the RRSIGs covering * the RRs in the getdns_rrset. * * The getdns_rrsets are already equiped with name/rr_class and rr_type when * constructing the linked list of chain_nodes up to the root for a chain_head. * They are substantiated with the wireformat packets that are returned with * the queries that were sheduled in the context of the * "dnssec_return_validation_chain" extension. * * Note that the NSEC(3) RRsets proving the non-existance of a getdns_rrset * can be found by processing that getdns_rrset, as it contains the pointer * to the wireformat data that should either contain the RRset or the proof * of non-existance. * * The getdns_validate_dnssec() function, after it constructed the chain_heads * hierarchy, creates an artifical packet for the support records and equips * all the ds and dnskey getdns_rrsets on the chain_nodes with this packet. * * The getdns_rrset + support function and data types are defined in section: * "getdns_rrset + Support Iterators" * * * Validation * ---------- * Validation of a constructed chain is done by the * chain_set_netreq_dnssec_status() function when validating in stub mode. * And with the chain_validate_dnssec() function when using the * getdns_validate_dnssec() function. They are the same, except that * chain_set_netreq_dnssec_status() evaluates DNSSEC status per network * request and chain_validate_dnssec() does it for the whole chain. * * They both evaluate the DNSSEC status for each head in turn. The worst * DNSSEC status determines the status of all heads evaluated. Where * INSECURE is worse than SECURE, and BOGUS is worse than INSECURE. * * For each head, the closest (most labels still a parent of the head's name) * trust anchor is tried. Without fitting trust anchors, DNSSEC_INDETERMINATE * is returned. * * Security status for a head (with a specific trust anchor) is evaluated by * first finding a authenticated keyset from the parent chain_nodes, and then * evaluating the rrset of the head (existent or not) with that keyset. * * Functions that implement DNSSEC validation are in section: * "DNSSEC Validation". * * Many functions are of key verification boolean return type; e.g. * key_proves_non_existance(), ds_authenticates_keys(), a_key_signed_rrset() * These will return the keytag identifying the key that was used to * authenticate + 0x10000 to allow keytag 0. * * These returned keytag's are used later with function * append_rrs2val_chain_list() to return a "dnssec_validation_chain" that * enumerates a single RRSIG per RRset. This can be found in section: * "dnssec_return_validation_chain Extension". */ #include "config.h" #include "debug.h" #include #include #include #include #include #include "getdns/getdns.h" #include "context.h" #include "util-internal.h" #include "types-internal.h" #include "dnssec.h" #include "rr-dict.h" #include "gldns/str2wire.h" #include "gldns/wire2str.h" #include "gldns/keyraw.h" #include "gldns/parseutil.h" #include "general.h" #include "dict.h" #include "list.h" #include "util/val_secalgo.h" /* Maximum number of canonical name redirections for one name */ #define MAX_CNAMES 100 #define SIGNATURE_VERIFIED 0x10000 #define NSEC3_ITERATION_COUNT_HIGH 0x20000 #define NO_SUPPORTED_ALGORITHMS 0x40000 /******************* Frequently Used Utility Functions ********************* *****************************************************************************/ inline static size_t _dname_len(const uint8_t *name) { const uint8_t *p; for (p = name; *p; p += *p + 1) /* pass */ ; return p - name + 1; } inline static size_t _dname_label_count(const uint8_t *name) { size_t c; for (c = 0; *name; name += *name + 1, c++) /* pass */ ; return c; } inline static int _dname_equal(const uint8_t *left, const uint8_t *right) { return _getdns_dname_equal(left, right); } static int _dname_is_parent( const uint8_t * const parent, const uint8_t *subdomain) { while (*subdomain) { if (_dname_equal(parent, subdomain)) return 1; subdomain += *subdomain + 1; } return *parent == 0; } static uint8_t *_dname_label_copy(uint8_t *dst, const uint8_t *src, size_t dst_len) { uint8_t *r = dst, i; if (!src || *src + 1 > dst_len) return NULL; for (i = (*dst++ = *src++); i ; i--) *dst++ = tolower(*src++); return r; } inline static void _dname_canonicalize(const uint8_t *src, uint8_t *dst) { const uint8_t *next_label; while (*src) { next_label = src + *src + 1; *dst++ = *src++; while (src < next_label) *dst++ = (uint8_t)tolower((unsigned char)*src++); } } inline static void _dname_canonicalize2(uint8_t *dname) { _dname_canonicalize(dname, dname); } /* Fills the array pointed to by labels (of at least 128 uint8_t * pointers) * with pointers to labels in given dname in reversed order. So that * labels[0] will point to the root. * labels[1] will point to the tld etc. * A pointer just past the last assigned array element will be returned. * * So if dname would be "www.getdnsapi.net" * labels[0] will be "." * labels[1] will be "net." * labels[2] will be "getdnsapi.net." * labels[3] will be "www.getdnsapi.net." * The returned value will be &labels[4] */ static const uint8_t **reverse_labels( const uint8_t *dname, const uint8_t **labels) { if (*dname) labels = reverse_labels(dname + *dname + 1, labels); *labels = dname; return labels + 1; } static const uint8_t *dname_shared_parent( const uint8_t *left, const uint8_t *right) { const uint8_t *llabels[128], *rlabels[128], **last_llabel, **last_rlabel, **llabel, **rlabel, *l, *r; uint8_t sz; last_llabel = reverse_labels(left, llabels); last_rlabel = reverse_labels(right, rlabels); /* Always at least one label (the root) */ assert(last_llabel > llabels); assert(last_rlabel > rlabels); assert(*llabels[0] == 0); assert(*rlabels[0] == 0); for ( llabel = &llabels[1], rlabel = &rlabels[1] ; llabel < last_llabel ; llabel++, rlabel++ ) { sz = **llabel; if ( rlabel == last_rlabel || **llabel != **rlabel) return llabel[-1]; for (l = *llabel+1, r = *rlabel+1; sz; l++, r++, sz-- ) if (*l != *r && tolower((unsigned char)*l) != tolower((unsigned char)*r)) return llabel[-1]; } return llabel[-1]; } static int dname_compare(const uint8_t *left, const uint8_t *right) { const uint8_t *llabels[128], *rlabels[128], **last_llabel, **last_rlabel, **llabel, **rlabel, *l, *r; uint8_t lsz, rsz; last_llabel = reverse_labels(left, llabels); last_rlabel = reverse_labels(right, rlabels); for ( llabel = llabels, rlabel = rlabels ; llabel < last_llabel ; llabel++, rlabel++ ) { if (rlabel == last_rlabel) return 1; for ( l = *llabel, lsz = *l++, r = *rlabel, rsz = *r++ ; lsz; l++, r++, lsz--, rsz-- ) { /* No compression pointers here */ assert(lsz <= 63); assert(rsz <= 63); if (!rsz) return 1; if (*l != *r && tolower((unsigned char)*l) != tolower((unsigned char)*r)) { if (tolower((unsigned char)*l) < tolower((unsigned char)*r)) return -1; return 1; } } if (rsz) return -1; } return rlabel == last_rlabel ? 0 : -1; } static int bitmap_has_type(_getdns_rdf_iter *bitmap, uint16_t rr_type) { const uint8_t *dptr, *dend; uint8_t window = rr_type >> 8; uint8_t subtype = rr_type & 0xFF; if (!bitmap || (dptr = bitmap->pos) == (dend = bitmap->nxt)) return 0; /* Type Bitmap = ( Window Block # | Bitmap Length | Bitmap ) + * dptr[0] dptr[1] dptr[2:] */ while (dptr < dend && dptr[0] <= window) { if (dptr[0] == window && subtype / 8 < dptr[1] && dptr + dptr[1] + 2 <= dend) return dptr[2 + subtype / 8] & (0x80 >> (subtype % 8)); dptr += dptr[1] + 2; /* next window */ } return 0; } #if defined(SEC_DEBUG) && SEC_DEBUG inline static void debug_sec_print_rr(const char *msg, _getdns_rr_iter *rr) { char str_spc[8192], *str = str_spc; size_t str_len = sizeof(str_spc); const uint8_t *data = rr->pos; size_t data_len = rr->nxt - rr->pos; if (!rr || !rr->pos) { DEBUG_SEC("%s\n", msg); return; } (void) gldns_wire2str_rr_scan( (UNCONST_UINT8_p *) &data, &data_len, &str, &str_len, (UNCONST_UINT8_p) rr->pkt, rr->pkt_end - rr->pkt); DEBUG_SEC("%s%s", msg, str_spc); } inline static void debug_sec_print_dname(const char *msg, const uint8_t *label) { char str[1024]; if (label && gldns_wire2str_dname_buf( (UNCONST_UINT8_p)label, 256, str, sizeof(str))) DEBUG_SEC("%s%s\n", msg, str); else DEBUG_SEC("%s\n", msg); } #else #define debug_sec_print_rr(...) DEBUG_OFF(__VA_ARGS__) #define debug_sec_print_dname(...) DEBUG_OFF(__VA_ARGS__) #define debug_sec_print_pkt(...) DEBUG_OFF(__VA_ARGS__) #endif /******************* getdns_rrset + Support Iterators ********************** *****************************************************************************/ /* Utility functions to read rr_type and rr_class from a rr iterator */ static inline uint16_t rr_iter_type(_getdns_rr_iter *rr) { return rr->rr_type + 2 <= rr->nxt ? gldns_read_uint16(rr->rr_type) : 0; } static inline uint16_t rr_iter_class(_getdns_rr_iter *rr) { return rr->rr_type + 4 <= rr->nxt ? gldns_read_uint16(rr->rr_type + 2) : 0; } /* Utility function to compare owner name of rr with name */ static int rr_owner_equal(_getdns_rr_iter *rr, const uint8_t *name) { uint8_t owner_spc[256]; const uint8_t *owner; size_t owner_len = sizeof(owner_spc); return (owner = _getdns_owner_if_or_as_decompressed(rr, owner_spc , &owner_len)) && _dname_equal(owner, name); } /* First a few filter functions that filter a RR iterator to point only * to RRs with certain constraints (and moves on otherwise). */ /* Filter that only iterates over the ANSWER and AUTHORITY section */ static _getdns_rr_iter *rr_iter_ansauth(_getdns_rr_iter *rr) { while (rr && rr->pos && !( _getdns_rr_iter_section(rr) == GLDNS_SECTION_ANSWER || _getdns_rr_iter_section(rr) == GLDNS_SECTION_AUTHORITY)) rr = _getdns_rr_iter_next(rr); return rr && rr->pos ? rr : NULL; } /* Filter that only iterates over RRs with a certain name/class/type */ static _getdns_rr_iter *rr_iter_name_class_type(_getdns_rr_iter *rr, const uint8_t *name, uint16_t rr_class, uint16_t rr_type) { while (rr_iter_ansauth(rr) && !( rr_iter_type(rr) == rr_type && rr_iter_class(rr) == rr_class && rr_owner_equal(rr, name))) rr = _getdns_rr_iter_next(rr); return rr && rr->pos ? rr : NULL; } /* Filter that only iterates over RRs that do not have a name/class/type */ static _getdns_rr_iter *rr_iter_not_name_class_type(_getdns_rr_iter *rr, const uint8_t *name, uint16_t rr_class, uint16_t rr_type) { while (rr_iter_ansauth(rr) && ( rr_iter_type(rr) == GETDNS_RRTYPE_RRSIG || ( rr_iter_type(rr) == rr_type && rr_iter_class(rr) == rr_class && rr_owner_equal(rr, name)))) rr = _getdns_rr_iter_next(rr); return rr && rr->pos ? rr : NULL; } /* Filter that only iterates over RRs that are of type RRSIG, that cover * a RRset with a certain name/class/type */ static _getdns_rr_iter *rr_iter_rrsig_covering(_getdns_rr_iter *rr, const uint8_t *name, uint16_t rr_class, uint16_t rr_type) { while (rr_iter_ansauth(rr) && !( rr_iter_type(rr) == GETDNS_RRTYPE_RRSIG && rr_iter_class(rr) == rr_class && rr->rr_type + 12 <= rr->nxt && gldns_read_uint16(rr->rr_type + 10) == rr_type && rr_owner_equal(rr, name))) rr = _getdns_rr_iter_next(rr); return rr && rr->pos ? rr : NULL; } typedef struct getdns_rrset { const uint8_t *name; uint16_t rr_class; uint16_t rr_type; uint8_t *pkt; size_t pkt_len; } getdns_rrset; typedef struct rrtype_iter { _getdns_rr_iter rr_i; getdns_rrset *rrset; } rrtype_iter; typedef struct rrsig_iter { _getdns_rr_iter rr_i; getdns_rrset *rrset; } rrsig_iter; static rrtype_iter *rrtype_iter_next(rrtype_iter *i) { return (rrtype_iter *) rr_iter_name_class_type( _getdns_rr_iter_next(&i->rr_i), i->rrset->name, i->rrset->rr_class, i->rrset->rr_type); } static rrtype_iter *rrtype_iter_init(rrtype_iter *i, getdns_rrset *rrset) { i->rrset = rrset; return (rrtype_iter *) rr_iter_name_class_type( _getdns_rr_iter_init(&i->rr_i, rrset->pkt, rrset->pkt_len ), i->rrset->name, i->rrset->rr_class, i->rrset->rr_type); } inline static int rrset_has_rrs(getdns_rrset *rrset) { rrtype_iter rr_spc; return rrtype_iter_init(&rr_spc, rrset) != NULL; } static rrsig_iter *rrsig_iter_next(rrsig_iter *i) { return (rrsig_iter *) rr_iter_rrsig_covering( _getdns_rr_iter_next(&i->rr_i), i->rrset->name, i->rrset->rr_class, i->rrset->rr_type); } static rrsig_iter *rrsig_iter_init(rrsig_iter *i, getdns_rrset *rrset) { i->rrset = rrset; return (rrsig_iter *) rr_iter_rrsig_covering( _getdns_rr_iter_init(&i->rr_i, rrset->pkt, rrset->pkt_len), i->rrset->name, i->rrset->rr_class, i->rrset->rr_type); } inline static int rrset_has_rrsigs(getdns_rrset *rrset) { rrsig_iter rrsig; return rrsig_iter_init(&rrsig, rrset) != NULL; } #if defined(SEC_DEBUG) && SEC_DEBUG static void debug_sec_print_rrset(const char *msg, getdns_rrset *rrset) { char owner[1024]; char buf_space[2048]; gldns_buffer buf; rrtype_iter *rr, rr_space; rrsig_iter *rrsig, rrsig_space; size_t i; if (!rrset) { DEBUG_SEC(""); return; } gldns_buffer_init_frm_data(&buf, buf_space, sizeof(buf_space)); if (gldns_wire2str_dname_buf( (UNCONST_UINT8_p)rrset->name, 256, owner, sizeof(owner))) gldns_buffer_printf(&buf, "%s ", owner); else gldns_buffer_printf(&buf, " "); switch (rrset->rr_class) { case GETDNS_RRCLASS_IN : gldns_buffer_printf(&buf, "IN ") ; break; case GETDNS_RRCLASS_CH : gldns_buffer_printf(&buf, "CH ") ; break; case GETDNS_RRCLASS_HS : gldns_buffer_printf(&buf, "HS ") ; break; case GETDNS_RRCLASS_NONE: gldns_buffer_printf(&buf, "NONE "); break; case GETDNS_RRCLASS_ANY : gldns_buffer_printf(&buf, "ANY ") ; break; default : gldns_buffer_printf(&buf, "CLASS%d " , rrset->rr_class); break; } gldns_buffer_printf(&buf, "%s", _getdns_rr_type_name(rrset->rr_type)); gldns_buffer_printf(&buf, ", rrs:"); for ( rr = rrtype_iter_init(&rr_space, rrset), i = 1 ; rr ; rr = rrtype_iter_next(rr), i++) gldns_buffer_printf(&buf, " %d", (int)i); gldns_buffer_printf(&buf, ", rrsigs:"); for ( rrsig = rrsig_iter_init(&rrsig_space, rrset), i = 1 ; rrsig ; rrsig = rrsig_iter_next(rrsig), i++) gldns_buffer_printf(&buf, " %d", (int)i); DEBUG_SEC("%s%s\n", msg, buf_space); } #else #define debug_sec_print_rrset(...) DEBUG_OFF(__VA_ARGS__) #endif /* The rrset_iter manifests an iterator of a wireformat packet that will return * all unique rrsets within that packet in turn. */ typedef struct rrset_iter rrset_iter; struct rrset_iter { getdns_rrset rrset; uint8_t name_spc[256]; size_t name_len; _getdns_rr_iter rr_i; }; static rrset_iter *rrset_iter_init(rrset_iter *i, uint8_t *pkt, size_t pkt_len) { _getdns_rr_iter *rr; i->rrset.name = i->name_spc; i->rrset.pkt = pkt; i->rrset.pkt_len = pkt_len; i->name_len = 0; for ( rr = _getdns_rr_iter_init(&i->rr_i, pkt, pkt_len) ;(rr = rr_iter_ansauth(rr)) ; rr = _getdns_rr_iter_next(rr)) { if ((i->rrset.rr_type = rr_iter_type(rr)) == GETDNS_RRTYPE_RRSIG) continue; i->rrset.rr_class = rr_iter_class(rr); if (!(i->rrset.name = _getdns_owner_if_or_as_decompressed( rr, i->name_spc, &i->name_len))) continue; return i; } return NULL; } static rrset_iter *rrset_iter_rewind(rrset_iter *i) { return rrset_iter_init(i, i->rrset.pkt, i->rrset.pkt_len); } static rrset_iter *rrset_iter_next(rrset_iter *i) { _getdns_rr_iter *rr; if (!(rr = i && i->rr_i.pos ? &i->rr_i : NULL)) return NULL; if (!(rr = rr_iter_not_name_class_type(rr, i->rrset.name, i->rrset.rr_class, i->rrset.rr_type))) return NULL; i->rrset.rr_type = rr_iter_type(rr); i->rrset.rr_class = rr_iter_class(rr); if (!(i->rrset.name = _getdns_owner_if_or_as_decompressed( rr, i->name_spc, &i->name_len))) /* This is safe, because rr_iter_not_name_class_type will shift * the iterator forward because at least name does not match. * Goal is to skip broken compression pointer issues but keep * processing the packet. */ return rrset_iter_next(i); return i; } static getdns_rrset *rrset_iter_value(rrset_iter *i) { if (!i) return NULL; if (!i->rr_i.pos) return NULL; return &i->rrset; } static getdns_rrset *rrset_by_type( rrset_iter *i_spc, getdns_network_req *netreq, uint16_t rr_type) { rrset_iter *i; getdns_rrset *rrset; for ( i = rrset_iter_init(i_spc,netreq->response,netreq->response_len) ; i ; i = rrset_iter_next(i)) { rrset = rrset_iter_value(i); if (rrset->rr_type == rr_type) /* Check class too? */ return rrset; } return NULL; } /********************* Validation Chain Data Structs *********************** *****************************************************************************/ typedef struct chain_head chain_head; typedef struct chain_node chain_node; struct chain_head { struct mem_funcs my_mf; chain_head *next; chain_node *parent; size_t node_count; /* Number of nodes attached directly * to this head. For cleaning. */ getdns_rrset rrset; getdns_network_req *netreq; int signer; uint8_t name_spc[]; }; struct chain_node { chain_node *parent; getdns_rrset dnskey; getdns_network_req *dnskey_req; int dnskey_signer; getdns_rrset ds; getdns_network_req *ds_req; int ds_signer; getdns_network_req *soa_req; chain_head *chains; }; /********************* Validation Chain Construction *********************** *****************************************************************************/ /* When construction is done in the context of stub validation, the requests * to equip the chain nodes with their RR sets are done alongside construction. * Hence they need to be enumerated before the construction functions. */ static void val_chain_sched(chain_head *head, const uint8_t *dname); static void val_chain_sched_ds(chain_head *head, const uint8_t *dname); static void val_chain_sched_signer(chain_head *head, rrsig_iter *rrsig); static void val_chain_sched_soa(chain_head *head, const uint8_t *dname); static chain_head *add_rrset2val_chain(struct mem_funcs *mf, chain_head **chain_p, getdns_rrset *rrset, getdns_network_req *netreq) { chain_head *head; const uint8_t *labels[128], **last_label, **label; size_t max_labels; /* max labels in common */ chain_head *max_head; chain_node *max_node; size_t dname_len, head_sz, node_count, n; const uint8_t *dname; uint8_t *region; chain_node *node; last_label = reverse_labels(rrset->name, labels); /* Try to find a chain with the most overlapping labels. * max_labels will be the number of labels in common from the root * (so at least one; the root) * max_head will be the head of the chain with max # labels in common */ max_head = NULL; max_labels = 0; for (head = *chain_p; head; head = head->next) { /* Also, try to prevent adding double rrsets */ if ( rrset->rr_class == head->rrset.rr_class && rrset->rr_type == head->rrset.rr_type && rrset->pkt == head->rrset.pkt && rrset->pkt_len == head->rrset.pkt_len && _dname_equal(rrset->name, head->rrset.name)) return NULL; for (label = labels; label < last_label; label++) { if (! _dname_is_parent(*label, head->rrset.name)) break; } if (label - labels > max_labels) { max_labels = label - labels; max_head = head; } } /* Chain found. Now set max_node to the point in the chain where nodes * will be common. */ if (max_head) { for ( node = max_head->parent, n = 0 ; node ; node = node->parent, n++); for ( n -= max_labels, node = max_head->parent ; n ; n--, node = node->parent); max_node = node; } else max_node = NULL; /* node_count is the amount of nodes to still allocate. * the last one's parent has to hook into the max_node. */ dname_len = *labels - last_label[-1] + 1; head_sz = (sizeof(chain_head) + dname_len + 7) / 8 * 8; node_count = last_label - labels - max_labels; DEBUG_SEC( "%zu labels in common. %zu labels to allocate\n" , max_labels, node_count); if (! (region = GETDNS_XMALLOC(*mf, uint8_t, head_sz + node_count * sizeof(chain_node)))) return NULL; /* Append the head on the linked list of heads */ for (head = *chain_p; head && head->next; head = head->next) ; if (head) head = head->next = (chain_head *)region; else head = *chain_p = (chain_head *)region; head->my_mf = *mf; head->next = NULL; head->rrset.name = head->name_spc; memcpy(head->name_spc, rrset->name, dname_len); head->rrset.rr_class = rrset->rr_class; head->rrset.rr_type = rrset->rr_type; head->rrset.pkt = rrset->pkt; head->rrset.pkt_len = rrset->pkt_len; head->netreq = netreq; head->signer = 0; head->node_count = node_count; if (!node_count) { head->parent = max_head->parent; return head; } /* Initialize the nodes */ for ( head->parent = node = (chain_node *)(region + head_sz), dname = head->rrset.name ; node_count ; node_count--, node = node->parent =&node[1], dname += *dname + 1) { node->ds.name = dname; node->dnskey.name = dname; node->ds.rr_class = head->rrset.rr_class; node->dnskey.rr_class = head->rrset.rr_class; node->ds.rr_type = GETDNS_RRTYPE_DS; node->dnskey.rr_type = GETDNS_RRTYPE_DNSKEY; node->ds.pkt = NULL; node->ds.pkt_len = 0; node->dnskey.pkt = NULL; node->dnskey.pkt_len = 0; node->ds_req = NULL; node->dnskey_req = NULL; node->soa_req = NULL; node->ds_signer = 0; node->dnskey_signer = 0; node->chains = *chain_p; } /* On the first chain, max_node == NULL. * Schedule a root DNSKEY query, we always need that. */ if (!(node[-1].parent = max_node)) val_chain_sched(head, (uint8_t *)"\0"); return head; } static int is_synthesized_cname(getdns_rrset *cname) { rrset_iter *i, i_spc; getdns_rrset *dname; rrtype_iter rr_spc, *rr; _getdns_rdf_iter rdf_spc, *rdf; rrtype_iter drr_spc, *drr; _getdns_rdf_iter drdf_spc, *drdf; uint8_t cname_rdata_spc[256], dname_rdata_spc[256], synth_name[256], *synth_name_end = synth_name + sizeof(synth_name) - 1, *s; const uint8_t *cname_rdata, *dname_rdata, *c; size_t cname_rdata_len = sizeof(cname_rdata_spc), dname_rdata_len = sizeof(dname_rdata_len), cname_labels, dname_labels; /* Synthesized CNAMEs don't have RRSIGs */ if ( cname->rr_type != GETDNS_RRTYPE_CNAME || rrset_has_rrsigs(cname)) return 0; /* Get canonical name rdata field */ if ( !(rr = rrtype_iter_init(&rr_spc, cname)) || !(rdf = _getdns_rdf_iter_init(&rdf_spc, &rr->rr_i)) || !(cname_rdata = _getdns_rdf_if_or_as_decompressed( rdf, cname_rdata_spc, &cname_rdata_len))) return 0; /* Find a matching DNAME */ for ( i = rrset_iter_init(&i_spc, cname->pkt, cname->pkt_len) ; i ; i = rrset_iter_next(i)) { dname = rrset_iter_value(i); if ( dname->rr_type != GETDNS_RRTYPE_DNAME /* DNAME->owner is parent of CNAME->owner */ || !_dname_is_parent(dname->name, cname->name)) continue; dname_labels = _dname_label_count(dname->name); cname_labels = _dname_label_count(cname->name); /* Synthesize the canonical name. * First copy labels(cname) - labels(dname) labels from * CNAME's owner name, then append DNAME rdata field. * If it matches CNAME's rdata field then it was synthesized * with this DNAME. */ cname_labels -= dname_labels; for ( c = cname->name, s = synth_name ; cname_labels && s + *c + 1 < synth_name_end ; cname_labels--, c += *c + 1, s += *s + 1 ) { memcpy(s, c, *c + 1); } if (cname_labels) continue; /* Get DNAME's rdata field */ if ( !(drr = rrtype_iter_init(&drr_spc, dname)) || !(drdf=_getdns_rdf_iter_init(&drdf_spc,&drr->rr_i)) || !(dname_rdata = _getdns_rdf_if_or_as_decompressed( drdf, dname_rdata_spc, &dname_rdata_len))) continue; if (s + _dname_len(dname_rdata) > synth_name_end) continue; memcpy(s, dname_rdata, _dname_len(dname_rdata)); debug_sec_print_dname("Synthesized name: ", synth_name); debug_sec_print_dname(" Canonical name: ", cname_rdata); if (_dname_equal(synth_name, cname_rdata)) return 1; } return 0; } /* Create the validation chain structure for the given packet. * When netreq is set, queries will be scheduled for the DS * and DNSKEY RR's for the nodes on the validation chain. * * Scheduling is as follows. * If the RRset has a signature, signer name is followed to schedule DS/DNSKEY. * Otherwise, if the RRSET is a SOA, owner name is followed to schedule DS * Otherwise, if the RRset is a CNAME, a SOA query is scheduled for the parent * Otherwise, a SOA query is scheduled for the owner name. * * When a SOA query was successful, a query for DS will follow for that * owner name. */ static void add_pkt2val_chain(struct mem_funcs *mf, chain_head **chain_p, uint8_t *pkt, size_t pkt_len, getdns_network_req *netreq) { rrset_iter *i, i_spc; getdns_rrset *rrset; rrsig_iter *rrsig, rrsig_spc; size_t n_rrsigs; chain_head *head; assert(pkt); assert(pkt_len >= GLDNS_HEADER_SIZE); /* For all things with signatures, create a chain */ /* For all things without signature, find SOA (zonecut) and query DS */ for ( i = rrset_iter_init(&i_spc, pkt, pkt_len) ; i ; i = rrset_iter_next(i)) { rrset = rrset_iter_value(i); debug_sec_print_rrset("rrset: ", rrset); /* Schedule validation for everything, except from DNAME * synthesized CNAME's */ if (is_synthesized_cname(rrset)) continue; if (!(head = add_rrset2val_chain(mf, chain_p, rrset, netreq))) continue; for ( rrsig = rrsig_iter_init(&rrsig_spc, rrset), n_rrsigs = 0 ; rrsig ; rrsig = rrsig_iter_next(rrsig), n_rrsigs++) { /* Signature, so lookup DS/DNSKEY at signer's name */ val_chain_sched_signer(head, rrsig); } if (n_rrsigs) continue; /* No signatures found for this RRset */ if (rrset->rr_type == GETDNS_RRTYPE_SOA) val_chain_sched_ds(head, rrset->name); else if (rrset->rr_type == GETDNS_RRTYPE_CNAME) val_chain_sched_soa(head, rrset->name + *rrset->name + 1); else val_chain_sched_soa(head, rrset->name); } } /* For NOERROR/NODATA or NXDOMAIN responses add extra rrset to * the validation chain so the denial of existence will be * checked eventually. * But only if we know the question of course... */ static void add_question2val_chain(struct mem_funcs *mf, chain_head **chain_p, uint8_t *pkt, size_t pkt_len, const uint8_t *qname, uint16_t qtype, uint16_t qclass, getdns_network_req *netreq) { getdns_rrset q_rrset; uint8_t cname_spc[256]; size_t cname_len = sizeof(cname_spc); size_t anti_loop; _getdns_rdf_iter rdf_spc, *rdf; rrtype_iter *rr, rr_spc; chain_head *head; assert(pkt); assert(pkt_len >= GLDNS_HEADER_SIZE); assert(qname); /* First find the canonical name for the question */ q_rrset.name = qname; q_rrset.rr_type = GETDNS_RRTYPE_CNAME; q_rrset.rr_class = qclass; q_rrset.pkt = pkt; q_rrset.pkt_len = pkt_len; for (anti_loop = MAX_CNAMES; anti_loop; anti_loop--) { if (!(rr = rrtype_iter_init(&rr_spc, &q_rrset))) break; if (!(rdf = _getdns_rdf_iter_init(&rdf_spc, &rr->rr_i))) break; q_rrset.name = _getdns_rdf_if_or_as_decompressed( rdf, cname_spc, &cname_len); } /* If the qtype was a CNAME, and we got one, we'r done. * We asked for it directly, so no redirection applies. * Otherwise we have to check the referred to name/qtype. */ if (qtype == GETDNS_RRTYPE_CNAME && q_rrset.name != qname) return; q_rrset.rr_type = qtype; if (!(rr = rrtype_iter_init(&rr_spc, &q_rrset))) { /* No answer for the question. Add a head for this rrset * anyway, to validate proof of non-existance, or to find * proof that the packet is insecure. */ debug_sec_print_rrset("Adding NX rrset: ", &q_rrset); head = add_rrset2val_chain(mf, chain_p, &q_rrset, netreq); /* On empty packet, find SOA (zonecut) for the qname */ if (head && GLDNS_ANCOUNT(pkt) == 0 && GLDNS_NSCOUNT(pkt) == 0) val_chain_sched_soa(head, q_rrset.name); } } /************* Schedule Queries to Provision Validation Chain *************** *****************************************************************************/ static getdns_dict *CD_extension(getdns_dns_req *dnsreq) { #ifdef DNSSEC_ROADBLOCK_AVOIDANCE return !dnsreq->dnssec_roadblock_avoidance ? dnssec_ok_checking_disabled : !dnsreq->avoid_dnssec_roadblocks ? dnssec_ok_checking_disabled_roadblock_avoidance : dnssec_ok_checking_disabled_avoid_roadblocks; #else return dnssec_ok_checking_disabled; #endif } static void check_chain_complete(chain_head *chain); static void val_chain_node_soa_cb(getdns_dns_req *dnsreq); static void val_chain_sched_soa_node(chain_node *node) { getdns_context *context; getdns_eventloop *loop; getdns_dns_req *dnsreq; char name[1024]; context = node->chains->netreq->owner->context; loop = node->chains->netreq->owner->loop; if (!gldns_wire2str_dname_buf( (UNCONST_UINT8_p)node->ds.name, 256, name, sizeof(name))) return; DEBUG_SEC("schedule SOA lookup for %s\n", name); if (! node->soa_req && ! _getdns_general_loop(context, loop, name, GETDNS_RRTYPE_SOA, CD_extension(node->chains->netreq->owner), node, &dnsreq, NULL, val_chain_node_soa_cb)) node->soa_req = dnsreq->netreqs[0]; } /* A SOA lookup is scheduled as a last resort. No signatures were found and * no SOA in the authority section. If a SOA query returns an actual SOA * answer, then a DS/DNSKEY lookup will follow the acquire the link of the * authentication chain. */ static void val_chain_sched_soa(chain_head *head, const uint8_t *dname) { chain_node *node; if (!head->netreq) return; if (!*dname) return; for ( node = head->parent ; node && !_dname_equal(dname, node->ds.name) ; node = node->parent); if (node) val_chain_sched_soa_node(node); } static void val_chain_node_cb(getdns_dns_req *dnsreq); static void val_chain_sched_node(chain_node *node) { getdns_context *context; getdns_eventloop *loop; getdns_dns_req *dnsreq; char name[1024]; context = node->chains->netreq->owner->context; loop = node->chains->netreq->owner->loop; if (!gldns_wire2str_dname_buf( (UNCONST_UINT8_p)node->ds.name, 256, name, sizeof(name))) return; DEBUG_SEC("schedule DS & DNSKEY lookup for %s\n", name); if (! node->dnskey_req /* not scheduled */ && ! _getdns_general_loop(context, loop, name, GETDNS_RRTYPE_DNSKEY, CD_extension(node->chains->netreq->owner), node, &dnsreq, NULL, val_chain_node_cb)) node->dnskey_req = dnsreq->netreqs[0]; if (! node->ds_req && node->parent /* not root */ && ! _getdns_general_loop(context, loop, name, GETDNS_RRTYPE_DS, CD_extension(node->chains->netreq->owner), node, &dnsreq, NULL, val_chain_node_cb)) node->ds_req = dnsreq->netreqs[0]; } static void val_chain_sched(chain_head *head, const uint8_t *dname) { chain_node *node; if (!head->netreq) return; for ( node = head->parent ; node && !_dname_equal(dname, node->ds.name) ; node = node->parent); if (node) val_chain_sched_node(node); } static void val_chain_sched_ds_node(chain_node *node) { getdns_context *context; getdns_eventloop *loop; getdns_dns_req *ds_req; char name[1024]; context = node->chains->netreq->owner->context; loop = node->chains->netreq->owner->loop; if (!gldns_wire2str_dname_buf( (UNCONST_UINT8_p)node->ds.name, 256, name, sizeof(name))) return; DEBUG_SEC("schedule DS lookup for %s\n", name); if (! node->ds_req && node->parent /* not root */ && ! _getdns_general_loop(context, loop, name, GETDNS_RRTYPE_DS, CD_extension(node->chains->netreq->owner), node, &ds_req, NULL, val_chain_node_cb)) node->ds_req = ds_req->netreqs[0]; } static void val_chain_sched_ds(chain_head *head, const uint8_t *dname) { chain_node *node; if (!head->netreq) return; for ( node = head->parent ; node && !_dname_equal(dname, node->ds.name) ; node = node->parent); if (node) val_chain_sched_ds_node(node); } static void val_chain_sched_signer_node(chain_node *node, rrsig_iter *rrsig) { _getdns_rdf_iter rdf_spc, *rdf; uint8_t signer_spc[256]; const uint8_t *signer; size_t signer_len; if (!(rdf = _getdns_rdf_iter_init_at(&rdf_spc, &rrsig->rr_i, 7))) return; if (!(signer = _getdns_rdf_if_or_as_decompressed( rdf, signer_spc, &signer_len))) return; while (node && !_dname_equal(signer, node->ds.name)) node = node->parent; if (node) val_chain_sched_node(node); } static void val_chain_sched_signer(chain_head *head, rrsig_iter *rrsig) { if (!head->netreq) return; val_chain_sched_signer_node(head->parent, rrsig); } static void val_chain_node_cb(getdns_dns_req *dnsreq) { chain_node *node = (chain_node *)dnsreq->user_pointer; getdns_network_req *netreq = dnsreq->netreqs[0]; rrset_iter *i, i_spc; getdns_rrset *rrset; rrsig_iter *rrsig, rrsig_spc; size_t n_signers; _getdns_context_clear_outbound_request(dnsreq); switch (netreq->request_type) { case GETDNS_RRTYPE_DS : node->ds.pkt = netreq->response; node->ds.pkt_len = netreq->response_len; break; case GETDNS_RRTYPE_DNSKEY: node->dnskey.pkt = netreq->response; node->dnskey.pkt_len = netreq->response_len; default : check_chain_complete(node->chains); return; } n_signers = 0; for ( i = rrset_iter_init(&i_spc,netreq->response,netreq->response_len) ; i ; i = rrset_iter_next(i)) { rrset = rrset_iter_value(i); if (rrset->rr_type != GETDNS_RRTYPE_DS && rrset->rr_type != GETDNS_RRTYPE_NSEC && rrset->rr_type != GETDNS_RRTYPE_NSEC3) continue; for ( rrsig = rrsig_iter_init(&rrsig_spc, rrset) ; rrsig; rrsig = rrsig_iter_next(rrsig)) { val_chain_sched_signer_node(node, rrsig); n_signers++; } } if (netreq->request_type == GETDNS_RRTYPE_DS && n_signers == 0) /* No signed DS and no signed proof of non-existance. * Search further up the tree... */ val_chain_sched_soa_node(node->parent); check_chain_complete(node->chains); } static void val_chain_node_soa_cb(getdns_dns_req *dnsreq) { chain_node *node = (chain_node *)dnsreq->user_pointer; getdns_network_req *netreq = dnsreq->netreqs[0]; rrset_iter i_spc; getdns_rrset *rrset; _getdns_context_clear_outbound_request(dnsreq); if ((rrset = rrset_by_type(&i_spc, netreq, GETDNS_RRTYPE_SOA))) { while (node && ! _dname_equal(node->ds.name, rrset->name)) node = node->parent; if (node) val_chain_sched_ds_node(node); else { /* SOA for a different name */ node = (chain_node *)dnsreq->user_pointer; val_chain_sched_soa_node(node->parent); } } else if (node->parent) val_chain_sched_soa_node(node->parent); check_chain_complete(node->chains); } /*************************** DNSSEC Validation ***************************** *****************************************************************************/ /* Returns whether a key in set dnskey is used to sign rrset. * Only keytag and signer name is compared. The signature is not verified. */ static int key_matches_signer(getdns_rrset *dnskey, getdns_rrset *rrset) { rrtype_iter rr_spc, *rr; rrsig_iter rrsig_spc, *rrsig; uint16_t keytag; _getdns_rdf_iter rdf_spc, *rdf; uint8_t signer_spc[256]; const uint8_t *signer; size_t signer_len = sizeof(signer_spc); assert(dnskey->rr_type == GETDNS_RRTYPE_DNSKEY); for ( rr = rrtype_iter_init(&rr_spc, dnskey) ; rr ; rr = rrtype_iter_next(rr) ) { /* Enough space to at least read algorithm field? */ if (rr->rr_i.nxt < rr->rr_i.rr_type + 14) continue; /* Then we have at least 4 bytes to calculate keytag */ keytag = gldns_calc_keytag_raw( (UNCONST_UINT8_p)rr->rr_i.rr_type + 10, rr->rr_i.nxt - rr->rr_i.rr_type - 10); for ( rrsig = rrsig_iter_init(&rrsig_spc, rrset) ; rrsig ; rrsig = rrsig_iter_next(rrsig) ) { if (/* Space for keytag & signer in rrsig rdata? */ rrsig->rr_i.nxt >= rrsig->rr_i.rr_type + 28 /* Does Algorithm match */ && rrsig->rr_i.rr_type[12] == rr->rr_i.rr_type[13] /* Does the keytag match? */ && gldns_read_uint16(rrsig->rr_i.rr_type + 26) == keytag /* Does the signer name match? */ && (rdf = _getdns_rdf_iter_init_at( &rdf_spc, &rrsig->rr_i, 7)) && (signer = _getdns_rdf_if_or_as_decompressed( rdf, signer_spc, &signer_len)) && _dname_equal(dnskey->name, signer)) return keytag; } } return 0; } static size_t _rr_uncompressed_rdata_size(rrtype_iter *rr) { _getdns_rdf_iter *rdf, rdf_spc; uint8_t decompressed[256]; size_t sz = 0, decompressed_sz; for ( rdf = _getdns_rdf_iter_init(&rdf_spc, &rr->rr_i) ; rdf ; rdf = _getdns_rdf_iter_next(rdf)) { if ((rdf->rdd_pos->type & GETDNS_RDF_N_C) == GETDNS_RDF_N_C) { decompressed_sz = sizeof(decompressed); if (_getdns_rdf_if_or_as_decompressed( rdf, decompressed, &decompressed_sz)) sz += decompressed_sz; } else sz += rdf->nxt - rdf->pos; } return sz; } static size_t _rr_rdata_size(rrtype_iter *rr) { const _getdns_rr_def *rr_def; size_t i; rr_def = _getdns_rr_def_lookup(gldns_read_uint16(rr->rr_i.rr_type)); for (i = 0; i < rr_def->n_rdata_fields; i++) if ((rr_def->rdata[i].type & GETDNS_RDF_N_C) == GETDNS_RDF_N_C) return _rr_uncompressed_rdata_size(rr); /* assert(gldns_read_uint16(rr->rr_type+8) == rr->nxt-rr->rr_type-10); */ return rr->rr_i.nxt - rr->rr_i.rr_type - 10; } /* Iterate byte by byte over rdata canonicalizing dname's */ typedef struct canon_rdata_iter { _getdns_rdf_iter rdf_spc; _getdns_rdf_iter *rdf; uint8_t cdname[256]; /* Canonical dname */ const uint8_t *pos; size_t len; } canon_rdata_iter; inline static void canon_rdata_iter_field_init(canon_rdata_iter *i) { for (;;) { if ((i->rdf->rdd_pos->type & GETDNS_RDF_N) == GETDNS_RDF_N) { i->len = sizeof(i->cdname); if ((i->pos = _getdns_rdf_if_or_as_decompressed( i->rdf, i->cdname, &i->len))) { _dname_canonicalize(i->pos, i->cdname); i->pos = i->cdname; } } else { i->pos = i->rdf->pos; i->len = i->rdf->nxt - i->rdf->pos; } if (i->len || !(i->rdf = _getdns_rdf_iter_next(i->rdf))) return; } } inline static void canon_rdata_iter_init(canon_rdata_iter*i,_getdns_rr_iter*rr) { if ((i->rdf = _getdns_rdf_iter_init(&i->rdf_spc, rr))) canon_rdata_iter_field_init(i); } inline static int canon_rdata_iter_data(canon_rdata_iter *i) { return i->rdf != NULL; } inline static uint8_t canon_rdata_iter_byte(canon_rdata_iter *i) { return *i->pos; } inline static void canon_rdata_iter_next(canon_rdata_iter *i) { if (--i->len == 0 && (i->rdf = _getdns_rdf_iter_next(i->rdf))) canon_rdata_iter_field_init(i); else i->pos++; } inline static int _dnssec_rdata_to_canonicalize(uint16_t rr_type) { return rr_type == GLDNS_RR_TYPE_NS || rr_type == GLDNS_RR_TYPE_MD || rr_type == GLDNS_RR_TYPE_MF || rr_type == GLDNS_RR_TYPE_CNAME || rr_type == GLDNS_RR_TYPE_SOA || rr_type == GLDNS_RR_TYPE_MB || rr_type == GLDNS_RR_TYPE_MG || rr_type == GLDNS_RR_TYPE_MR || rr_type == GLDNS_RR_TYPE_PTR || rr_type == GLDNS_RR_TYPE_MINFO || rr_type == GLDNS_RR_TYPE_MX || rr_type == GLDNS_RR_TYPE_RP || rr_type == GLDNS_RR_TYPE_AFSDB || rr_type == GLDNS_RR_TYPE_RT || rr_type == GLDNS_RR_TYPE_SIG || rr_type == GLDNS_RR_TYPE_PX || rr_type == GLDNS_RR_TYPE_NXT || rr_type == GLDNS_RR_TYPE_NAPTR || rr_type == GLDNS_RR_TYPE_KX || rr_type == GLDNS_RR_TYPE_SRV || rr_type == GLDNS_RR_TYPE_DNAME || rr_type == GLDNS_RR_TYPE_RRSIG; } static int _rr_iter_rdata_cmp(const void *a, const void *b) { _getdns_rr_iter *x = (_getdns_rr_iter *)a; _getdns_rr_iter *y = (_getdns_rr_iter *)b; uint16_t rr_type = gldns_read_uint16(x->rr_type); size_t x_rdata_len, y_rdata_len; int r; canon_rdata_iter p, q; assert(rr_type == gldns_read_uint16(y->rr_type)); if (!_dnssec_rdata_to_canonicalize(rr_type)) { /* Memory compare of rdata */ x_rdata_len = x->nxt - x->rr_type - 10; y_rdata_len = y->nxt - y->rr_type - 10; if ((r = memcmp(x->rr_type + 10, y->rr_type + 10, x_rdata_len < y_rdata_len ? x_rdata_len : y_rdata_len))) return r; return x_rdata_len < y_rdata_len ? -1 : x_rdata_len > y_rdata_len ? 1 : 0; } for ( canon_rdata_iter_init(&p, x), canon_rdata_iter_init(&q, y) ; canon_rdata_iter_data(&p) && canon_rdata_iter_data(&q) ; canon_rdata_iter_next(&p) , canon_rdata_iter_next(&q) ) { if (canon_rdata_iter_byte(&p) != canon_rdata_iter_byte(&q)) return canon_rdata_iter_byte(&p) > canon_rdata_iter_byte(&q) ? 1 : -1; } return canon_rdata_iter_data(&p) ? 1 : canon_rdata_iter_data(&q) ? -1 : 0; } /* Verifies the signature rrsig for rrset rrset with key key. * 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 static int _getdns_verify_rrsig(struct mem_funcs *mf, getdns_rrset *rrset, rrsig_iter *rrsig, rrtype_iter *key, const uint8_t **nc_name) { int r; int to_skip; _getdns_rr_iter val_rrset_spc[VAL_RRSET_SPC_SZ]; _getdns_rr_iter *val_rrset = val_rrset_spc; rrtype_iter rr_spc, *rr; size_t n_rrs, i, valbuf_sz, owner_len; _getdns_rdf_iter *signer, signer_spc, *rdf, rdf_spc; uint8_t valbuf_spc[4096], *valbuf_buf = valbuf_spc; uint8_t cdname_spc[256], owner[256]; const uint8_t *cdname; size_t cdname_len, pos; uint32_t orig_ttl; gldns_buffer valbuf; char *reason; /* nc_name should already have been initialized by the parent! */ assert(nc_name); assert(!*nc_name); if (!(signer = _getdns_rdf_iter_init_at(&signer_spc, &rrsig->rr_i, 7))) return 0; valbuf_sz = signer->nxt - rrsig->rr_i.rr_type - 10; if ((owner_len = _dname_len(rrset->name)) > 255) return 0; for (;;) { for ( rr = rrtype_iter_init(&rr_spc, rrset), n_rrs = 0 ; rr ; rr = rrtype_iter_next(rr), n_rrs++) { if (val_rrset == val_rrset_spc) { valbuf_sz += owner_len + 2 /* type */ + 2 /* class */ + 4 /* Orig TTL */ + 2 /* Rdata len */ + _rr_rdata_size(rr); if (n_rrs < VAL_RRSET_SPC_SZ) val_rrset[n_rrs] = rr->rr_i; } else val_rrset[n_rrs] = rr->rr_i; } /* Did everything fit? Then break */ if (val_rrset != val_rrset_spc || n_rrs <= VAL_RRSET_SPC_SZ) break; /* More space needed for val_rrset */ val_rrset = GETDNS_XMALLOC(*mf, _getdns_rr_iter, n_rrs); } DEBUG_SEC( "sizes: %zu rrs, %zu bytes for validation buffer\n" , n_rrs, valbuf_sz); qsort(val_rrset, n_rrs, sizeof(_getdns_rr_iter), _rr_iter_rdata_cmp); if (valbuf_sz >= sizeof(valbuf_spc)) valbuf_buf = GETDNS_XMALLOC(*mf, uint8_t, valbuf_sz); gldns_buffer_init_frm_data(&valbuf, valbuf_buf, valbuf_sz); gldns_buffer_write(&valbuf, rrsig->rr_i.rr_type + 10, signer->nxt - rrsig->rr_i.rr_type - 10); _dname_canonicalize2(gldns_buffer_at(&valbuf, 18)); orig_ttl = gldns_read_uint32(rrsig->rr_i.rr_type + 14); (void) memcpy(owner, rrset->name, owner_len); _dname_canonicalize2(owner); if (!_dnssec_rdata_to_canonicalize(rrset->rr_type)) for (i = 0; i < n_rrs; i++) { if (i && !_rr_iter_rdata_cmp( &val_rrset[i], &val_rrset[i-1])) continue; gldns_buffer_write(&valbuf, owner, owner_len); gldns_buffer_write_u16(&valbuf, rrset->rr_type); gldns_buffer_write_u16(&valbuf, rrset->rr_class); gldns_buffer_write_u32(&valbuf, orig_ttl); gldns_buffer_write(&valbuf, val_rrset[i].rr_type + 8, val_rrset[i].nxt - val_rrset[i].rr_type - 8); } else for (i = 0; i < n_rrs; i++) { if (i && !_rr_iter_rdata_cmp(&val_rrset[i], &val_rrset[i-1])) continue; gldns_buffer_write(&valbuf, owner, owner_len); gldns_buffer_write_u16(&valbuf, rrset->rr_type); gldns_buffer_write_u16(&valbuf, rrset->rr_class); gldns_buffer_write_u32(&valbuf, orig_ttl); pos = gldns_buffer_position(&valbuf); gldns_buffer_skip(&valbuf, 2); for ( rdf = _getdns_rdf_iter_init(&rdf_spc, &val_rrset[i]) ; rdf ; rdf = _getdns_rdf_iter_next(rdf) ) { if (!(rdf->rdd_pos->type & GETDNS_RDF_N)) { gldns_buffer_write( &valbuf, rdf->pos, rdf->nxt - rdf->pos); continue; } cdname_len = sizeof(cdname); if (!(cdname = _getdns_rdf_if_or_as_decompressed( rdf, cdname_spc, &cdname_len))) continue; gldns_buffer_write(&valbuf, cdname, cdname_len); _dname_canonicalize2( gldns_buffer_current(&valbuf) - cdname_len); } gldns_buffer_write_u16_at(&valbuf, pos, (uint16_t)(gldns_buffer_position(&valbuf) - pos - 2)); } DEBUG_SEC( "written to valbuf: %zu bytes\n" , gldns_buffer_position(&valbuf)); assert(gldns_buffer_position(&valbuf) <= valbuf_sz); gldns_buffer_flip(&valbuf); r = _getdns_verify_canonrrset(&valbuf, key->rr_i.rr_type[13], (UNCONST_UINT8_p)signer->nxt, rrsig->rr_i.nxt - signer->nxt, (UNCONST_UINT8_p)key->rr_i.rr_type+14, key->rr_i.nxt - key->rr_i.rr_type-14, &reason); #if defined(SEC_DEBUG) && SEC_DEBUG if (r == 0) { DEBUG_SEC("verification failed: %s\n", reason); debug_sec_print_rrset("verification failed: ", rrset); debug_sec_print_rr("verification failed: ", &rrsig->rr_i); debug_sec_print_rr("verification failed: ", &key->rr_i); } #endif if (val_rrset != val_rrset_spc) GETDNS_FREE(*mf, val_rrset); if (valbuf_buf != valbuf_spc) GETDNS_FREE(*mf, valbuf_buf); if (!r) return 0; /* Verification has already been done, so the labels rdata field is * definitely readable */ assert(rrsig->rr_i.rr_type + 14 <= rrsig->rr_i.nxt); /* If the number of labels in the owner name mathes the "labels" rdata * field, then this was not a wildcard expansion, and everything is * good. */ if ((size_t)rrsig->rr_i.rr_type[13] == _dname_label_count(rrset->name)) return 1; /* This is a valid wildcard expansion. Calculate and return the * "Next closer" name, because we need another NSEC to cover it. * (except for rrsigs for NSECs, but those are dealt with later) */ to_skip = (int)_dname_label_count(rrset->name) - (int)rrsig->rr_i.rr_type[13] - 1; for ( *nc_name = rrset->name ; to_skip > 0 ; *nc_name += **nc_name + 1, to_skip--); return 1; } /* Calculates NSEC3 hash for name, and stores that into label */ static uint8_t *_getdns_nsec3_hash_label(uint8_t *label, size_t label_len, const uint8_t *name, uint8_t algorithm, uint16_t iterations, const uint8_t *salt) { uint8_t buf[512], *dst, *eob; const uint8_t *src; uint8_t md[SHA_DIGEST_LENGTH + 256]; assert(SHA_DIGEST_LENGTH + 256 < sizeof(buf)); if (algorithm != GLDNS_SHA1) return NULL; for ( src = name, dst = buf, eob = buf + sizeof(buf) ; *src && dst + *src < eob ; src += *src + 1, dst += *dst + 1 ) _dname_label_copy(dst, src, eob - dst); if (*src || dst + *salt >= eob) return NULL; *dst++ = 0; (void)memcpy(dst, salt + 1, *salt); dst += *salt; (void)SHA1(buf, dst - buf, md); if (iterations) { (void)memcpy(buf + SHA_DIGEST_LENGTH, salt + 1, *salt); while (iterations--) { (void)memcpy(buf, md, SHA_DIGEST_LENGTH); SHA1(buf, SHA_DIGEST_LENGTH + *salt, md); } } *label = gldns_b32_ntop_extended_hex( md, SHA_DIGEST_LENGTH, (char *)label + 1, label_len - 1); return label; } static uint8_t *name2nsec3_label( getdns_rrset *nsec3, const uint8_t *name, uint8_t *label, size_t label_len) { rrsig_iter rrsig_spc, *rrsig; _getdns_rdf_iter rdf_spc, *rdf; uint8_t signer_spc[256]; const uint8_t *signer; size_t signer_len = sizeof(signer_spc); rrtype_iter rr_spc, *rr; if (/* With the "first" signature */ (rrsig = rrsig_iter_init(&rrsig_spc, nsec3)) /* Access the signer name rdata field (7th) */ && (rdf = _getdns_rdf_iter_init_at( &rdf_spc, &rrsig->rr_i, 7)) /* Verify & decompress */ && (signer = _getdns_rdf_if_or_as_decompressed( rdf, signer_spc, &signer_len)) /* signer of the NSEC3 is direct parent for this NSEC3? */ && _dname_equal( signer, nsec3->name + *nsec3->name + 1) /* signer of the NSEC3 is parent of name? */ && _dname_is_parent(signer, name) /* Initialize rr for getting NSEC3 rdata fields */ && (rr = rrtype_iter_init(&rr_spc, nsec3)) /* Check for available space to get rdata fields */ && rr->rr_i.rr_type + 15 <= rr->rr_i.nxt && rr->rr_i.rr_type + 14 + rr->rr_i.rr_type[14] <= rr->rr_i.nxt) /* Get the hashed label */ return _getdns_nsec3_hash_label(label, label_len, name, rr->rr_i.rr_type[10], gldns_read_uint16(rr->rr_i.rr_type + 12), rr->rr_i.rr_type + 14); return NULL; } static int nsec3_iteration_count_high(rrtype_iter *dnskey, getdns_rrset *nsec3) { rrtype_iter rr_spc, *rr; size_t bits; /* No NSEC3, then iteration count is not too high */ if (nsec3->rr_type != GETDNS_RRTYPE_NSEC3) return 0; /* Enough space to at least read algorithm field? * Without key data iteration count is definitely too high. */ if (dnskey->rr_i.nxt < dnskey->rr_i.rr_type + 14) return 1; if (/* Initialize rr for getting NSEC3 rdata fields */ !(rr = rrtype_iter_init(&rr_spc, nsec3)) /* Check for available space to get rdata fields */ || rr->rr_i.rr_type + 14 > rr->rr_i.nxt) return 1; bits = gldns_rr_dnskey_key_size_raw(dnskey->rr_i.rr_type + 10, dnskey->rr_i.nxt - dnskey->rr_i.rr_type - 10, dnskey->rr_i.rr_type[13]); if (bits > 2048) return gldns_read_uint16(rr->rr_i.rr_type + 12) > 2500; else if (bits > 1024) return gldns_read_uint16(rr->rr_i.rr_type + 12) > 500; else 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) { return (exp - inc > 0) && (inc - now < skew) && (now - exp < skew); } /* Returns whether dnskey signed rrset. If the rrset was a valid wildcard * expansion, nc_name will point to the next closer part of the name in rrset. */ static int dnskey_signed_rrset(struct mem_funcs *mf, time_t now, uint32_t skew, rrtype_iter *dnskey, getdns_rrset *rrset, const uint8_t **nc_name) { rrsig_iter rrsig_spc, *rrsig; _getdns_rdf_iter rdf_spc, *rdf; uint8_t signer_spc[256]; const uint8_t *signer; size_t signer_len = sizeof(signer_spc); uint16_t keytag; assert(dnskey->rrset->rr_type == GETDNS_RRTYPE_DNSKEY); assert(nc_name); *nc_name = NULL; /* Enough space to at least read algorithm field? */ if (dnskey->rr_i.nxt < dnskey->rr_i.rr_type + 14) return 0; /* Then we have at least 4 bytes to calculate keytag */ keytag = gldns_calc_keytag_raw((UNCONST_UINT8_p)dnskey->rr_i.rr_type + 10, dnskey->rr_i.nxt - dnskey->rr_i.rr_type - 10); for ( rrsig = rrsig_iter_init(&rrsig_spc, rrset) ; rrsig ; rrsig = rrsig_iter_next(rrsig) ) { if (/* Space for keytag & signer in rrsig rdata? */ rrsig->rr_i.nxt >= rrsig->rr_i.rr_type + 28 /* Does Algorithm match */ && rrsig->rr_i.rr_type[12] == dnskey->rr_i.rr_type[13] /* Does the keytag match? */ && gldns_read_uint16(rrsig->rr_i.rr_type + 26) == keytag /* Signature still (or already) valid? */ && check_dates(now, skew, gldns_read_uint32(rrsig->rr_i.rr_type + 18), gldns_read_uint32(rrsig->rr_i.rr_type + 22)) /* Does the signer name match? */ && (rdf = _getdns_rdf_iter_init_at( &rdf_spc, &rrsig->rr_i, 7)) && (signer = _getdns_rdf_if_or_as_decompressed( rdf, signer_spc, &signer_len)) && _dname_equal(dnskey->rrset->name, signer) /* Does the signature verify? */ && _getdns_verify_rrsig(mf, rrset,rrsig,dnskey,nc_name)) { debug_sec_print_rr("key ", &dnskey->rr_i); debug_sec_print_rrset("signed ", rrset); /* Signal insecurity by too high nsec3 iteration * count with NSEC3_ITERATION_COUNT_HIGH * bit in return value. */ return ( nsec3_iteration_count_high(dnskey, rrset) ? NSEC3_ITERATION_COUNT_HIGH : SIGNATURE_VERIFIED ) | keytag; } } return 0; } static int find_nsec_covering_name( struct mem_funcs *mf, time_t now, uint32_t skew, getdns_rrset *dnskey, getdns_rrset *rrset, const uint8_t *name, int *opt_out); /* Returns whether a dnskey for keyset signed rrset. */ static int a_key_signed_rrset(struct mem_funcs *mf, time_t now, uint32_t skew, getdns_rrset *keyset, getdns_rrset *rrset) { rrtype_iter dnskey_spc, *dnskey; const uint8_t *nc_name; int keytag; assert(keyset->rr_type == GETDNS_RRTYPE_DNSKEY); for ( dnskey = rrtype_iter_init(&dnskey_spc, keyset) ; dnskey ; dnskey = rrtype_iter_next(dnskey) ) { if (!(keytag = dnskey_signed_rrset(mf, now, skew, dnskey, rrset, &nc_name))) continue; if (!nc_name) /* Not a wildcard, then success! */ return keytag; /* Wildcard RRSIG for a NSEC on the wildcard. * There is no more specific! */ if (rrset->rr_type == GETDNS_RRTYPE_NSEC && rrset->name[0] == 1 && rrset->name[1] == '*') return keytag; debug_sec_print_rrset("wildcard expanded to: ", rrset); debug_sec_print_dname("Find NSEC covering the more sepecific: " , nc_name); if (find_nsec_covering_name( mf, now, skew, keyset, rrset, nc_name, NULL)) return keytag; } return 0; } /* Returns whether a DS in ds_set matches a dnskey in dnskey_set which in turn * signed the dnskey set. */ static int ds_authenticates_keys(struct mem_funcs *mf, time_t now, uint32_t skew, getdns_rrset *ds_set, getdns_rrset *dnskey_set) { rrtype_iter dnskey_spc, *dnskey; rrtype_iter ds_spc, *ds; uint16_t keytag; const uint8_t *nc_name; size_t valid_dsses = 0, supported_dsses = 0; uint8_t max_supported_digest = 0; int max_supported_result = 0; unsigned char digest_spc[256], *digest; unsigned char digest_buf_spc[2048], *digest_buf; size_t digest_len, digest_buf_len, dnskey_owner_len; assert(ds_set->rr_type == GETDNS_RRTYPE_DS); assert(dnskey_set->rr_type == GETDNS_RRTYPE_DNSKEY); /* The ds_set is already authenticated! */ if (!_dname_equal(ds_set->name, dnskey_set->name)) return 0; debug_sec_print_rrset("ds_authenticates_keys DS: ", ds_set); debug_sec_print_rrset("ds_authenticates_keys DNSKEY: ", dnskey_set); if ((dnskey_owner_len = _dname_len(dnskey_set->name)) >= 255) return 0; (void) memcpy(digest_buf_spc, dnskey_set->name, dnskey_owner_len); _dname_canonicalize2(digest_buf_spc); for ( dnskey = rrtype_iter_init(&dnskey_spc, dnskey_set) ; dnskey ; dnskey = rrtype_iter_next(dnskey)) { /* Enough space to at least read algorithm field? */ if (dnskey->rr_i.nxt < dnskey->rr_i.rr_type + 14) continue; keytag = gldns_calc_keytag_raw( (UNCONST_UINT8_p) dnskey->rr_i.rr_type + 10, dnskey->rr_i.nxt - dnskey->rr_i.rr_type - 10); for ( ds = rrtype_iter_init(&ds_spc, ds_set) ; ds ; ds = rrtype_iter_next(ds)) { if (/* Space for keytag, algorithm & digest type? */ ds->rr_i.nxt < ds->rr_i.rr_type + 14 /* Does algorithm match? */ || ds->rr_i.rr_type[12] != dnskey->rr_i.rr_type[13] /* Does the keytag match? */ || gldns_read_uint16(ds->rr_i.rr_type+10)!=keytag) continue; valid_dsses++; if (/* Algorithm is not RSAMD5 (deprecated) */ ds->rr_i.rr_type[12] == GLDNS_RSAMD5 /* Algorithm is supported */ || !_getdns_dnskey_algo_id_is_supported( ds->rr_i.rr_type[12]) /* Digest is supported */ || !(digest_len = _getdns_ds_digest_size_supported( ds->rr_i.rr_type[13]))) continue; digest = digest_len <= sizeof(digest_spc) ? digest_spc : GETDNS_XMALLOC(*mf, unsigned char, digest_len); digest_buf_len = dnskey->rr_i.nxt - dnskey->rr_i.rr_type - 10 + dnskey_owner_len; digest_buf = digest_buf_len <= sizeof(digest_buf_spc) ? digest_buf_spc : GETDNS_XMALLOC(*mf, unsigned char, digest_buf_len); if (digest_buf != digest_buf_spc) (void) memcpy(digest_buf, digest_buf_spc, dnskey_owner_len); (void) memcpy(digest_buf + dnskey_owner_len, dnskey->rr_i.rr_type + 10, dnskey->rr_i.nxt - dnskey->rr_i.rr_type - 10); if (!_getdns_secalgo_ds_digest(ds->rr_i.rr_type[13], digest_buf, digest_buf_len, digest)) { if (digest != digest_spc) GETDNS_FREE(*mf, digest); if (digest_buf != digest_buf_spc) GETDNS_FREE(*mf, digest_buf); continue; } supported_dsses++; /* The result of the best digest type counts! * We'll assume higher is better for now. * So, continue with next DS if... */ if (/* we already had a better digest earlier */ ds->rr_i.rr_type[13] < max_supported_digest /* or we had the same digest and it already gave * a match (to a key in dnskey_set which * authenticated the dnskey_set). */ || ( ds->rr_i.rr_type[13] == max_supported_digest && max_supported_result)) { if (digest != digest_spc) GETDNS_FREE(*mf, digest); if (digest_buf != digest_buf_spc) GETDNS_FREE(*mf, digest_buf); DEBUG_SEC("Better DS available\n"); continue; } 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 || memcmp(digest, ds->rr_i.rr_type+14, digest_len) != 0) { if (digest != digest_spc) GETDNS_FREE(*mf, digest); if (digest_buf != digest_buf_spc) GETDNS_FREE(*mf, digest_buf); DEBUG_SEC("HASH length mismatch %zu != %zu\n", digest_len, ds->rr_i.nxt - ds->rr_i.rr_type-14); continue; } /* Match! */ if (digest != digest_spc) GETDNS_FREE(*mf, digest); if (digest_buf != digest_buf_spc) GETDNS_FREE(*mf, digest_buf); if (!dnskey_signed_rrset(mf, now, skew, dnskey, dnskey_set, &nc_name) || nc_name /* No DNSKEY's on wildcards! */) { debug_sec_print_rrset("keyset did not " "authenticate: ", dnskey_set); continue; } debug_sec_print_rrset( "keyset authenticated: ", dnskey_set); max_supported_result = SIGNATURE_VERIFIED | keytag; } } DEBUG_SEC("valid_dsses: %zu, supported_dsses: %zu\n", valid_dsses, supported_dsses); if (valid_dsses && !supported_dsses) return NO_SUPPORTED_ALGORITHMS; else return max_supported_result; } static int nsec_covers_name( getdns_rrset *nsec, const uint8_t *name, const uint8_t **ce_name) { uint8_t owner_spc[256], next_spc[256]; const uint8_t *owner, *next; size_t owner_len = sizeof(owner_spc), next_len = sizeof(next_spc); rrtype_iter rr_spc, *rr; _getdns_rdf_iter rdf_spc, *rdf; int nsec_cmp; const uint8_t *common1, *common2; if (/* Get owner and next, nicely decompressed */ !(rr = rrtype_iter_init(&rr_spc, nsec)) || !(rdf = _getdns_rdf_iter_init(&rdf_spc, &rr->rr_i)) || !(owner = _getdns_owner_if_or_as_decompressed( &rr->rr_i, owner_spc, &owner_len)) || !(next = _getdns_rdf_if_or_as_decompressed( rdf, next_spc, &next_len))) return 0; debug_sec_print_dname("nsec owner: ", owner); debug_sec_print_dname("name : ", name); debug_sec_print_dname("nsec next : ", next); if (ce_name) { common1 = dname_shared_parent(name, owner); common2 = dname_shared_parent(name, next); *ce_name = _dname_label_count(common1) > _dname_label_count(common2) ? common1 : common2; debug_sec_print_dname("nsec closest encloser: ", *ce_name); } nsec_cmp = dname_compare(owner, next); if (nsec_cmp < 0) { /* Regular NSEC * >= so it can match the wildcard * (for wildcard NODATA proofs). */ return dname_compare(name, owner) >= 0 && dname_compare(name, next) < 0; } else if (nsec_cmp > 0) { /* The wrap around nsec. So NSEC->nxt == zone.name. * qname must be a subdomain of that. */ return dname_compare(name, owner) >= 0 && _dname_is_parent(next, name) && dname_compare(next, name); } else { /* This nsec is the only nsec. * zone.name NSEC zone.name, disproves everything else, * but only for subdomains of that zone. * (also no zone.name == qname of course) */ return _dname_is_parent(owner, name) && dname_compare(owner, name); } } static int nsec3_matches_name(getdns_rrset *nsec3, const uint8_t *name) { uint8_t label[64], owner[64]; if (name2nsec3_label(nsec3, name, label, sizeof(label)) && _dname_label_copy(owner, nsec3->name, sizeof(owner))) return *nsec3->name == label[0] /* Labels same size? */ && memcmp(owner + 1, label + 1, label[0]) == 0; return 0; } static int nsec3_covers_name( getdns_rrset *nsec3, const uint8_t *name, int *opt_out) { uint8_t label[65], next[65], owner[65]; rrtype_iter rr_spc, *rr; _getdns_rdf_iter rdf_spc, *rdf; int nsz = 0, nsec_cmp; if (!name2nsec3_label(nsec3, name, label, sizeof(label)-1)) return 0; label[label[0]+1] = 0; if ( !(rr = rrtype_iter_init(&rr_spc, nsec3)) || !(rdf = _getdns_rdf_iter_init_at(&rdf_spc, &rr->rr_i, 4)) || rdf->pos + *rdf->pos + 1 > rdf->nxt || (nsz = gldns_b32_ntop_extended_hex(rdf->pos + 1, *rdf->pos, (char *)next + 1, sizeof(next)-2)) < 0 || *nsec3->name > sizeof(owner) - 2 || !_dname_label_copy(owner, nsec3->name, sizeof(owner)-1)) { DEBUG_SEC("Error getting NSEC3 owner & next labels\n"); return 0; } owner[owner[0]+1] = 0; next[(next[0] = (uint8_t)nsz)+1] = 0; if (opt_out) *opt_out = (rr->rr_i.rr_type[11] & 1) != 0; debug_sec_print_dname("NSEC3 for: ", name); debug_sec_print_dname(" is: ", label); debug_sec_print_dname("inbetween: ", owner); debug_sec_print_dname(" and: ", next); nsec_cmp = dname_compare(owner, next); if (nsec_cmp >= 0) { /* The wrap around and apex-only nsec case */ return dname_compare(label, owner) > 0 || dname_compare(label, next) < 0; } else { assert(nsec_cmp < 0); /* The normal case * >= so it can match the wildcard * (for wildcard NODATA proofs). */ return dname_compare(label, owner) >= 0 && dname_compare(label, next) < 0; } } static int find_nsec_covering_name( struct mem_funcs *mf, time_t now, uint32_t skew, getdns_rrset *dnskey, getdns_rrset *rrset, const uint8_t *name, int *opt_out) { rrset_iter i_spc, *i; getdns_rrset *n; rrtype_iter nsec_spc, *nsec_rr; _getdns_rdf_iter bitmap_spc, *bitmap; int keytag; if (opt_out) *opt_out = 0; for ( i = rrset_iter_init(&i_spc, rrset->pkt, rrset->pkt_len) ; i ; i = rrset_iter_next(i)) { if ((n = rrset_iter_value(i))->rr_type == GETDNS_RRTYPE_NSEC3 /* Get the bitmap rdata field */ && (nsec_rr = rrtype_iter_init(&nsec_spc, n)) && (bitmap = _getdns_rdf_iter_init_at( &bitmap_spc, &nsec_rr->rr_i, 5)) && (keytag = a_key_signed_rrset(mf, now, skew, dnskey, n)) && ( keytag & NSEC3_ITERATION_COUNT_HIGH || ( nsec3_covers_name(n, name, opt_out) /* NSEC should cover, but not match name... * Unless it is wildcard match, but then we have to * check that rrset->rr_type is not enlisted, * because otherwise it should have matched the * wildcard. * * Also no CNAME... cause that should have matched too. */ && ( !nsec3_matches_name(n, name) || ( name[0] == 1 && name[1] == (uint8_t)'*' && !bitmap_has_type(bitmap, rrset->rr_type) && !bitmap_has_type(bitmap, GETDNS_RRTYPE_CNAME) ) ) ) ) ) { debug_sec_print_rrset("NSEC3: ", n); debug_sec_print_dname("covered: ", name); return keytag; } if ((n = rrset_iter_value(i))->rr_type == GETDNS_RRTYPE_NSEC && nsec_covers_name(n, name, NULL) /* Get the bitmap rdata field */ && (nsec_rr = rrtype_iter_init(&nsec_spc, n)) && (bitmap = _getdns_rdf_iter_init_at( &bitmap_spc, &nsec_rr->rr_i, 1)) /* NSEC should cover, but not match name... * Unless it is wildcard match, but then we have to check * that rrset->rr_type is not enlisted, because otherwise * it should have matched the wildcard. * * Also no CNAME... cause that should have matched too. */ && ( !_dname_equal(n->name, name) || ( name[0] == 1 && name[1] == (uint8_t)'*' && !bitmap_has_type(bitmap, rrset->rr_type) && !bitmap_has_type(bitmap, GETDNS_RRTYPE_CNAME) ) ) /* When qname is a subdomain of the NSEC owner, make * sure there is no DNAME, and no delegation point * there. */ && ( !_dname_is_parent(n->name, name) || ( !bitmap_has_type(bitmap, GETDNS_RRTYPE_DNAME) && ( !bitmap_has_type(bitmap, GETDNS_RRTYPE_NS) || bitmap_has_type(bitmap, GETDNS_RRTYPE_SOA) ) ) ) && (keytag = a_key_signed_rrset(mf,now,skew, dnskey, n))) { debug_sec_print_rrset("NSEC: ", n); debug_sec_print_dname("covered: ", name); return keytag; } } return 0; } static int nsec3_find_next_closer( struct mem_funcs *mf, time_t now, uint32_t skew, getdns_rrset *dnskey, getdns_rrset *rrset, const uint8_t *nc_name, int *opt_out) { uint8_t wc_name[256] = { 1, (uint8_t)'*' }; int my_opt_out, keytag; if (opt_out) *opt_out = 0; if (!(keytag = find_nsec_covering_name( mf, now, skew, dnskey, rrset, nc_name, &my_opt_out))) { /* TODO: At least google doesn't return next_closer on wildcard * nodata for DS query. And in fact returns even bogus for, * for example bladiebla.xavier.nlnet.nl DS. */ return 0; } if (opt_out) *opt_out = my_opt_out; /* Wild card not needed on a "covering" NODATA response, * because of opt-out? * * We check for opt-out bit, because rcode is unreliable... * ... the checked packet might be artificially constructed * (if we came here via getdns_validate_dnssec) in which case * rcode is always NOERROR. */ if (my_opt_out || keytag & NSEC3_ITERATION_COUNT_HIGH) return keytag; nc_name += *nc_name + 1; if (_dname_len(nc_name) > sizeof(wc_name) - 2) return 0; else (void) memcpy(wc_name + 2, nc_name, _dname_len(nc_name)); return find_nsec_covering_name( mf, now, skew, dnskey, rrset, wc_name, opt_out); } /* * Does a key from keyset dnskey prove the nonexistence of the (name, type) * tuple in rrset? * * On success returns the keytag + SIGNATURE_VERIFIED (0x10000) of the key * that signed the proof. * Or in case there were NSEC3's with too high iteration count for the * verifying key: it returns keytag + NSEC3_ITERATION_COUNT_HIGH (0x20000) */ static int key_proves_nonexistance( struct mem_funcs *mf, time_t now, uint32_t skew, getdns_rrset *keyset, getdns_rrset *rrset, int *opt_out) { getdns_rrset nsec_rrset, *cover, *ce; rrtype_iter nsec_spc, *nsec_rr; _getdns_rdf_iter bitmap_spc, *bitmap; rrset_iter i_spc, *i; const uint8_t *ce_name, *nc_name; uint8_t wc_name[256] = { 1, (uint8_t)'*' }; int keytag; assert(keyset->rr_type == GETDNS_RRTYPE_DNSKEY); if (opt_out) *opt_out = 0; /* The NSEC NODATA case * ==================== * NSEC has same ownername as the rrset to deny. * Only the rr_type is missing from the bitmap. */ nsec_rrset = *rrset; nsec_rrset.rr_type = GETDNS_RRTYPE_NSEC; if (/* A NSEC RR exists at the owner name of rrset */ (nsec_rr = rrtype_iter_init(&nsec_spc, &nsec_rrset)) /* Get the bitmap rdata field */ && (bitmap = _getdns_rdf_iter_init_at( &bitmap_spc, &nsec_rr->rr_i, 1)) /* At least the rr_type of rrset should be missing from it */ && !bitmap_has_type(bitmap, rrset->rr_type) /* If the name is a CNAME, then we should have gotten the CNAME, * So no CNAME bit either. */ && !bitmap_has_type(bitmap, GETDNS_RRTYPE_CNAME) /* In case of a DS query, make sure we have the parent side NSEC * and not the child (so no SOA). * Except for the root that is checked by itself. */ && ( rrset->rr_type != GETDNS_RRTYPE_DS || !bitmap_has_type(bitmap, GETDNS_RRTYPE_SOA) || *rrset->name == 0 ) /* If not a DS query, then make sure the NSEC does not contain NS, * or if it does, then also contains SOA, otherwise we have a parent * side delegation point NSEC where we should have gotten a child * side NSEC! */ && ( rrset->rr_type == GETDNS_RRTYPE_DS || !bitmap_has_type(bitmap, GETDNS_RRTYPE_NS) || bitmap_has_type(bitmap, GETDNS_RRTYPE_SOA)) /* And a valid signature please */ && (keytag = a_key_signed_rrset(mf,now,skew,keyset,&nsec_rrset))) { debug_sec_print_rrset("NSEC NODATA proof for: ", rrset); return keytag; } /* More NSEC NODATA cases * ====================== * There are a few NSEC NODATA cases where qname doesn't match * NSEC->name: * * - An empty non terminal (ENT) will result in a NSEC covering the * qname, where qname > NSEC->name and ce(qname) is parent of NXT. * This case is handled below after the covering NSEC is found. * * - Or a wildcard match without the type. The wildcard owner name * match has special handing in the find_nsec_covering_name function. * We still expect a NSEC covering the name though. */ /* The NSEC Name error case * ======================== * - First find the NSEC that covers the owner name. */ for ( i = rrset_iter_init(&i_spc, rrset->pkt, rrset->pkt_len) ; i ; i = rrset_iter_next(i)) { cover = rrset_iter_value(i); if (/* Is cover an NSEC rrset? */ cover->rr_type != GETDNS_RRTYPE_NSEC /* Does it cover the name */ || !nsec_covers_name(cover, rrset->name, &ce_name) /* But not a match (because that would be NODATA case) */ || _dname_equal(cover->name, rrset->name) /* Get the bitmap rdata field */ || !(nsec_rr = rrtype_iter_init(&nsec_spc, cover)) || !(bitmap = _getdns_rdf_iter_init_at( &bitmap_spc, &nsec_rr->rr_i, 1)) /* When qname is a subdomain of the NSEC owner, make * sure there is no DNAME, and no delegation point * there. */ || ( _dname_is_parent(cover->name, rrset->name) && ( bitmap_has_type(bitmap, GETDNS_RRTYPE_DNAME) || ( bitmap_has_type(bitmap, GETDNS_RRTYPE_NS) && !bitmap_has_type(bitmap, GETDNS_RRTYPE_SOA) ) ) ) /* And a valid signature please (as always) */ || !(keytag = a_key_signed_rrset( mf, now, skew, keyset, cover))) continue; /* We could have found a NSEC covering an Empty Non Terminal. * In that case no NSEC covering the wildcard is needed. * Because it was actually a NODATA proof. * * Empty NON terminals can be identified, by * qname > NSEC->name && NSEC->nxt is subdomain of qname. * * nsec_covers_name() will set ce_name to qname when NSEC->nxt * is a subdomain of qname. */ if ( dname_compare(rrset->name, cover->name) > 0 && dname_compare(rrset->name, ce_name) == 0) { debug_sec_print_dname("Empty Non Terminal: ", ce_name); return keytag; } debug_sec_print_dname("Closest Encloser: ", ce_name); if (_dname_len(ce_name) > sizeof(wc_name) - 2) return 0; else (void) memcpy(wc_name+2, ce_name, _dname_len(ce_name)); debug_sec_print_dname(" Wildcard: ", wc_name); return find_nsec_covering_name( mf, now, skew, keyset, rrset, wc_name, NULL); } /* The NSEC3 NODATA case * ===================== * NSEC3 has same (hashed) ownername as the rrset to deny. */ for ( i = rrset_iter_init(&i_spc, rrset->pkt, rrset->pkt_len) ; i ; i = rrset_iter_next(i)) { /* ce is potentially the NSEC3 that matches complete qname * (so is also the closest encloser) */ ce = rrset_iter_value(i); if ( ce->rr_type == GETDNS_RRTYPE_NSEC3 /* A NSEC3 RR exists at the owner name of rrset * (this is always true) */ && (nsec_rr = rrtype_iter_init(&nsec_spc, ce)) /* Get the bitmap rdata field */ && (bitmap = _getdns_rdf_iter_init_at( &bitmap_spc, &nsec_rr->rr_i, 5)) /* At least the rr_type of rrset should be missing */ && !bitmap_has_type(bitmap, rrset->rr_type) /* If the name is a CNAME, then we should have gotten it, * So no CNAME bit either. */ && !bitmap_has_type(bitmap, GETDNS_RRTYPE_CNAME) /* In case of a DS query, make sure we have the parent side * NSEC and not the child (so no SOA). * (except for the root...) */ && ( rrset->rr_type != GETDNS_RRTYPE_DS || !bitmap_has_type(bitmap, GETDNS_RRTYPE_SOA) || *rrset->name == 0 ) /* If not a DS query, then make sure the NSEC does not * contain NS, or if it does, then also contains SOA, * otherwise we have a parent side delegation point NSEC * where we should have gotten a child side NSEC! */ && ( rrset->rr_type == GETDNS_RRTYPE_DS || !bitmap_has_type(bitmap, GETDNS_RRTYPE_NS) || bitmap_has_type(bitmap, GETDNS_RRTYPE_SOA)) /* It must have a valid signature */ && (keytag = a_key_signed_rrset(mf, now, skew, keyset, ce)) /* The qname must match the NSEC3 */ && ( keytag & NSEC3_ITERATION_COUNT_HIGH || nsec3_matches_name(ce, rrset->name))) { debug_sec_print_rrset("NSEC3 No Data for: ", rrset); return keytag; } } /* More NSEC3 NODATA cases * ====================== * There are a few NSEC NODATA cases where qname doesn't match * NSEC->name: * * - NSEC3 ownername match for qtype == NSEC3 (TODO?) * - Wildcard NODATA (wildcard owner name match has special handing * find_nsec_covering_name()) */ /* The NSEC3 Name error case * ========================+ * First find the closest encloser. */ for ( nc_name = rrset->name, ce_name = rrset->name + *rrset->name + 1 ; *ce_name ; nc_name = ce_name, ce_name += *ce_name + 1) { for ( i = rrset_iter_init(&i_spc, rrset->pkt, rrset->pkt_len) ; i ; i = rrset_iter_next(i)) { if ( (ce = rrset_iter_value(i))->rr_type != GETDNS_RRTYPE_NSEC3 /* Get the bitmap rdata field */ || !(nsec_rr = rrtype_iter_init(&nsec_spc, ce)) || !(bitmap = _getdns_rdf_iter_init_at( &bitmap_spc, &nsec_rr->rr_i, 1)) /* No DNAME or delegation point at the closest * encloser. * * TODO: Ask Wouter * Unbound val_nsec3:1024 finishes insecurely * here (instead of bogus) when DS is also missing. * Should we not have followed the delegation then * too? * The NSEC could come from a parent zone! * */ || bitmap_has_type(bitmap, GETDNS_RRTYPE_DNAME) || ( bitmap_has_type(bitmap, GETDNS_RRTYPE_NS) && !bitmap_has_type(bitmap, GETDNS_RRTYPE_SOA) ) || !(keytag = a_key_signed_rrset( mf, now, skew, keyset, ce)) || ( !(keytag & NSEC3_ITERATION_COUNT_HIGH) && !nsec3_matches_name(ce, ce_name))) continue; debug_sec_print_rrset("Closest Encloser: ", ce); debug_sec_print_dname("Closest Encloser: ", ce_name); debug_sec_print_dname(" Next closer: ", nc_name); if ( keytag & NSEC3_ITERATION_COUNT_HIGH || (keytag = nsec3_find_next_closer(mf, now, skew, keyset, rrset, nc_name, opt_out))) return keytag; } } return 0; } /* Ascend up to the root along chain_nodes. Try to find a keyset * authenticated by a key in ta rrset (trust anchor). When we found one, * descend back down, authenticating more specific keysets along the chain. * * The most specific keyset is returned in keys. Also a DNSSEC status is * returned. BOGUS if no keyset could be found. INSECURE if the * non-existence of a DS along the path is proofed, and SECURE otherwise. */ static int chain_node_get_trusted_keys( struct mem_funcs *mf, time_t now, uint32_t skew, chain_node *node, getdns_rrset *ta, getdns_rrset **keys) { int s, keytag; /* Ascend up to the root */ if (! node) return GETDNS_DNSSEC_BOGUS; else if (ta->rr_type == GETDNS_RRTYPE_DS) { if ((keytag = ds_authenticates_keys( mf, now, skew, ta, &node->dnskey))) { *keys = &node->dnskey; node->dnskey_signer = keytag; return keytag & NO_SUPPORTED_ALGORITHMS ? GETDNS_DNSSEC_INSECURE : GETDNS_DNSSEC_SECURE; } } else if (ta->rr_type == GETDNS_RRTYPE_DNSKEY) { /* ta is KSK */ if ((keytag = a_key_signed_rrset( mf, now, skew, ta, &node->dnskey))) { *keys = &node->dnskey; node->dnskey_signer = keytag; return GETDNS_DNSSEC_SECURE; } /* ta is parent's ZSK */ if ((keytag = key_proves_nonexistance( mf, now, skew, ta, &node->ds, NULL))) { node->ds_signer = keytag; return GETDNS_DNSSEC_INSECURE; } if ((keytag = a_key_signed_rrset(mf,now,skew,ta,&node->ds))) { node->ds_signer = keytag; if ((keytag = ds_authenticates_keys( mf, now, skew, &node->ds, &node->dnskey))) { *keys = &node->dnskey; node->dnskey_signer = keytag; return keytag & NO_SUPPORTED_ALGORITHMS ? GETDNS_DNSSEC_INSECURE : GETDNS_DNSSEC_SECURE; } return GETDNS_DNSSEC_BOGUS; } } else return GETDNS_DNSSEC_BOGUS; if (GETDNS_DNSSEC_SECURE != (s = chain_node_get_trusted_keys( mf, now, skew, node->parent, ta, keys))) return s; /* keys is an authenticated dnskey rrset always now (i.e. ZSK) */ ta = *keys; /* Back down to the head */ if ((keytag = key_proves_nonexistance( mf, now, skew, ta, &node->ds, NULL))) { node->ds_signer = keytag; return GETDNS_DNSSEC_INSECURE; } if (key_matches_signer(ta, &node->ds)) { if ((node->ds_signer = a_key_signed_rrset( mf, now, skew, ta, &node->ds)) && (keytag = ds_authenticates_keys( mf, now, skew, &node->ds, &node->dnskey))){ *keys = &node->dnskey; node->dnskey_signer = keytag; return keytag & NO_SUPPORTED_ALGORITHMS ? GETDNS_DNSSEC_INSECURE : GETDNS_DNSSEC_SECURE; } return GETDNS_DNSSEC_BOGUS; } /* If we are on a zone cut, we must return BOGUS, because there should * have been a more specific DS set. We can be sure of a zone cut if * a request for the DSset was sent (because they are done only for * signer names and when there was a SOA) or if we do have a DS, * but not signed with a current trusted key. * * For the getdns_validate_dnssec case, we must make sure to insert * an empty DS for this name in the validation chain... so it can * be used for the support_records parameter. */ if (node->ds_req || rrset_has_rrs(&node->ds)) return GETDNS_DNSSEC_BOGUS; /* Not at a zone cut, the trusted keyset must be authenticating * something below (closer to head) this node. */ return GETDNS_DNSSEC_SECURE; } /* The DNSSEC status of the rrset of head is evaluated with trust anchor ta. * For this first a secure keyset is looked up, with which the keyset is * evaluated. */ static int chain_head_validate_with_ta(struct mem_funcs *mf, time_t now, uint32_t skew, chain_head *head, getdns_rrset *ta) { getdns_rrset *keys; int s, keytag, opt_out; debug_sec_print_rrset("validating ", &head->rrset); debug_sec_print_rrset("with trust anchor ", ta); if ((s = chain_node_get_trusted_keys( mf, now, skew, head->parent, ta, &keys)) != GETDNS_DNSSEC_SECURE) return s; if (rrset_has_rrs(&head->rrset)) { if ((keytag = a_key_signed_rrset( mf, now, skew, keys, &head->rrset))) { head->signer = keytag; return GETDNS_DNSSEC_SECURE; } else if (!rrset_has_rrsigs(&head->rrset) && (keytag = key_proves_nonexistance(mf, now, skew, keys, &head->rrset, &opt_out)) && opt_out) { head->signer = keytag; return GETDNS_DNSSEC_INSECURE; } } else if ((keytag = key_proves_nonexistance(mf, now, skew, keys, &head->rrset, &opt_out))) { head->signer = keytag; return opt_out || (keytag & NSEC3_ITERATION_COUNT_HIGH) ? GETDNS_DNSSEC_INSECURE : GETDNS_DNSSEC_SECURE; } return GETDNS_DNSSEC_BOGUS; } /* The DNSSEC status of the rrset in head is evaluated by trying the trust * anchors in tas in turn. The best outcome counts. */ static int chain_head_validate(struct mem_funcs *mf, time_t now, uint32_t skew, chain_head *head, rrset_iter *tas) { rrset_iter *i; getdns_rrset *ta, dnskey_ta, ds_ta; rrset_iter closest_ta; int closest_labels, s = GETDNS_DNSSEC_INDETERMINATE; size_t ta_labels, supported_algorithms; rrtype_iter rr_spc, *rr; /* Find the TA closest to the head's RRset name */ closest_labels = -1; for (i = rrset_iter_rewind(tas); i ;i = rrset_iter_next(i)) { ta = rrset_iter_value(i); if ((ta->rr_type == GETDNS_RRTYPE_DNSKEY || ta->rr_type == GETDNS_RRTYPE_DS) && _dname_is_parent(ta->name, head->rrset.name) && (int)(ta_labels = _dname_label_count(ta->name)) > closest_labels ) { closest_labels = (int)ta_labels; closest_ta = *i; if (i->rrset.name == i->name_spc) closest_ta.rrset.name = closest_ta.name_spc; } } DEBUG_SEC("closest labels for TA: %d\n", closest_labels); if (closest_labels == -1) return GETDNS_DNSSEC_INDETERMINATE; ta = rrset_iter_value(&closest_ta); dnskey_ta = *ta; dnskey_ta.rr_type = GETDNS_RRTYPE_DNSKEY; ds_ta = *ta; ds_ta.rr_type = GETDNS_RRTYPE_DS; if (!rrset_has_rrs(&dnskey_ta)) return chain_head_validate_with_ta(mf,now,skew,head,&ds_ta); /* Does the selected DNSKEY set have supported algorithms? */ supported_algorithms = 0; for ( rr = rrtype_iter_init(&rr_spc, ta) ; rr; rr = rrtype_iter_next(rr)) { if ( rr->rr_i.rr_type + 14 <= rr->rr_i.nxt && _getdns_dnskey_algo_id_is_supported( rr->rr_i.rr_type[13])) supported_algorithms++; } if (!supported_algorithms) { if (rrset_has_rrs(&ds_ta)) return chain_head_validate_with_ta( mf, now, skew, head, &ds_ta); return GETDNS_DNSSEC_INSECURE; } s = chain_head_validate_with_ta(mf, now, skew, head, &dnskey_ta); if (rrset_has_rrs(&ds_ta)) { switch (chain_head_validate_with_ta(mf,now,skew,head,&ds_ta)) { case GETDNS_DNSSEC_SECURE : s = GETDNS_DNSSEC_SECURE; case GETDNS_DNSSEC_INSECURE: if (s != GETDNS_DNSSEC_SECURE) s = GETDNS_DNSSEC_INSECURE; break; case GETDNS_DNSSEC_BOGUS : if (s != GETDNS_DNSSEC_SECURE && s != GETDNS_DNSSEC_INSECURE) s = GETDNS_DNSSEC_BOGUS; break; default : break; } } return s; } /* The DNSSEC status of the network requests which constructed the chain is * evaluated by processing each head in turn. The worst outcome per network request * is the dnssec status for that network request. */ static void chain_set_netreq_dnssec_status(chain_head *chain, rrset_iter *tas) { chain_head *head; /* The netreq status is the worst for any head */ for (head = chain; head; head = head->next) { if (!head->netreq) continue; switch (chain_head_validate(priv_getdns_context_mf( head->netreq->owner->context), time(NULL), head->netreq->owner->context->dnssec_allowed_skew, head, tas)) { case GETDNS_DNSSEC_SECURE: if (head->netreq->dnssec_status == GETDNS_DNSSEC_INDETERMINATE) head->netreq->dnssec_status = GETDNS_DNSSEC_SECURE; break; case GETDNS_DNSSEC_INSECURE: if (head->netreq->dnssec_status != GETDNS_DNSSEC_BOGUS) head->netreq->dnssec_status = GETDNS_DNSSEC_INSECURE; break; case GETDNS_DNSSEC_BOGUS : head->netreq->dnssec_status = GETDNS_DNSSEC_BOGUS; break; default: break; } } } /* The DNSSEC status of all heads for a chain structure is evaluated by * processing each head in turn. The worst outcome is the dnssec status for * the whole. */ static int chain_validate_dnssec(struct mem_funcs *mf, time_t now, uint32_t skew, chain_head *chain, rrset_iter *tas) { int s = GETDNS_DNSSEC_INDETERMINATE, t; chain_head *head; /* The netreq status is the worst for any head */ for (head = chain; head; head = head->next) { t = chain_head_validate(mf, now, skew, head, tas); switch (t) { case GETDNS_DNSSEC_SECURE: if (s == GETDNS_DNSSEC_INDETERMINATE) s = GETDNS_DNSSEC_SECURE; break; case GETDNS_DNSSEC_INSECURE: if (s != GETDNS_DNSSEC_BOGUS) s = GETDNS_DNSSEC_INSECURE; break; case GETDNS_DNSSEC_BOGUS : s = GETDNS_DNSSEC_BOGUS; break; default: break; } } DEBUG_SEC("chain_validate_dnssec() returning %d\n", s); return s; } /**************** dnssec_return_validation_chain Extension ****************** *****************************************************************************/ static size_t count_outstanding_requests(chain_head *head) { size_t count; chain_node *node; if (!head) return 0; for ( node = head->parent, count = 0 ; node ; node = node->parent) { if (node->dnskey_req && node->dnskey_req->state != NET_REQ_FINISHED && node->dnskey_req->state != NET_REQ_CANCELED) count++; if (node->ds_req && node->ds_req->state != NET_REQ_FINISHED && node->ds_req->state != NET_REQ_CANCELED) count++; if (node->soa_req && node->soa_req->state != NET_REQ_FINISHED && node->soa_req->state != NET_REQ_CANCELED) count++; } return count + count_outstanding_requests(head->next); } static int rrset_in_list(getdns_rrset *rrset, getdns_list *list) { size_t i; getdns_dict *rr_dict; uint32_t rr_type; uint32_t rr_class; getdns_bindata *name; for (i = 0; !getdns_list_get_dict(list, i, &rr_dict); i++) { if (!getdns_dict_get_int(rr_dict, "type", &rr_type) && rrset->rr_type == rr_type && !getdns_dict_get_int(rr_dict, "class", &rr_class) && rrset->rr_class == rr_class && !getdns_dict_get_bindata(rr_dict, "name", &name) && dname_compare(rrset->name, name->data) == 0) return 1; } return 0; } static void append_rrs2val_chain_list(getdns_context *ctxt, getdns_list *val_chain_list, getdns_network_req *netreq, int signer) { rrset_iter *i, i_spc; getdns_rrset *rrset; rrtype_iter *rr, rr_spc; rrsig_iter *rrsig, rrsig_spc; getdns_dict *rr_dict; for ( i = rrset_iter_init(&i_spc,netreq->response,netreq->response_len) ; i ; i = rrset_iter_next(i)) { rrset = rrset_iter_value(i); if (rrset->rr_type == GETDNS_RRTYPE_NSEC || rrset->rr_type == GETDNS_RRTYPE_NSEC3) { if (rrset_in_list(rrset, val_chain_list)) continue; } else if (rrset->rr_type != GETDNS_RRTYPE_DNSKEY && rrset->rr_type != GETDNS_RRTYPE_DS) continue; for ( rr = rrtype_iter_init(&rr_spc, rrset) ; rr; rr = rrtype_iter_next(rr)) { if (!(rr_dict = _getdns_rr_iter2rr_dict( &ctxt->mf, &rr->rr_i))) continue; (void)_getdns_list_append_dict(val_chain_list, rr_dict); getdns_dict_destroy(rr_dict); } for ( rrsig = rrsig_iter_init(&rrsig_spc, rrset) ; rrsig; rrsig = rrsig_iter_next(rrsig)) { if (/* No space for keytag & signer in rrsig rdata? */ rrsig->rr_i.nxt < rrsig->rr_i.rr_type + 28 /* We have a signer and it doesn't match? */ || ((signer & 0xFFFF) && gldns_read_uint16(rrsig->rr_i.rr_type + 26) != (signer & 0xFFFF)) /* Could not convert to rr_dict */ || !(rr_dict = _getdns_rr_iter2rr_dict( &ctxt->mf, &rrsig->rr_i))) continue; (void)_getdns_list_append_dict(val_chain_list, rr_dict); getdns_dict_destroy(rr_dict); } } } static void append_empty_ds2val_chain_list( getdns_context *context, getdns_list *val_chain_list, getdns_rrset *ds) { getdns_dict *rr_dict; getdns_bindata bindata; getdns_dict *rdata_dict; if (!(rr_dict = getdns_dict_create_with_context(context))) return; bindata.size = _dname_len(ds->name); bindata.data = (UNCONST_UINT8_p)ds->name; (void) getdns_dict_set_bindata(rr_dict, "name", &bindata); (void) getdns_dict_set_int(rr_dict, "class", ds->rr_class); (void) getdns_dict_set_int(rr_dict, "type", ds->rr_type); (void) getdns_dict_set_int(rr_dict, "ttl", 0); if (!(rdata_dict = getdns_dict_create_with_context(context))) { getdns_dict_destroy(rr_dict); return; } bindata.size = 0; bindata.data = NULL; (void) getdns_dict_set_bindata(rdata_dict, "rdata_raw", &bindata); getdns_dict_destroy(rdata_dict); (void)_getdns_list_append_dict(val_chain_list, rr_dict); getdns_dict_destroy(rr_dict); } static void check_chain_complete(chain_head *chain) { getdns_dns_req *dnsreq; getdns_context *context; size_t o, node_count; chain_head *head, *next; chain_node *node; getdns_list *val_chain_list; getdns_dict *response_dict; rrset_iter tas_iter; if ((o = count_outstanding_requests(chain)) > 0) { DEBUG_SEC("%zu outstanding requests\n", o); return; } DEBUG_SEC("Chain done!\n"); dnsreq = chain->netreq->owner; context = dnsreq->context; #ifdef STUB_NATIVE_DNSSEC /* Perform validation only on GETDNS_RESOLUTION_STUB (unbound_id == -1) * Or when asked for the validation chain (to identify the RRSIGs that * signed the RRSETs, so that only those will be included in the * validation chain) * In any case we must have a trust anchor. */ if (( chain->netreq->unbound_id == -1 || dnsreq->dnssec_return_validation_chain) && context->trust_anchors) chain_set_netreq_dnssec_status(chain,rrset_iter_init(&tas_iter, context->trust_anchors, context->trust_anchors_len)); #else if (dnsreq->dnssec_return_validation_chain && context->trust_anchors) (void) chain_validate_dnssec(priv_getdns_context_mf(context), time(NULL), context->dnssec_allowed_skew, chain, rrset_iter_init( &tas_iter , context->trust_anchors , context->trust_anchors_len)); #endif #ifdef DNSSEC_ROADBLOCK_AVOIDANCE if ( dnsreq->dnssec_roadblock_avoidance && !dnsreq->avoid_dnssec_roadblocks && dnsreq->netreqs[0]->dnssec_status == GETDNS_DNSSEC_BOGUS) { getdns_return_t r = GETDNS_RETURN_GOOD; getdns_network_req **netreq_p, *netreq; dnsreq->avoid_dnssec_roadblocks = 1; for ( netreq_p = dnsreq->netreqs ; !r && (netreq = *netreq_p) ; netreq_p++) { netreq->state = NET_REQ_NOT_SENT; netreq->owner = dnsreq; r = _getdns_submit_netreq(netreq); } return; } #endif val_chain_list = dnsreq->dnssec_return_validation_chain ? getdns_list_create_with_context(context) : NULL; /* Walk chain to add values to val_chain_list and to cleanup */ for ( head = chain; head ; head = next ) { next = head->next; for ( node_count = head->node_count, node = head->parent ; node_count ; node_count--, node = node->parent ) { if (node->dnskey_req) { append_rrs2val_chain_list( context, val_chain_list, node->dnskey_req, node->dnskey_signer); _getdns_dns_req_free(node->dnskey_req->owner); } if (node->ds_req) { append_rrs2val_chain_list( context, val_chain_list, node->ds_req, node->ds_signer); if (!node->ds_signer && !rrset_has_rrs(&node->ds)) { /* Add empty DS, to prevent less * specific to be able to authenticate * below a zone cut (closer to head) */ append_empty_ds2val_chain_list( context, val_chain_list, &node->ds); } _getdns_dns_req_free(node->ds_req->owner); } if (node->soa_req) { _getdns_dns_req_free(node->soa_req->owner); } } GETDNS_FREE(head->my_mf, head); } response_dict = _getdns_create_getdns_response(dnsreq); if (val_chain_list) { (void) getdns_dict_set_list( response_dict, "validation_chain", val_chain_list); getdns_list_destroy(val_chain_list); } /* Final user callback */ _getdns_call_user_callback(dnsreq, response_dict); } void _getdns_get_validation_chain(getdns_dns_req *dnsreq) { getdns_network_req *netreq, **netreq_p; chain_head *chain = NULL; for (netreq_p = dnsreq->netreqs; (netreq = *netreq_p) ; netreq_p++) { if (! netreq->response || netreq->response_len < GLDNS_HEADER_SIZE || ( GLDNS_RCODE_WIRE(netreq->response) != GETDNS_RCODE_NOERROR && GLDNS_RCODE_WIRE(netreq->response) != GETDNS_RCODE_NXDOMAIN) ) { netreq->dnssec_status = GETDNS_DNSSEC_INSECURE; continue; } add_pkt2val_chain( &dnsreq->my_mf, &chain , netreq->response, netreq->response_len , netreq ); add_question2val_chain( &dnsreq->my_mf, &chain , netreq->response, netreq->response_len , netreq->owner->name , netreq->request_type , netreq->owner->request_class , netreq ); } if (chain) check_chain_complete(chain); else _getdns_call_user_callback(dnsreq, _getdns_create_getdns_response(dnsreq)); } /******************* getdns_validate_dnssec() Function ********************* *****************************************************************************/ static int wire_validate_dnssec(struct mem_funcs *mf, time_t now, uint32_t skew, uint8_t *to_val, size_t to_val_len, uint8_t *support, size_t support_len, uint8_t *tas, size_t tas_len) { chain_head *chain, *head, *next_head; chain_node *node; uint8_t qname_spc[256]; const uint8_t *qname = NULL; size_t qname_len = sizeof(qname_spc); uint16_t qtype = 0, qclass = GETDNS_RRCLASS_IN; _getdns_rr_iter rr_spc, *rr; rrset_iter tas_iter; int s; if (to_val_len < GLDNS_HEADER_SIZE) return GETDNS_RETURN_GENERIC_ERROR; #if defined(SEC_DEBUG) && SEC_DEBUG char *str = gldns_wire2str_pkt(to_val, to_val_len); DEBUG_SEC("to validate: %s\n", str); free(str); #endif if (GLDNS_RCODE_WIRE(to_val) != GETDNS_RCODE_NOERROR && GLDNS_RCODE_WIRE(to_val) != GETDNS_RCODE_NXDOMAIN) return GETDNS_DNSSEC_INSECURE; if (GLDNS_QDCOUNT(to_val) == 0 && GLDNS_ANCOUNT(to_val) == 0) return GETDNS_RETURN_GENERIC_ERROR; chain = NULL; /* First create a chain (head + nodes) for each rr in the answer and * authority section of the fake to_val packet. */ add_pkt2val_chain(mf, &chain, to_val, to_val_len, NULL); /* For each question in the question section add a chain head. */ if ( (rr = _getdns_rr_iter_init(&rr_spc, to_val, to_val_len)) && _getdns_rr_iter_section(rr) == GLDNS_SECTION_QUESTION && (qname = _getdns_owner_if_or_as_decompressed( rr, qname_spc, &qname_len)) && rr->nxt >= rr->rr_type + 4) { qtype = gldns_read_uint16(rr->rr_type); qclass = gldns_read_uint16(rr->rr_type + 2); add_question2val_chain(mf, &chain, to_val, to_val_len, qname, qtype, qclass, NULL); } /* Now equip the nodes with the support records wireformat */ for (head = chain; head; head = head->next) { for (node = head->parent; node; node = node->parent) { node->dnskey.pkt = support; node->dnskey.pkt_len = support_len; node->ds.pkt = support; node->ds.pkt_len = support_len; } } s = chain_validate_dnssec( mf, now, skew, chain, rrset_iter_init(&tas_iter, tas, tas_len)); /* Cleanup the chain */ for (head = chain; head; head = next_head) { next_head = head->next; GETDNS_FREE(*mf, head); } return s; } /* * getdns_validate_dnssec * */ getdns_return_t getdns_validate_dnssec(getdns_list *records_to_validate, getdns_list *support_records, getdns_list *trust_anchors) { uint8_t to_val_buf[4096], *to_val, support_buf[4096], *support, tas_buf[4096], *tas; size_t to_val_len = sizeof(to_val_buf), support_len = sizeof(support_buf), tas_len = sizeof(tas_buf); int r = GETDNS_RETURN_MEMORY_ERROR; struct mem_funcs *mf; size_t i; getdns_dict *reply; time_t now; uint32_t skew; #if defined(SEC_DEBUG) && SEC_DEBUG fflush(stdout); #endif if (!records_to_validate || !support_records || !trust_anchors) return GETDNS_RETURN_INVALID_PARAMETER; mf = &records_to_validate->mf; now = time(NULL); skew = 0; /* First convert everything to wire format */ if (!(support = _getdns_list2wire(support_records, support_buf, &support_len, mf))) return GETDNS_RETURN_MEMORY_ERROR; if (!(tas = _getdns_list2wire(trust_anchors, tas_buf, &tas_len, mf))) goto exit_free_support; if (!(to_val = _getdns_list2wire(records_to_validate, to_val_buf, &to_val_len, mf))) goto exit_free_tas; if ((r = wire_validate_dnssec(mf, now, skew, to_val, to_val_len, support,support_len, tas,tas_len)) != GETDNS_RETURN_GENERIC_ERROR) goto exit_free_to_val; for (i = 0; !getdns_list_get_dict(records_to_validate,i,&reply); i++) { DEBUG_SEC("REPLY %zu, r: %d\n", i, r); if (to_val != to_val_buf) GETDNS_FREE(*mf, to_val); to_val_len = sizeof(to_val_buf); if (!(to_val = _getdns_reply2wire( reply, to_val_buf, &to_val_len, mf))) continue; r = GETDNS_DNSSEC_INDETERMINATE; switch (wire_validate_dnssec(mf, now, skew, to_val, to_val_len, support, support_len, tas, tas_len)) { case GETDNS_DNSSEC_SECURE: if (r == GETDNS_DNSSEC_INDETERMINATE) r = GETDNS_DNSSEC_SECURE; break; case GETDNS_DNSSEC_INSECURE: if (r != GETDNS_DNSSEC_BOGUS) r = GETDNS_DNSSEC_INSECURE; break; case GETDNS_DNSSEC_BOGUS: r = GETDNS_DNSSEC_BOGUS; break; default: break; } } DEBUG_SEC("REPLY %zu, r: %d\n", i, r); exit_free_to_val: if (to_val != to_val_buf) GETDNS_FREE(*mf, to_val); exit_free_tas: if (tas != tas_buf) GETDNS_FREE(*mf, tas); exit_free_support: if (support != support_buf) GETDNS_FREE(*mf, support); return r; } /****************** getdns_root_trust_anchor() Function ******************** *****************************************************************************/ uint16_t _getdns_parse_ta_file(time_t *ta_mtime, gldns_buffer *gbuf) { struct gldns_file_parse_state pst; struct stat st; uint8_t rr[8192]; /* Reasonable size for a single DNSKEY or DS RR */ size_t len, dname_len; FILE *in; uint16_t ta_count = 0; size_t pkt_start; if (stat(TRUST_ANCHOR_FILE, &st) != 0) return 0; if (ta_mtime) *ta_mtime = st.st_mtime; if (!(in = fopen(TRUST_ANCHOR_FILE, "r"))) return 0; memset(&pst, 0, sizeof(pst)); pst.default_ttl = 3600; pst.lineno = 1; pkt_start = gldns_buffer_position(gbuf); /* Empty header */ gldns_buffer_write_u32(gbuf, 0); gldns_buffer_write_u32(gbuf, 0); gldns_buffer_write_u32(gbuf, 0); while (!feof(in)) { len = sizeof(rr); dname_len = 0; if (gldns_fp2wire_rr_buf(in, rr, &len, &dname_len, &pst)) break; if (len == 0) /* empty, $TTL, $ORIGIN */ continue; if (gldns_wirerr_get_type(rr, len, dname_len) != GLDNS_RR_TYPE_DS && gldns_wirerr_get_type(rr, len, dname_len) != GLDNS_RR_TYPE_DNSKEY) continue; gldns_buffer_write(gbuf, rr, len); ta_count++; } fclose(in); gldns_buffer_write_u16_at(gbuf, pkt_start+GLDNS_ANCOUNT_OFF, ta_count); return ta_count; } getdns_list * getdns_root_trust_anchor(time_t *utc_date_of_anchor) { gldns_buffer *gbuf; getdns_list *ta_rrs; if (!(ta_rrs = getdns_list_create())) return NULL; if (!(gbuf = gldns_buffer_new(4096))) goto error_free_ta_rrs; if (!_getdns_parse_ta_file(utc_date_of_anchor, gbuf)) goto error_free_gbuf; _getdns_wire2list( gldns_buffer_begin(gbuf) , gldns_buffer_position(gbuf), ta_rrs); gldns_buffer_free(gbuf); return ta_rrs; error_free_gbuf: gldns_buffer_free(gbuf); error_free_ta_rrs: getdns_list_destroy(ta_rrs); return NULL; } /* dnssec.c */ getdns-0.9.0/src/Doxyfile.in0000664000175100017510000023746212641212403012644 00000000000000# Doxyfile 1.8.3.1 # Copyright (c) 2013, Verisign, Inc., NLnet Labs # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the names of the copyright holders nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or sequence of words) that should # identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. PROJECT_NAME = "getdns API" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = @PACKAGE_VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer # a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "A modern asynchronous API for fetching DNS data" # With the PROJECT_LOGO tag one can specify an logo or icon that is # included in the documentation. The maximum height of the logo should not # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = ../doc # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = YES # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. Note that you specify absolute paths here, but also # relative paths, which will be relative from the directory where doxygen is # started. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding # "class=itcl::class" will allow you to use the command class in the # itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, # and language is one of the parsers supported by doxygen: IDL, Java, # Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, # C++. For instance to make doxygen treat .inc files as Fortran files (default # is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note # that for custom extensions you also need to set FILE_PATTERNS otherwise the # files are not read by doxygen. EXTENSION_MAPPING = # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all # comments according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you # can mix doxygen, HTML, and XML commands with Markdown formatting. # Disable only in case of backward compatibilities issues. MARKDOWN_SUPPORT = YES # When enabled doxygen tries to link words that correspond to documented classes, # or namespaces to their corresponding documentation. Such a link can be # prevented in individual cases by by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES (the # default) will make doxygen replace the get and set methods by a property in # the documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and # unions are shown inside the group in which they are included (e.g. using # @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and # unions with only public data fields will be shown inline in the documentation # of the scope in which they are defined (i.e. file, namespace, or group # documentation), provided this scope is documented. If set to NO (the default), # structs, classes, and unions are shown on a separate page (for HTML and Man # pages) or section (for LaTeX and RTF). INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. SYMBOL_CACHE_SIZE = 0 # Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be # set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given # their name and scope. Since this can be an expensive process and often the # same symbol appear multiple times in the code, doxygen keeps a cache of # pre-resolved symbols. If the cache is too small doxygen will become slower. # If the cache is too large, memory is wasted. The cache size is given by this # formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal # scope will be included in the documentation. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = NO # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to # do proper type resolution of all parameters of a function it will reject a # match between the prototype and the implementation of a member function even # if there is only one candidate or it is obvious which candidate to choose # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if section-label ... \endif # and \cond section-label ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files # containing the references data. This must be a list of .bib files. The # .bib extension is automatically appended if omitted. Using this command # requires the bibtex tool to be installed. See also # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this # feature you need bibtex and perl available in the search path. Do not use # file names with spaces, bibtex cannot handle them. CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = @srcdir@ \ getdns/ \ @srcdir@/getdns/ \ @srcdir@/example/ \ @srcdir@/test/ \ @srcdir@/../README.md # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = config.h # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = example/ # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) # and it is also possible to disable source filtering for a specific pattern # using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. FILTER_SOURCE_PATTERNS = # If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page (index.html). # This can be useful if you have a project on for instance GitHub and want reuse # the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = ../README.md #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C, C++ and Fortran comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. Note that when using a custom header you are responsible # for the proper inclusion of any scripts and style sheets that doxygen # needs, which is dependent on the configuration options used. # It is advised to generate a default header using "doxygen -w html # header.html footer.html stylesheet.css YourConfigFile" and then modify # that header. Note that the header is subject to change so you typically # have to redo this when upgrading to a newer version of doxygen or when # changing the value of configuration settings such as GENERATE_TREEVIEW! HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If left blank doxygen will # generate a default style sheet. Note that it is recommended to use # HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this # tag will in the future become obsolete. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify an additional # user-defined cascading style sheet that is included after the standard # style sheets created by doxygen. Using this option one can overrule # certain style aspects. This is preferred over using HTML_STYLESHEET # since it does not replace the standard style sheet and is therefor more # robust against future updates. Doxygen will copy the style sheet file to # the output directory. HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the style sheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of # entries shown in the various tree structured indices initially; the user # can expand and collapse entries dynamically later on. Doxygen will expand # the tree to such a level that at most the specified number of entries are # visible (unless a fully collapsed tree already exceeds this amount). # So setting the number of entries 1 will produce a full collapsed tree by # default. 0 is a special value representing an infinite number of entries # and will result in a full expanded tree by default. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely # identify the documentation publisher. This should be a reverse domain-name # style string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) # at top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. Since the tabs have the same information as the # navigation tree you can set this option to NO if you already set # GENERATE_TREEVIEW to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. # Since the tree basically has the same information as the tab index you # could consider to set DISABLE_INDEX to NO when enabling this option. GENERATE_TREEVIEW = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values # (range [0,1..20]) that doxygen will group on one line in the generated HTML # documentation. Note that a value of 0 will completely suppress the enum # values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and # SVG. The default value is HTML-CSS, which is slower, but has the best # compatibility. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to # the MathJax Content Delivery Network so you can quickly see the result without # installing MathJax. # However, it is strongly recommended to install a local # copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension # names that should be enabled during MathJax rendering. MATHJAX_EXTENSIONS = # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a web server instead of a web client using Javascript. # There are two flavours of web server based search depending on the # EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for # searching and an index file used by the script. When EXTERNAL_SEARCH is # enabled the indexing and searching needs to be provided by external tools. # See the manual for details. SERVER_BASED_SEARCH = NO # When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP # script for searching. Instead the search results are written to an XML file # which needs to be processed by an external indexer. Doxygen will invoke an # external search engine pointed to by the SEARCHENGINE_URL option to obtain # the search results. Doxygen ships with an example indexer (doxyindexer) and # search engine (doxysearch.cgi) which are based on the open source search engine # library Xapian. See the manual for configuration details. EXTERNAL_SEARCH = NO # The SEARCHENGINE_URL should point to a search engine hosted by a web server # which will returned the search results when EXTERNAL_SEARCH is enabled. # Doxygen ships with an example search engine (doxysearch) which is based on # the open source search engine library Xapian. See the manual for configuration # details. SEARCHENGINE_URL = # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed # search data is written to a file for indexing by an external tool. With the # SEARCHDATA_FILE tag the name of this file can be specified. SEARCHDATA_FILE = searchdata.xml # When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the # EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is # useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple # projects and redirect the results back to the right project. EXTERNAL_SEARCH_ID = # The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen # projects other than the one defined by this configuration file, but that are # all added to the same external search index. Each project needs to have a # unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id # of to a relative location where the documentation can be found. # The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for # the generated latex document. The footer should contain everything after # the last chapter. If it is left blank doxygen will generate a # standard footer. Notice: only use this tag if you know what you are doing! LATEX_FOOTER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See # http://en.wikipedia.org/wiki/BibTeX for more info. LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load style sheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = YES # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition that # overrules the definition found in the source code. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all references to function-like macros # that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. For each # tag file the location of the external documentation should be added. The # format of a tag file without this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths # or URLs. Note that each tag file must have a unique name (where the name does # NOT include the path). If a tag file is not located in the directory in which # doxygen is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 # By default doxygen will use the Helvetica font for all dot files that # doxygen generates. When you want a differently looking font you can specify # the font name using DOT_FONTNAME. You need to make sure dot is able to find # the font, which can be done by putting it in a standard location or by setting # the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the # directory containing the font. DOT_FONTNAME = Helvetica # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the Helvetica font. # If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to # set the path where dot can find it. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If the UML_LOOK tag is enabled, the fields and methods are shown inside # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more # managable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are svg, png, jpg, or gif. # If left blank png will be used. If you choose svg you need to set # HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = png # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to # enable generation of interactive SVG images that allow zooming and panning. # Note that this requires a modern browser other than Internet Explorer. # Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you # need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible. Older versions of IE do not have SVG support. INTERACTIVE_SVG = NO # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES getdns-0.9.0/src/rr-dict.h0000664000175100017510000001342012641212403012230 00000000000000/** * * /brief getdns support functions for DNS Resource Records */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef RR_DICT_H_ #define RR_DICT_H_ #include "config.h" #include "getdns/getdns.h" #include "gldns/gbuffer.h" /* rdf_end returns a pointer to the end of this rdf's data, * i.e. where the next rdata field will start. */ typedef const uint8_t *(*_getdns_rdf_end_t)( const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf); /* Limit checks are already done with _getdns_rdf_end_t */ typedef getdns_return_t (*_getdns_rdf_wire2dict_t)( getdns_dict *dict, const uint8_t *rdf); typedef getdns_return_t (*_getdns_rdf_wire2list_t)( getdns_list *list, const uint8_t *rdf); typedef getdns_return_t (*_getdns_rdf_dict2wire_t)( const getdns_dict *dict, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len); typedef getdns_return_t (*_getdns_rdf_list2wire_t)( const getdns_list *list, size_t index, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len); typedef struct _getdns_rdf_special { _getdns_rdf_end_t rdf_end; _getdns_rdf_wire2dict_t wire2dict; _getdns_rdf_wire2list_t wire2list; _getdns_rdf_dict2wire_t dict2wire; _getdns_rdf_list2wire_t list2wire; } _getdns_rdf_special; /* draft-levine-dnsextlang'ish type rr and rdata definitions */ #define GETDNS_RDF_INTEGER 0x010000 #define GETDNS_RDF_BINDATA 0x020000 #define GETDNS_RDF_DNAME 0x040000 #define GETDNS_RDF_COMPRESSED 0x080000 #define GETDNS_RDF_REPEAT 0x100000 #define GETDNS_RDF_FIXEDSZ 0x0000FF #define GETDNS_RDF_LEN_VAL 0x00FF00 typedef enum _getdns_rdf_wf_type { GETDNS_RDF_N = 0x060000, /* N */ GETDNS_RDF_N_A = 0x060000, /* N[A] */ GETDNS_RDF_N_C = 0x0E0000, /* N[C] */ GETDNS_RDF_N_A_C = 0x0E0000, /* N[A,C] */ GETDNS_RDF_N_M = 0x160000, /* N[M] */ GETDNS_RDF_I1 = 0x010001, /* I1 */ GETDNS_RDF_I2 = 0x010002, /* I2 */ GETDNS_RDF_I4 = 0x010004, /* I4 */ GETDNS_RDF_T = 0x010004, /* T */ /* Time values using ring arithmetics * (rfc1982) for TKEY['inception'], * TKEY['expiration'], * RRSIG['inception'] and * RRSIG['expiration'] */ GETDNS_RDF_T6 = 0x020006, /* T6 */ /* Absolute time values (since epoch) * for TSIG['time_signed'] */ GETDNS_RDF_A = 0x020004, /* A */ GETDNS_RDF_AA = 0x020008, /* AA */ GETDNS_RDF_AAAA = 0x020010, /* AAAA */ GETDNS_RDF_S = 0x020100, /* S */ GETDNS_RDF_S_L = 0x020000, /* S[L] */ GETDNS_RDF_S_M = 0x120100, /* S[M] */ GETDNS_RDF_B = 0x020000, /* B */ GETDNS_RDF_B_C = 0x020100, /* B[C] */ GETDNS_RDF_B32_C = 0x020100, /* B32[C] */ GETDNS_RDF_X = 0x020000, /* X */ GETDNS_RDF_X_C = 0x020100, /* X[C] */ /* for NSEC3['salt'] and * NSEC3PARAM['salt']. */ GETDNS_RDF_X_S = 0x020200, /* X[S] */ /* for OPT['option_data'], * TKEY['key_data'], * TKEY['other_data'], * TSIG['mac'] and * TSIG['other_data'] * Although those do not have an * official presentation format. */ GETDNS_RDF_X6 = 0x020006, GETDNS_RDF_X8 = 0x020008, GETDNS_RDF_R = 0x100000, /* Repeat */ GETDNS_RDF_SPECIAL = 0x800000, } _getdns_rdf_type; typedef struct _getdns_rdata_def { const char *name; _getdns_rdf_type type; _getdns_rdf_special *special; } _getdns_rdata_def; typedef struct _getdns_rr_def { const char *name; const _getdns_rdata_def *rdata; int n_rdata_fields; } _getdns_rr_def; const _getdns_rr_def *_getdns_rr_def_lookup(uint16_t rr_type); getdns_return_t _getdns_rr_dict2wire( const getdns_dict *rr_dict, gldns_buffer *buf); const char *_getdns_rr_type_name(int rr_type); #endif /* rrs.h */ getdns-0.9.0/src/pubkey-pinning.h0000664000175100017510000000472112641212403013627 00000000000000/** * * /brief internal functions for dealing with pubkey pinsets * */ /* * Copyright (c) 2015 ACLU * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PUBKEY_PINNING_H_ #define PUBKEY_PINNING_H_ /* create and populate a pinset linked list from a getdns_list pinset */ getdns_return_t _getdns_get_pubkey_pinset_from_list(const getdns_list *pinset_list, struct mem_funcs *mf, sha256_pin_t **pinset_out); /* create a getdns_list version of the pinset */ getdns_return_t _getdns_get_pubkey_pinset_list(getdns_context *ctx, const sha256_pin_t *pinset_in, getdns_list **pinset_list); /* internal functions for associating X.509 verification processes in * OpenSSL with getdns_upstream objects. */ getdns_upstream* _getdns_upstream_from_x509_store(X509_STORE_CTX *store); getdns_return_t _getdns_associate_upstream_with_SSL(SSL *ssl, getdns_upstream *upstream); getdns_return_t _getdns_verify_pinset_match(const sha256_pin_t *pinset, X509_STORE_CTX *store); #endif /* pubkey-pinning.h */ getdns-0.9.0/src/gldns/0000775000175100017510000000000012641212403011702 500000000000000getdns-0.9.0/src/gldns/rrdef.c0000664000175100017510000011675212641212403013104 00000000000000/* rrdef.c * * access functions to rr definitions list. * a Net::DNS like library for C * LibDNS Team @ NLnet Labs * * (c) NLnet Labs, 2004-2006 * See the file LICENSE for the license */ /** * \file * * Defines resource record types and constants. */ #include "config.h" #include "gldns/rrdef.h" #include "gldns/parseutil.h" #include /* classes */ static gldns_lookup_table gldns_rr_classes_data[] = { { GLDNS_RR_CLASS_IN, "IN" }, { GLDNS_RR_CLASS_CH, "CH" }, { GLDNS_RR_CLASS_HS, "HS" }, { GLDNS_RR_CLASS_NONE, "NONE" }, { GLDNS_RR_CLASS_ANY, "ANY" }, { 0, NULL } }; gldns_lookup_table* gldns_rr_classes = gldns_rr_classes_data; /* types */ static const gldns_rdf_type type_0_wireformat[] = { GLDNS_RDF_TYPE_UNKNOWN }; static const gldns_rdf_type type_a_wireformat[] = { GLDNS_RDF_TYPE_A }; static const gldns_rdf_type type_ns_wireformat[] = { GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_md_wireformat[] = { GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_mf_wireformat[] = { GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_cname_wireformat[] = { GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_soa_wireformat[] = { GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_INT32, GLDNS_RDF_TYPE_PERIOD, GLDNS_RDF_TYPE_PERIOD, GLDNS_RDF_TYPE_PERIOD, GLDNS_RDF_TYPE_PERIOD }; static const gldns_rdf_type type_mb_wireformat[] = { GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_mg_wireformat[] = { GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_mr_wireformat[] = { GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_wks_wireformat[] = { GLDNS_RDF_TYPE_A, GLDNS_RDF_TYPE_WKS }; static const gldns_rdf_type type_ptr_wireformat[] = { GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_hinfo_wireformat[] = { GLDNS_RDF_TYPE_STR, GLDNS_RDF_TYPE_STR }; static const gldns_rdf_type type_minfo_wireformat[] = { GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_mx_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_rp_wireformat[] = { GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_afsdb_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_x25_wireformat[] = { GLDNS_RDF_TYPE_STR }; static const gldns_rdf_type type_isdn_wireformat[] = { GLDNS_RDF_TYPE_STR, GLDNS_RDF_TYPE_STR }; static const gldns_rdf_type type_rt_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_nsap_wireformat[] = { GLDNS_RDF_TYPE_NSAP }; static const gldns_rdf_type type_nsap_ptr_wireformat[] = { GLDNS_RDF_TYPE_STR }; static const gldns_rdf_type type_sig_wireformat[] = { GLDNS_RDF_TYPE_TYPE, GLDNS_RDF_TYPE_ALG, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT32, GLDNS_RDF_TYPE_TIME, GLDNS_RDF_TYPE_TIME, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_B64 }; static const gldns_rdf_type type_key_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_B64 }; static const gldns_rdf_type type_px_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_gpos_wireformat[] = { GLDNS_RDF_TYPE_STR, GLDNS_RDF_TYPE_STR, GLDNS_RDF_TYPE_STR }; static const gldns_rdf_type type_aaaa_wireformat[] = { GLDNS_RDF_TYPE_AAAA }; static const gldns_rdf_type type_loc_wireformat[] = { GLDNS_RDF_TYPE_LOC }; static const gldns_rdf_type type_nxt_wireformat[] = { GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_UNKNOWN }; static const gldns_rdf_type type_eid_wireformat[] = { GLDNS_RDF_TYPE_HEX }; static const gldns_rdf_type type_nimloc_wireformat[] = { GLDNS_RDF_TYPE_HEX }; static const gldns_rdf_type type_srv_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_atma_wireformat[] = { GLDNS_RDF_TYPE_ATMA }; static const gldns_rdf_type type_naptr_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_STR, GLDNS_RDF_TYPE_STR, GLDNS_RDF_TYPE_STR, GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_kx_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_cert_wireformat[] = { GLDNS_RDF_TYPE_CERT_ALG, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_ALG, GLDNS_RDF_TYPE_B64 }; static const gldns_rdf_type type_a6_wireformat[] = { GLDNS_RDF_TYPE_UNKNOWN }; static const gldns_rdf_type type_dname_wireformat[] = { GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_sink_wireformat[] = { GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_B64 }; static const gldns_rdf_type type_apl_wireformat[] = { GLDNS_RDF_TYPE_APL }; static const gldns_rdf_type type_ds_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_ALG, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_HEX }; static const gldns_rdf_type type_sshfp_wireformat[] = { GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_HEX }; static const gldns_rdf_type type_ipseckey_wireformat[] = { GLDNS_RDF_TYPE_IPSECKEY }; static const gldns_rdf_type type_rrsig_wireformat[] = { GLDNS_RDF_TYPE_TYPE, GLDNS_RDF_TYPE_ALG, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT32, GLDNS_RDF_TYPE_TIME, GLDNS_RDF_TYPE_TIME, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_B64 }; static const gldns_rdf_type type_nsec_wireformat[] = { GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_NSEC }; static const gldns_rdf_type type_dhcid_wireformat[] = { GLDNS_RDF_TYPE_B64 }; static const gldns_rdf_type type_talink_wireformat[] = { GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_DNAME }; /* nsec3 is some vars, followed by same type of data of nsec */ static const gldns_rdf_type type_nsec3_wireformat[] = { /* GLDNS_RDF_TYPE_NSEC3_VARS, GLDNS_RDF_TYPE_NSEC3_NEXT_OWNER, GLDNS_RDF_TYPE_NSEC*/ GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_NSEC3_SALT, GLDNS_RDF_TYPE_NSEC3_NEXT_OWNER, GLDNS_RDF_TYPE_NSEC }; static const gldns_rdf_type type_nsec3param_wireformat[] = { /* GLDNS_RDF_TYPE_NSEC3_PARAMS_VARS*/ GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_NSEC3_SALT }; static const gldns_rdf_type type_dnskey_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_ALG, GLDNS_RDF_TYPE_B64 }; static const gldns_rdf_type type_tkey_wireformat[] = { GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_TIME, GLDNS_RDF_TYPE_TIME, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_INT16_DATA, GLDNS_RDF_TYPE_INT16_DATA, }; static const gldns_rdf_type type_tsig_wireformat[] = { GLDNS_RDF_TYPE_DNAME, GLDNS_RDF_TYPE_TSIGTIME, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_INT16_DATA, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_INT16_DATA }; static const gldns_rdf_type type_tlsa_wireformat[] = { GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_HEX }; static const gldns_rdf_type type_hip_wireformat[] = { GLDNS_RDF_TYPE_HIP }; static const gldns_rdf_type type_nid_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_ILNP64 }; static const gldns_rdf_type type_l32_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_A }; static const gldns_rdf_type type_l64_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_ILNP64 }; static const gldns_rdf_type type_lp_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_DNAME }; static const gldns_rdf_type type_eui48_wireformat[] = { GLDNS_RDF_TYPE_EUI48 }; static const gldns_rdf_type type_eui64_wireformat[] = { GLDNS_RDF_TYPE_EUI64 }; #ifdef DRAFT_RRTYPES static const gldns_rdf_type type_uri_wireformat[] = { GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_INT16, GLDNS_RDF_TYPE_LONG_STR }; #endif static const gldns_rdf_type type_caa_wireformat[] = { GLDNS_RDF_TYPE_INT8, GLDNS_RDF_TYPE_TAG, GLDNS_RDF_TYPE_LONG_STR }; /* All RR's defined in 1035 are well known and can thus * be compressed. See RFC3597. These RR's are: * CNAME HINFO MB MD MF MG MINFO MR MX NULL NS PTR SOA TXT */ static gldns_rr_descriptor rdata_field_descriptors[] = { /* 0 */ { 0, NULL, 0, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 1 */ {GLDNS_RR_TYPE_A, "A", 1, 1, type_a_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 2 */ {GLDNS_RR_TYPE_NS, "NS", 1, 1, type_ns_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_COMPRESS, 1 }, /* 3 */ {GLDNS_RR_TYPE_MD, "MD", 1, 1, type_md_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_COMPRESS, 1 }, /* 4 */ {GLDNS_RR_TYPE_MF, "MF", 1, 1, type_mf_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_COMPRESS, 1 }, /* 5 */ {GLDNS_RR_TYPE_CNAME, "CNAME", 1, 1, type_cname_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_COMPRESS, 1 }, /* 6 */ {GLDNS_RR_TYPE_SOA, "SOA", 7, 7, type_soa_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_COMPRESS, 2 }, /* 7 */ {GLDNS_RR_TYPE_MB, "MB", 1, 1, type_mb_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_COMPRESS, 1 }, /* 8 */ {GLDNS_RR_TYPE_MG, "MG", 1, 1, type_mg_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_COMPRESS, 1 }, /* 9 */ {GLDNS_RR_TYPE_MR, "MR", 1, 1, type_mr_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_COMPRESS, 1 }, /* 10 */ {GLDNS_RR_TYPE_NULL, "NULL", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 11 */ {GLDNS_RR_TYPE_WKS, "WKS", 2, 2, type_wks_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 12 */ {GLDNS_RR_TYPE_PTR, "PTR", 1, 1, type_ptr_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_COMPRESS, 1 }, /* 13 */ {GLDNS_RR_TYPE_HINFO, "HINFO", 2, 2, type_hinfo_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 14 */ {GLDNS_RR_TYPE_MINFO, "MINFO", 2, 2, type_minfo_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_COMPRESS, 2 }, /* 15 */ {GLDNS_RR_TYPE_MX, "MX", 2, 2, type_mx_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_COMPRESS, 1 }, /* 16 */ {GLDNS_RR_TYPE_TXT, "TXT", 1, 0, NULL, GLDNS_RDF_TYPE_STR, GLDNS_RR_NO_COMPRESS, 0 }, /* 17 */ {GLDNS_RR_TYPE_RP, "RP", 2, 2, type_rp_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 2 }, /* 18 */ {GLDNS_RR_TYPE_AFSDB, "AFSDB", 2, 2, type_afsdb_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* 19 */ {GLDNS_RR_TYPE_X25, "X25", 1, 1, type_x25_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 20 */ {GLDNS_RR_TYPE_ISDN, "ISDN", 1, 2, type_isdn_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 21 */ {GLDNS_RR_TYPE_RT, "RT", 2, 2, type_rt_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* 22 */ {GLDNS_RR_TYPE_NSAP, "NSAP", 1, 1, type_nsap_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 23 */ {GLDNS_RR_TYPE_NSAP_PTR, "NSAP-PTR", 1, 1, type_nsap_ptr_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 24 */ {GLDNS_RR_TYPE_SIG, "SIG", 9, 9, type_sig_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* 25 */ {GLDNS_RR_TYPE_KEY, "KEY", 4, 4, type_key_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 26 */ {GLDNS_RR_TYPE_PX, "PX", 3, 3, type_px_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 2 }, /* 27 */ {GLDNS_RR_TYPE_GPOS, "GPOS", 3, 3, type_gpos_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 28 */ {GLDNS_RR_TYPE_AAAA, "AAAA", 1, 1, type_aaaa_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 29 */ {GLDNS_RR_TYPE_LOC, "LOC", 1, 1, type_loc_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 30 */ {GLDNS_RR_TYPE_NXT, "NXT", 2, 2, type_nxt_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* 31 */ {GLDNS_RR_TYPE_EID, "EID", 1, 1, type_eid_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 32 */ {GLDNS_RR_TYPE_NIMLOC, "NIMLOC", 1, 1, type_nimloc_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 33 */ {GLDNS_RR_TYPE_SRV, "SRV", 4, 4, type_srv_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* 34 */ {GLDNS_RR_TYPE_ATMA, "ATMA", 1, 1, type_atma_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 35 */ {GLDNS_RR_TYPE_NAPTR, "NAPTR", 6, 6, type_naptr_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* 36 */ {GLDNS_RR_TYPE_KX, "KX", 2, 2, type_kx_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* 37 */ {GLDNS_RR_TYPE_CERT, "CERT", 4, 4, type_cert_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 38 */ {GLDNS_RR_TYPE_A6, "A6", 1, 1, type_a6_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 39 */ {GLDNS_RR_TYPE_DNAME, "DNAME", 1, 1, type_dname_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* 40 */ {GLDNS_RR_TYPE_SINK, "SINK", 1, 1, type_sink_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 41 */ {GLDNS_RR_TYPE_OPT, "OPT", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 42 */ {GLDNS_RR_TYPE_APL, "APL", 0, 0, type_apl_wireformat, GLDNS_RDF_TYPE_APL, GLDNS_RR_NO_COMPRESS, 0 }, /* 43 */ {GLDNS_RR_TYPE_DS, "DS", 4, 4, type_ds_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 44 */ {GLDNS_RR_TYPE_SSHFP, "SSHFP", 3, 3, type_sshfp_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 45 */ {GLDNS_RR_TYPE_IPSECKEY, "IPSECKEY", 1, 1, type_ipseckey_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 46 */ {GLDNS_RR_TYPE_RRSIG, "RRSIG", 9, 9, type_rrsig_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* 47 */ {GLDNS_RR_TYPE_NSEC, "NSEC", 1, 2, type_nsec_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* 48 */ {GLDNS_RR_TYPE_DNSKEY, "DNSKEY", 4, 4, type_dnskey_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 49 */ {GLDNS_RR_TYPE_DHCID, "DHCID", 1, 1, type_dhcid_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 50 */ {GLDNS_RR_TYPE_NSEC3, "NSEC3", 5, 6, type_nsec3_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 51 */ {GLDNS_RR_TYPE_NSEC3PARAM, "NSEC3PARAM", 4, 4, type_nsec3param_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 52 */ {GLDNS_RR_TYPE_TLSA, "TLSA", 4, 4, type_tlsa_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE53", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE54", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 55 * Hip ends with 0 or more Rendezvous Servers represented as dname's. * Hence the GLDNS_RDF_TYPE_DNAME _variable field and the _maximum field * set to 0. */ {GLDNS_RR_TYPE_HIP, "HIP", 1, 1, type_hip_wireformat, GLDNS_RDF_TYPE_DNAME, GLDNS_RR_NO_COMPRESS, 0 }, #ifdef DRAFT_RRTYPES /* 56 */ {GLDNS_RR_TYPE_NINFO, "NINFO", 1, 0, NULL, GLDNS_RDF_TYPE_STR, GLDNS_RR_NO_COMPRESS, 0 }, /* 57 */ {GLDNS_RR_TYPE_RKEY, "RKEY", 4, 4, type_key_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, #else {GLDNS_RR_TYPE_NULL, "TYPE56", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE57", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, #endif /* 58 */ {GLDNS_RR_TYPE_TALINK, "TALINK", 2, 2, type_talink_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 2 }, /* 59 */ {GLDNS_RR_TYPE_CDS, "CDS", 4, 4, type_ds_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 60 */ {GLDNS_RR_TYPE_CDNSKEY, "CDNSKEY", 4, 4, type_dnskey_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE61", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE62", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE63", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE64", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE65", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE66", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE67", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE68", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE69", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE70", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE71", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE72", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE73", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE74", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE75", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE76", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE77", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE78", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE79", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE80", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE81", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE82", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE83", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE84", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE85", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE86", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE87", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE88", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE89", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE90", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE91", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE92", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE93", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE94", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE95", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE96", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE97", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE98", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 99 */ {GLDNS_RR_TYPE_SPF, "SPF", 1, 0, NULL, GLDNS_RDF_TYPE_STR, GLDNS_RR_NO_COMPRESS, 0 }, /* UINFO [IANA-Reserved] */ {GLDNS_RR_TYPE_NULL, "TYPE100", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* UID [IANA-Reserved] */ {GLDNS_RR_TYPE_NULL, "TYPE101", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* GID [IANA-Reserved] */ {GLDNS_RR_TYPE_NULL, "TYPE102", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* UNSPEC [IANA-Reserved] */ {GLDNS_RR_TYPE_NULL, "TYPE103", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 104 */ {GLDNS_RR_TYPE_NID, "NID", 2, 2, type_nid_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 105 */ {GLDNS_RR_TYPE_L32, "L32", 2, 2, type_l32_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 106 */ {GLDNS_RR_TYPE_L64, "L64", 2, 2, type_l64_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 107 */ {GLDNS_RR_TYPE_LP, "LP", 2, 2, type_lp_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* 108 */ {GLDNS_RR_TYPE_EUI48, "EUI48", 1, 1, type_eui48_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* 109 */ {GLDNS_RR_TYPE_EUI64, "EUI64", 1, 1, type_eui64_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE110", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE111", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE112", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE113", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE114", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE115", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE116", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE117", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE118", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE119", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE120", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE121", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE122", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE123", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE124", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE125", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE126", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE127", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE128", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE129", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE130", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE131", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE132", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE133", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE134", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE135", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE136", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE137", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE138", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE139", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE140", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE141", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE142", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE143", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE144", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE145", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE146", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE147", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE148", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE149", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE150", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE151", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE152", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE153", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE154", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE155", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE156", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE157", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE158", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE159", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE160", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE161", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE162", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE163", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE164", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE165", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE166", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE167", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE168", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE169", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE170", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE171", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE172", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE173", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE174", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE175", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE176", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE177", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE178", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE179", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE180", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE181", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE182", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE183", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE184", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE185", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE186", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE187", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE188", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE189", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE190", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE191", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE192", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE193", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE194", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE195", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE196", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE197", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE198", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE199", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE200", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE201", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE202", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE203", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE204", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE205", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE206", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE207", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE208", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE209", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE210", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE211", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE212", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE213", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE214", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE215", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE216", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE217", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE218", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE219", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE220", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE221", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE222", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE223", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE224", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE225", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE226", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE227", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE228", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE229", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE230", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE231", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE232", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE233", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE234", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE235", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE236", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE237", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE238", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE239", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE240", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE241", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE242", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE243", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE244", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE245", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE246", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE247", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, {GLDNS_RR_TYPE_NULL, "TYPE248", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* GLDNS_RDF_TYPE_INT16_DATA takes two fields (length and data) as one. * So, unlike RFC 2930 spec, we have 7 min/max rdf's i.s.o. 8/9. */ /* 249 */ {GLDNS_RR_TYPE_TKEY, "TKEY", 7, 7, type_tkey_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* GLDNS_RDF_TYPE_INT16_DATA takes two fields (length and data) as one. * So, unlike RFC 2930 spec, we have 7 min/max rdf's i.s.o. 8/9. */ /* 250 */ {GLDNS_RR_TYPE_TSIG, "TSIG", 7, 7, type_tsig_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 1 }, /* IXFR: A request for a transfer of an incremental zone transfer */ {GLDNS_RR_TYPE_IXFR, "IXFR", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* AXFR: A request for a transfer of an entire zone */ {GLDNS_RR_TYPE_AXFR, "AXFR", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* MAILB: A request for mailbox-related records (MB, MG or MR) */ {GLDNS_RR_TYPE_MAILB, "MAILB", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* MAILA: A request for mail agent RRs (Obsolete - see MX) */ {GLDNS_RR_TYPE_MAILA, "MAILA", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* ANY: A request for all (available) records */ {GLDNS_RR_TYPE_ANY, "ANY", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, #ifdef DRAFT_RRTYPES /* 256 */ {GLDNS_RR_TYPE_URI, "URI", 3, 3, type_uri_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, #else {GLDNS_RR_TYPE_NULL, "TYPE256", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, #endif /* 257 */ {GLDNS_RR_TYPE_CAA, "CAA", 3, 3, type_caa_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, /* split in array, no longer contiguous */ #ifdef DRAFT_RRTYPES /* 32768 */ {GLDNS_RR_TYPE_TA, "TA", 4, 4, type_ds_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, #else {GLDNS_RR_TYPE_NULL, "TYPE32768", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 }, #endif /* 32769 */ {GLDNS_RR_TYPE_DLV, "DLV", 4, 4, type_ds_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 } }; /** * \def GLDNS_RDATA_FIELD_DESCRIPTORS_COUNT * computes the number of rdata fields */ #define GLDNS_RDATA_FIELD_DESCRIPTORS_COUNT \ (sizeof(rdata_field_descriptors)/sizeof(rdata_field_descriptors[0])) const gldns_rr_descriptor * gldns_rr_descript(uint16_t type) { size_t i; if (type < GLDNS_RDATA_FIELD_DESCRIPTORS_COMMON) { return &rdata_field_descriptors[type]; } else { /* because not all array index equals type code */ for (i = GLDNS_RDATA_FIELD_DESCRIPTORS_COMMON; i < GLDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) { if (rdata_field_descriptors[i]._type == type) { return &rdata_field_descriptors[i]; } } return &rdata_field_descriptors[0]; } } size_t gldns_rr_descriptor_minimum(const gldns_rr_descriptor *descriptor) { if (descriptor) { return descriptor->_minimum; } else { return 0; } } size_t gldns_rr_descriptor_maximum(const gldns_rr_descriptor *descriptor) { if (descriptor) { if (descriptor->_variable != GLDNS_RDF_TYPE_NONE) { return 65535; /* cannot be more than 64k */ } else { return descriptor->_maximum; } } else { return 0; } } gldns_rdf_type gldns_rr_descriptor_field_type(const gldns_rr_descriptor *descriptor, size_t index) { assert(descriptor != NULL); assert(index < descriptor->_maximum || descriptor->_variable != GLDNS_RDF_TYPE_NONE); if (index < descriptor->_maximum) { return descriptor->_wireformat[index]; } else { return descriptor->_variable; } } gldns_rr_type gldns_get_rr_type_by_name(const char *name) { unsigned int i; const char *desc_name; const gldns_rr_descriptor *desc; /* TYPEXX representation */ if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) { return atoi(name + 4); } /* Normal types */ for (i = 0; i < (unsigned int) GLDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) { desc = &rdata_field_descriptors[i]; desc_name = desc->_name; if(desc_name && strlen(name) == strlen(desc_name) && strncasecmp(name, desc_name, strlen(desc_name)) == 0) { /* because not all array index equals type code */ return desc->_type; } } /* special cases for query types */ if (strlen(name) == 4 && strncasecmp(name, "IXFR", 4) == 0) { return 251; } else if (strlen(name) == 4 && strncasecmp(name, "AXFR", 4) == 0) { return 252; } else if (strlen(name) == 5 && strncasecmp(name, "MAILB", 5) == 0) { return 253; } else if (strlen(name) == 5 && strncasecmp(name, "MAILA", 5) == 0) { return 254; } else if (strlen(name) == 3 && strncasecmp(name, "ANY", 3) == 0) { return 255; } return 0; } gldns_rr_class gldns_get_rr_class_by_name(const char *name) { gldns_lookup_table *lt; /* CLASSXX representation */ if (strlen(name) > 5 && strncasecmp(name, "CLASS", 5) == 0) { return atoi(name + 5); } /* Normal types */ lt = gldns_lookup_by_name(gldns_rr_classes, name); if (lt) { return lt->id; } return 0; } getdns-0.9.0/src/gldns/parse.c0000664000175100017510000002322612641212403013105 00000000000000/* * a generic (simple) parser. Use to parse rr's, private key * information and /etc/resolv.conf files * * a Net::DNS like library for C * LibDNS Team @ NLnet Labs * (c) NLnet Labs, 2005-2006 * See the file LICENSE for the license */ #include "config.h" #include "gldns/parse.h" #include "gldns/parseutil.h" #include "gldns/gbuffer.h" #include #include gldns_lookup_table gldns_directive_types[] = { { GLDNS_DIR_TTL, "$TTL" }, { GLDNS_DIR_ORIGIN, "$ORIGIN" }, { GLDNS_DIR_INCLUDE, "$INCLUDE" }, { 0, NULL } }; /* add max_limit here? */ ssize_t gldns_fget_token(FILE *f, char *token, const char *delim, size_t limit) { return gldns_fget_token_l(f, token, delim, limit, NULL); } ssize_t gldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *line_nr) { int c, prev_c; int p; /* 0 -> no parenthese seen, >0 nr of ( seen */ int com, quoted; char *t; size_t i; const char *d; const char *del; /* standard delimeters */ if (!delim) { /* from isspace(3) */ del = GLDNS_PARSE_NORMAL; } else { del = delim; } p = 0; i = 0; com = 0; quoted = 0; prev_c = 0; t = token; if (del[0] == '"') { quoted = 1; } while ((c = getc(f)) != EOF) { if (c == '\r') /* carriage return */ c = ' '; if (c == '(' && prev_c != '\\' && !quoted) { /* this only counts for non-comments */ if (com == 0) { p++; } prev_c = c; continue; } if (c == ')' && prev_c != '\\' && !quoted) { /* this only counts for non-comments */ if (com == 0) { p--; } prev_c = c; continue; } if (p < 0) { /* more ) then ( - close off the string */ *t = '\0'; return 0; } /* do something with comments ; */ if (c == ';' && quoted == 0) { if (prev_c != '\\') { com = 1; } } if (c == '\"' && com == 0 && prev_c != '\\') { quoted = 1 - quoted; } if (c == '\n' && com != 0) { /* comments */ com = 0; *t = ' '; if (line_nr) { *line_nr = *line_nr + 1; } if (p == 0 && i > 0) { goto tokenread; } else { prev_c = c; continue; } } if (com == 1) { *t = ' '; prev_c = c; continue; } if (c == '\n' && p != 0 && t > token) { /* in parentheses */ if (line_nr) { *line_nr = *line_nr + 1; } *t++ = ' '; prev_c = c; continue; } /* check if we hit the delim */ for (d = del; *d; d++) { if (c == *d && i > 0 && prev_c != '\\' && p == 0) { if (c == '\n' && line_nr) { *line_nr = *line_nr + 1; } goto tokenread; } } if (c != '\0' && c != '\n') { i++; } if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) { *t = '\0'; return -1; } if (c != '\0' && c != '\n') { *t++ = c; } if (c == '\\' && prev_c == '\\') prev_c = 0; else prev_c = c; } *t = '\0'; if (c == EOF) { return (ssize_t)i; } if (i == 0) { /* nothing read */ return -1; } if (p != 0) { return -1; } return (ssize_t)i; tokenread: if(*del == '"') /* do not skip over quotes after the string, they are part * of the next string. But skip over whitespace (if needed)*/ gldns_fskipcs_l(f, del+1, line_nr); else gldns_fskipcs_l(f, del, line_nr); *t = '\0'; if (p != 0) { return -1; } return (ssize_t)i; } ssize_t gldns_fget_keyword_data(FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit) { return gldns_fget_keyword_data_l(f, keyword, k_del, data, d_del, data_limit, NULL); } ssize_t gldns_fget_keyword_data_l(FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit, int *line_nr) { /* we assume: keyword|sep|data */ char *fkeyword; ssize_t i; if(strlen(keyword) >= GLDNS_MAX_KEYWORDLEN) return -1; fkeyword = (char*)malloc(GLDNS_MAX_KEYWORDLEN); if(!fkeyword) return -1; i = gldns_fget_token(f, fkeyword, k_del, GLDNS_MAX_KEYWORDLEN); if(i==0 || i==-1) { free(fkeyword); return -1; } /* case??? i instead of strlen? */ if (strncmp(fkeyword, keyword, GLDNS_MAX_KEYWORDLEN - 1) == 0) { /* whee! */ /* printf("%s\n%s\n", "Matching keyword", fkeyword); */ i = gldns_fget_token_l(f, data, d_del, data_limit, line_nr); free(fkeyword); return i; } else { /*printf("no match for %s (read: %s)\n", keyword, fkeyword);*/ free(fkeyword); return -1; } } int gldns_bgetc(gldns_buffer *buffer) { if (!gldns_buffer_available_at(buffer, buffer->_position, sizeof(uint8_t))) { gldns_buffer_set_position(buffer, gldns_buffer_limit(buffer)); /* gldns_buffer_rewind(buffer);*/ return EOF; } return (int)gldns_buffer_read_u8(buffer); } ssize_t gldns_bget_token(gldns_buffer *b, char *token, const char *delim, size_t limit) { return gldns_bget_token_par(b, token, delim, limit, NULL, NULL); } ssize_t gldns_bget_token_par(gldns_buffer *b, char *token, const char *delim, size_t limit, int* par, const char* skipw) { int c, lc; int p; /* 0 -> no parenthese seen, >0 nr of ( seen */ int com, quoted; char *t; size_t i; const char *d; const char *del; /* standard delimiters */ if (!delim) { /* from isspace(3) */ del = GLDNS_PARSE_NORMAL; } else { del = delim; } p = (par?*par:0); i = 0; com = 0; quoted = 0; t = token; lc = 0; if (del[0] == '"') { quoted = 1; } while ((c = gldns_bgetc(b)) != EOF) { if (c == '\r') /* carriage return */ c = ' '; if (c == '(' && lc != '\\' && !quoted) { /* this only counts for non-comments */ if (com == 0) { if(par) (*par)++; p++; } lc = c; continue; } if (c == ')' && lc != '\\' && !quoted) { /* this only counts for non-comments */ if (com == 0) { if(par) (*par)--; p--; } lc = c; continue; } if (p < 0) { /* more ) then ( */ *t = '\0'; return 0; } /* do something with comments ; */ if (c == ';' && quoted == 0) { if (lc != '\\') { com = 1; } } if (c == '"' && com == 0 && lc != '\\') { quoted = 1 - quoted; } if (c == '\n' && com != 0) { /* comments */ com = 0; *t = ' '; lc = c; continue; } if (com == 1) { *t = ' '; lc = c; continue; } if (c == '\n' && p != 0) { /* in parentheses */ /* do not write ' ' if we want to skip spaces */ if(!(skipw && (strchr(skipw, c)||strchr(skipw, ' ')))) *t++ = ' '; lc = c; continue; } /* check to skip whitespace at start, but also after ( */ if(skipw && i==0 && !com && !quoted && lc != '\\') { if(strchr(skipw, c)) { lc = c; continue; } } /* check if we hit the delim */ for (d = del; *d; d++) { /* we can only exit if no parens or user tracks them */ if (c == *d && lc != '\\' && (p == 0 || par)) { goto tokenread; } } i++; if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) { *t = '\0'; return -1; } *t++ = c; if (c == '\\' && lc == '\\') { lc = 0; } else { lc = c; } } *t = '\0'; if (i == 0) { /* nothing read */ return -1; } if (!par && p != 0) { return -1; } return (ssize_t)i; tokenread: if(*del == '"') /* do not skip over quotes after the string, they are part * of the next string. But skip over whitespace (if needed)*/ gldns_bskipcs(b, del+1); else gldns_bskipcs(b, del); *t = '\0'; if (!par && p != 0) { return -1; } return (ssize_t)i; } void gldns_bskipcs(gldns_buffer *buffer, const char *s) { int found; char c; const char *d; while(gldns_buffer_available_at(buffer, buffer->_position, sizeof(char))) { c = (char) gldns_buffer_read_u8_at(buffer, buffer->_position); found = 0; for (d = s; *d; d++) { if (*d == c) { found = 1; } } if (found && buffer->_limit > buffer->_position) { buffer->_position += sizeof(char); } else { return; } } } void gldns_fskipcs(FILE *fp, const char *s) { gldns_fskipcs_l(fp, s, NULL); } void gldns_fskipcs_l(FILE *fp, const char *s, int *line_nr) { int found; int c; const char *d; while ((c = fgetc(fp)) != EOF) { if (line_nr && c == '\n') { *line_nr = *line_nr + 1; } found = 0; for (d = s; *d; d++) { if (*d == c) { found = 1; } } if (!found) { /* with getc, we've read too far */ ungetc(c, fp); return; } } } ssize_t gldns_bget_keyword_data(gldns_buffer *b, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit) { /* we assume: keyword|sep|data */ char *fkeyword; ssize_t i; if(strlen(keyword) >= GLDNS_MAX_KEYWORDLEN) return -1; fkeyword = (char*)malloc(GLDNS_MAX_KEYWORDLEN); if(!fkeyword) return -1; /* out of memory */ i = gldns_bget_token(b, fkeyword, k_del, data_limit); if(i==0 || i==-1) { free(fkeyword); return -1; /* nothing read */ } /* case??? */ if (strncmp(fkeyword, keyword, strlen(keyword)) == 0) { free(fkeyword); /* whee, the match! */ /* retrieve it's data */ i = gldns_bget_token(b, data, d_del, 0); return i; } else { free(fkeyword); return -1; } } getdns-0.9.0/src/gldns/rrdef.h0000664000175100017510000003374712641212403013113 00000000000000/* * rrdef.h * * RR definitions * * a Net::DNS like library for C * * (c) NLnet Labs, 2005-2006 * * See the file LICENSE for the license */ /** * \file * * Defines resource record types and constants. */ #ifndef GLDNS_RRDEF_H #define GLDNS_RRDEF_H #ifdef __cplusplus extern "C" { #endif /** Maximum length of a dname label */ #define GLDNS_MAX_LABELLEN 63 /** Maximum length of a complete dname */ #define GLDNS_MAX_DOMAINLEN 255 /** Maximum number of pointers in 1 dname */ #define GLDNS_MAX_POINTERS 65535 /** The bytes TTL, CLASS and length use up in an rr */ #define GLDNS_RR_OVERHEAD 10 #define GLDNS_DNSSEC_KEYPROTO 3 #define GLDNS_KEY_ZONE_KEY 0x0100 /* set for ZSK&KSK, rfc 4034 */ #define GLDNS_KEY_SEP_KEY 0x0001 /* set for KSK, rfc 4034 */ #define GLDNS_KEY_REVOKE_KEY 0x0080 /* used to revoke KSK, rfc 5011 */ /* The first fields are contiguous and can be referenced instantly */ #define GLDNS_RDATA_FIELD_DESCRIPTORS_COMMON 258 /** lookuptable for rr classes */ extern struct gldns_struct_lookup_table* gldns_rr_classes; /** * The different RR classes. */ enum gldns_enum_rr_class { /** the Internet */ GLDNS_RR_CLASS_IN = 1, /** Chaos class */ GLDNS_RR_CLASS_CH = 3, /** Hesiod (Dyer 87) */ GLDNS_RR_CLASS_HS = 4, /** None class, dynamic update */ GLDNS_RR_CLASS_NONE = 254, /** Any class */ GLDNS_RR_CLASS_ANY = 255, GLDNS_RR_CLASS_FIRST = 0, GLDNS_RR_CLASS_LAST = 65535, GLDNS_RR_CLASS_COUNT = GLDNS_RR_CLASS_LAST - GLDNS_RR_CLASS_FIRST + 1 }; typedef enum gldns_enum_rr_class gldns_rr_class; /** * Used to specify whether compression is allowed. */ enum gldns_enum_rr_compress { /** compression is allowed */ GLDNS_RR_COMPRESS, GLDNS_RR_NO_COMPRESS }; typedef enum gldns_enum_rr_compress gldns_rr_compress; /** * The different RR types. */ enum gldns_enum_rr_type { /** a host address */ GLDNS_RR_TYPE_A = 1, /** an authoritative name server */ GLDNS_RR_TYPE_NS = 2, /** a mail destination (Obsolete - use MX) */ GLDNS_RR_TYPE_MD = 3, /** a mail forwarder (Obsolete - use MX) */ GLDNS_RR_TYPE_MF = 4, /** the canonical name for an alias */ GLDNS_RR_TYPE_CNAME = 5, /** marks the start of a zone of authority */ GLDNS_RR_TYPE_SOA = 6, /** a mailbox domain name (EXPERIMENTAL) */ GLDNS_RR_TYPE_MB = 7, /** a mail group member (EXPERIMENTAL) */ GLDNS_RR_TYPE_MG = 8, /** a mail rename domain name (EXPERIMENTAL) */ GLDNS_RR_TYPE_MR = 9, /** a null RR (EXPERIMENTAL) */ GLDNS_RR_TYPE_NULL = 10, /** a well known service description */ GLDNS_RR_TYPE_WKS = 11, /** a domain name pointer */ GLDNS_RR_TYPE_PTR = 12, /** host information */ GLDNS_RR_TYPE_HINFO = 13, /** mailbox or mail list information */ GLDNS_RR_TYPE_MINFO = 14, /** mail exchange */ GLDNS_RR_TYPE_MX = 15, /** text strings */ GLDNS_RR_TYPE_TXT = 16, /** RFC1183 */ GLDNS_RR_TYPE_RP = 17, /** RFC1183 */ GLDNS_RR_TYPE_AFSDB = 18, /** RFC1183 */ GLDNS_RR_TYPE_X25 = 19, /** RFC1183 */ GLDNS_RR_TYPE_ISDN = 20, /** RFC1183 */ GLDNS_RR_TYPE_RT = 21, /** RFC1706 */ GLDNS_RR_TYPE_NSAP = 22, /** RFC1348 */ GLDNS_RR_TYPE_NSAP_PTR = 23, /** 2535typecode */ GLDNS_RR_TYPE_SIG = 24, /** 2535typecode */ GLDNS_RR_TYPE_KEY = 25, /** RFC2163 */ GLDNS_RR_TYPE_PX = 26, /** RFC1712 */ GLDNS_RR_TYPE_GPOS = 27, /** ipv6 address */ GLDNS_RR_TYPE_AAAA = 28, /** LOC record RFC1876 */ GLDNS_RR_TYPE_LOC = 29, /** 2535typecode */ GLDNS_RR_TYPE_NXT = 30, /** draft-ietf-nimrod-dns-01.txt */ GLDNS_RR_TYPE_EID = 31, /** draft-ietf-nimrod-dns-01.txt */ GLDNS_RR_TYPE_NIMLOC = 32, /** SRV record RFC2782 */ GLDNS_RR_TYPE_SRV = 33, /** http://www.jhsoft.com/rfc/af-saa-0069.000.rtf */ GLDNS_RR_TYPE_ATMA = 34, /** RFC2915 */ GLDNS_RR_TYPE_NAPTR = 35, /** RFC2230 */ GLDNS_RR_TYPE_KX = 36, /** RFC2538 */ GLDNS_RR_TYPE_CERT = 37, /** RFC2874 */ GLDNS_RR_TYPE_A6 = 38, /** RFC2672 */ GLDNS_RR_TYPE_DNAME = 39, /** dnsind-kitchen-sink-02.txt */ GLDNS_RR_TYPE_SINK = 40, /** Pseudo OPT record... */ GLDNS_RR_TYPE_OPT = 41, /** RFC3123 */ GLDNS_RR_TYPE_APL = 42, /** RFC4034, RFC3658 */ GLDNS_RR_TYPE_DS = 43, /** SSH Key Fingerprint */ GLDNS_RR_TYPE_SSHFP = 44, /* RFC 4255 */ /** IPsec Key */ GLDNS_RR_TYPE_IPSECKEY = 45, /* RFC 4025 */ /** DNSSEC */ GLDNS_RR_TYPE_RRSIG = 46, /* RFC 4034 */ GLDNS_RR_TYPE_NSEC = 47, /* RFC 4034 */ GLDNS_RR_TYPE_DNSKEY = 48, /* RFC 4034 */ GLDNS_RR_TYPE_DHCID = 49, /* RFC 4701 */ /* NSEC3 */ GLDNS_RR_TYPE_NSEC3 = 50, /* RFC 5155 */ GLDNS_RR_TYPE_NSEC3PARAM = 51, /* RFC 5155 */ GLDNS_RR_TYPE_NSEC3PARAMS = 51, GLDNS_RR_TYPE_TLSA = 52, /* RFC 6698 */ GLDNS_RR_TYPE_HIP = 55, /* RFC 5205 */ /** draft-reid-dnsext-zs */ GLDNS_RR_TYPE_NINFO = 56, /** draft-reid-dnsext-rkey */ GLDNS_RR_TYPE_RKEY = 57, /** draft-ietf-dnsop-trust-history */ GLDNS_RR_TYPE_TALINK = 58, GLDNS_RR_TYPE_CDS = 59, /** RFC 7344 */ GLDNS_RR_TYPE_CDNSKEY = 60, /** RFC 7344 */ GLDNS_RR_TYPE_SPF = 99, /* RFC 4408 */ GLDNS_RR_TYPE_UINFO = 100, GLDNS_RR_TYPE_UID = 101, GLDNS_RR_TYPE_GID = 102, GLDNS_RR_TYPE_UNSPEC = 103, GLDNS_RR_TYPE_NID = 104, /* RFC 6742 */ GLDNS_RR_TYPE_L32 = 105, /* RFC 6742 */ GLDNS_RR_TYPE_L64 = 106, /* RFC 6742 */ GLDNS_RR_TYPE_LP = 107, /* RFC 6742 */ /** draft-jabley-dnsext-eui48-eui64-rrtypes */ GLDNS_RR_TYPE_EUI48 = 108, GLDNS_RR_TYPE_EUI64 = 109, GLDNS_RR_TYPE_TKEY = 249, /* RFC 2930 */ GLDNS_RR_TYPE_TSIG = 250, GLDNS_RR_TYPE_IXFR = 251, GLDNS_RR_TYPE_AXFR = 252, /** A request for mailbox-related records (MB, MG or MR) */ GLDNS_RR_TYPE_MAILB = 253, /** A request for mail agent RRs (Obsolete - see MX) */ GLDNS_RR_TYPE_MAILA = 254, /** any type (wildcard) */ GLDNS_RR_TYPE_ANY = 255, /** draft-faltstrom-uri-06 */ GLDNS_RR_TYPE_URI = 256, GLDNS_RR_TYPE_CAA = 257, /* RFC 6844 */ /** DNSSEC Trust Authorities */ GLDNS_RR_TYPE_TA = 32768, /* RFC 4431, 5074, DNSSEC Lookaside Validation */ GLDNS_RR_TYPE_DLV = 32769, /* type codes from nsec3 experimental phase GLDNS_RR_TYPE_NSEC3 = 65324, GLDNS_RR_TYPE_NSEC3PARAMS = 65325, */ GLDNS_RR_TYPE_FIRST = 0, GLDNS_RR_TYPE_LAST = 65535, GLDNS_RR_TYPE_COUNT = GLDNS_RR_TYPE_LAST - GLDNS_RR_TYPE_FIRST + 1 }; typedef enum gldns_enum_rr_type gldns_rr_type; /* RDATA */ #define GLDNS_MAX_RDFLEN 65535 #define GLDNS_RDF_SIZE_BYTE 1 #define GLDNS_RDF_SIZE_WORD 2 #define GLDNS_RDF_SIZE_DOUBLEWORD 4 #define GLDNS_RDF_SIZE_6BYTES 6 #define GLDNS_RDF_SIZE_8BYTES 8 #define GLDNS_RDF_SIZE_16BYTES 16 #define GLDNS_NSEC3_VARS_OPTOUT_MASK 0x01 #define GLDNS_APL_IP4 1 #define GLDNS_APL_IP6 2 #define GLDNS_APL_MASK 0x7f #define GLDNS_APL_NEGATION 0x80 /** * The different types of RDATA fields. */ enum gldns_enum_rdf_type { /** none */ GLDNS_RDF_TYPE_NONE, /** domain name */ GLDNS_RDF_TYPE_DNAME, /** 8 bits */ GLDNS_RDF_TYPE_INT8, /** 16 bits */ GLDNS_RDF_TYPE_INT16, /** 32 bits */ GLDNS_RDF_TYPE_INT32, /** A record */ GLDNS_RDF_TYPE_A, /** AAAA record */ GLDNS_RDF_TYPE_AAAA, /** txt string */ GLDNS_RDF_TYPE_STR, /** apl data */ GLDNS_RDF_TYPE_APL, /** b32 string */ GLDNS_RDF_TYPE_B32_EXT, /** b64 string */ GLDNS_RDF_TYPE_B64, /** hex string */ GLDNS_RDF_TYPE_HEX, /** nsec type codes */ GLDNS_RDF_TYPE_NSEC, /** a RR type */ GLDNS_RDF_TYPE_TYPE, /** a class */ GLDNS_RDF_TYPE_CLASS, /** certificate algorithm */ GLDNS_RDF_TYPE_CERT_ALG, /** a key algorithm */ GLDNS_RDF_TYPE_ALG, /** unknown types */ GLDNS_RDF_TYPE_UNKNOWN, /** time (32 bits) */ GLDNS_RDF_TYPE_TIME, /** period */ GLDNS_RDF_TYPE_PERIOD, /** tsig time 48 bits */ GLDNS_RDF_TYPE_TSIGTIME, /** Represents the Public Key Algorithm, HIT and Public Key fields for the HIP RR types. A HIP specific rdf type is used because of the unusual layout in wireformat (see RFC 5205 Section 5) */ GLDNS_RDF_TYPE_HIP, /** variable length any type rdata where the length is specified by the first 2 bytes */ GLDNS_RDF_TYPE_INT16_DATA, /** protocol and port bitmaps */ GLDNS_RDF_TYPE_SERVICE, /** location data */ GLDNS_RDF_TYPE_LOC, /** well known services */ GLDNS_RDF_TYPE_WKS, /** NSAP */ GLDNS_RDF_TYPE_NSAP, /** ATMA */ GLDNS_RDF_TYPE_ATMA, /** IPSECKEY */ GLDNS_RDF_TYPE_IPSECKEY, /** nsec3 hash salt */ GLDNS_RDF_TYPE_NSEC3_SALT, /** nsec3 base32 string (with length byte on wire */ GLDNS_RDF_TYPE_NSEC3_NEXT_OWNER, /** 4 shorts represented as 4 * 16 bit hex numbers * seperated by colons. For NID and L64. */ GLDNS_RDF_TYPE_ILNP64, /** 6 * 8 bit hex numbers seperated by dashes. For EUI48. */ GLDNS_RDF_TYPE_EUI48, /** 8 * 8 bit hex numbers seperated by dashes. For EUI64. */ GLDNS_RDF_TYPE_EUI64, /** A non-zero sequence of US-ASCII letters and numbers in lower case. * For CAA. */ GLDNS_RDF_TYPE_TAG, /** A encoding of the value field as specified * [RFC1035], Section 5.1., encoded as remaining rdata. * For CAA. */ GLDNS_RDF_TYPE_LONG_STR, /* Aliases */ GLDNS_RDF_TYPE_BITMAP = GLDNS_RDF_TYPE_NSEC }; typedef enum gldns_enum_rdf_type gldns_rdf_type; /** * Algorithms used in dns */ enum gldns_enum_algorithm { GLDNS_RSAMD5 = 1, /* RFC 4034,4035 */ GLDNS_DH = 2, GLDNS_DSA = 3, GLDNS_ECC = 4, GLDNS_RSASHA1 = 5, GLDNS_DSA_NSEC3 = 6, GLDNS_RSASHA1_NSEC3 = 7, GLDNS_RSASHA256 = 8, /* RFC 5702 */ GLDNS_RSASHA512 = 10, /* RFC 5702 */ GLDNS_ECC_GOST = 12, /* RFC 5933 */ GLDNS_ECDSAP256SHA256 = 13, /* RFC 6605 */ GLDNS_ECDSAP384SHA384 = 14, /* RFC 6605 */ GLDNS_INDIRECT = 252, GLDNS_PRIVATEDNS = 253, GLDNS_PRIVATEOID = 254 }; typedef enum gldns_enum_algorithm gldns_algorithm; /** * Hashing algorithms used in the DS record */ enum gldns_enum_hash { GLDNS_SHA1 = 1, /* RFC 4034 */ GLDNS_SHA256 = 2, /* RFC 4509 */ GLDNS_HASH_GOST = 3, /* RFC 5933 */ GLDNS_SHA384 = 4 /* RFC 6605 */ }; typedef enum gldns_enum_hash gldns_hash; /** * algorithms used in CERT rrs */ enum gldns_enum_cert_algorithm { GLDNS_CERT_PKIX = 1, GLDNS_CERT_SPKI = 2, GLDNS_CERT_PGP = 3, GLDNS_CERT_IPKIX = 4, GLDNS_CERT_ISPKI = 5, GLDNS_CERT_IPGP = 6, GLDNS_CERT_ACPKIX = 7, GLDNS_CERT_IACPKIX = 8, GLDNS_CERT_URI = 253, GLDNS_CERT_OID = 254 }; typedef enum gldns_enum_cert_algorithm gldns_cert_algorithm; /** * EDNS option codes */ enum gldns_enum_edns_option { GLDNS_EDNS_LLQ = 1, /* http://files.dns-sd.org/draft-sekar-dns-llq.txt */ GLDNS_EDNS_UL = 2, /* http://files.dns-sd.org/draft-sekar-dns-ul.txt */ GLDNS_EDNS_NSID = 3, /* RFC5001 */ /* 4 draft-cheshire-edns0-owner-option */ GLDNS_EDNS_DAU = 5, /* RFC6975 */ GLDNS_EDNS_DHU = 6, /* RFC6975 */ GLDNS_EDNS_N3U = 7, /* RFC6975 */ GLDNS_EDNS_CLIENT_SUBNET = 8, /* draft-vandergaast-edns-client-subnet */ GLDNS_EDNS_KEEPALIVE = 11 /* draft-ietf-dnsop-edns-tcp-keepalive*/ }; typedef enum gldns_enum_edns_option gldns_edns_option; #define GLDNS_EDNS_MASK_DO_BIT 0x8000 /** * Contains all information about resource record types. * * This structure contains, for all rr types, the rdata fields that are defined. */ struct gldns_struct_rr_descriptor { /** Type of the RR that is described here */ gldns_rr_type _type; /** Textual name of the RR type. */ const char *_name; /** Minimum number of rdata fields in the RRs of this type. */ uint8_t _minimum; /** Maximum number of rdata fields in the RRs of this type. */ uint8_t _maximum; /** Wireformat specification for the rr, i.e. the types of rdata fields in their respective order. */ const gldns_rdf_type *_wireformat; /** Special rdf types */ gldns_rdf_type _variable; /** Specifies whether compression can be used for dnames in this RR type. */ gldns_rr_compress _compress; /** The number of DNAMEs in the _wireformat string, for parsing. */ uint8_t _dname_count; }; typedef struct gldns_struct_rr_descriptor gldns_rr_descriptor; /** * returns the resource record descriptor for the given rr type. * * \param[in] type the type value of the rr type *\return the gldns_rr_descriptor for this type */ const gldns_rr_descriptor *gldns_rr_descript(uint16_t type); /** * returns the minimum number of rdata fields of the rr type this descriptor describes. * * \param[in] descriptor for an rr type * \return the minimum number of rdata fields */ size_t gldns_rr_descriptor_minimum(const gldns_rr_descriptor *descriptor); /** * returns the maximum number of rdata fields of the rr type this descriptor describes. * * \param[in] descriptor for an rr type * \return the maximum number of rdata fields */ size_t gldns_rr_descriptor_maximum(const gldns_rr_descriptor *descriptor); /** * returns the rdf type for the given rdata field number of the rr type for the given descriptor. * * \param[in] descriptor for an rr type * \param[in] field the field number * \return the rdf type for the field */ gldns_rdf_type gldns_rr_descriptor_field_type(const gldns_rr_descriptor *descriptor, size_t field); /** * retrieves a rrtype by looking up its name. * \param[in] name a string with the name * \return the type which corresponds with the name */ gldns_rr_type gldns_get_rr_type_by_name(const char *name); /** * retrieves a class by looking up its name. * \param[in] name string with the name * \return the cass which corresponds with the name */ gldns_rr_class gldns_get_rr_class_by_name(const char *name); #ifdef __cplusplus } #endif #endif /* GLDNS_RRDEF_H */ getdns-0.9.0/src/gldns/parseutil.c0000664000175100017510000004201312641212403013776 00000000000000/* * parseutil.c - parse utilities for string and wire conversion * * (c) NLnet Labs, 2004-2006 * * See the file LICENSE for the license */ /** * \file * * Utility functions for parsing, base32(DNS variant) and base64 encoding * and decoding, Hex, Time units, Escape codes. */ #include "config.h" #include "gldns/parseutil.h" #include #include #include #include gldns_lookup_table * gldns_lookup_by_name(gldns_lookup_table *table, const char *name) { while (table->name != NULL) { if (strcasecmp(name, table->name) == 0) return table; table++; } return NULL; } gldns_lookup_table * gldns_lookup_by_id(gldns_lookup_table *table, int id) { while (table->name != NULL) { if (table->id == id) return table; table++; } return NULL; } /* Number of days per month (except for February in leap years). */ static const int mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; #define GLDNS_MOD(x,y) (((x) % (y) < 0) ? ((x) % (y) + (y)) : ((x) % (y))) #define GLDNS_DIV(x,y) (((x) % (y) < 0) ? ((x) / (y) - 1 ) : ((x) / (y))) static int is_leap_year(int year) { return GLDNS_MOD(year, 4) == 0 && (GLDNS_MOD(year, 100) != 0 || GLDNS_MOD(year, 400) == 0); } static int leap_days(int y1, int y2) { --y1; --y2; return (GLDNS_DIV(y2, 4) - GLDNS_DIV(y1, 4)) - (GLDNS_DIV(y2, 100) - GLDNS_DIV(y1, 100)) + (GLDNS_DIV(y2, 400) - GLDNS_DIV(y1, 400)); } /* * Code adapted from Python 2.4.1 sources (Lib/calendar.py). */ time_t gldns_mktime_from_utc(const struct tm *tm) { int year = 1900 + tm->tm_year; time_t days = 365 * ((time_t) year - 1970) + leap_days(1970, year); time_t hours; time_t minutes; time_t seconds; int i; for (i = 0; i < tm->tm_mon; ++i) { days += mdays[i]; } if (tm->tm_mon > 1 && is_leap_year(year)) { ++days; } days += tm->tm_mday - 1; hours = days * 24 + tm->tm_hour; minutes = hours * 60 + tm->tm_min; seconds = minutes * 60 + tm->tm_sec; return seconds; } #if SIZEOF_TIME_T <= 4 static void gldns_year_and_yday_from_days_since_epoch(int64_t days, struct tm *result) { int year = 1970; int new_year; while (days < 0 || days >= (int64_t) (is_leap_year(year) ? 366 : 365)) { new_year = year + (int) GLDNS_DIV(days, 365); days -= (new_year - year) * 365; days -= leap_days(year, new_year); year = new_year; } result->tm_year = year; result->tm_yday = (int) days; } /* Number of days per month in a leap year. */ static const int leap_year_mdays[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static void gldns_mon_and_mday_from_year_and_yday(struct tm *result) { int idays = result->tm_yday; const int *mon_lengths = is_leap_year(result->tm_year) ? leap_year_mdays : mdays; result->tm_mon = 0; while (idays >= mon_lengths[result->tm_mon]) { idays -= mon_lengths[result->tm_mon++]; } result->tm_mday = idays + 1; } static void gldns_wday_from_year_and_yday(struct tm *result) { result->tm_wday = 4 /* 1-1-1970 was a thursday */ + GLDNS_MOD((result->tm_year - 1970), 7) * GLDNS_MOD(365, 7) + leap_days(1970, result->tm_year) + result->tm_yday; result->tm_wday = GLDNS_MOD(result->tm_wday, 7); if (result->tm_wday < 0) { result->tm_wday += 7; } } static struct tm * gldns_gmtime64_r(int64_t clock, struct tm *result) { result->tm_isdst = 0; result->tm_sec = (int) GLDNS_MOD(clock, 60); clock = GLDNS_DIV(clock, 60); result->tm_min = (int) GLDNS_MOD(clock, 60); clock = GLDNS_DIV(clock, 60); result->tm_hour = (int) GLDNS_MOD(clock, 24); clock = GLDNS_DIV(clock, 24); gldns_year_and_yday_from_days_since_epoch(clock, result); gldns_mon_and_mday_from_year_and_yday(result); gldns_wday_from_year_and_yday(result); result->tm_year -= 1900; return result; } #endif /* SIZEOF_TIME_T <= 4 */ static int64_t gldns_serial_arithmitics_time(int32_t time, time_t now) { int32_t offset = time - (int32_t) now; return (int64_t) now + offset; } struct tm * gldns_serial_arithmitics_gmtime_r(int32_t time, time_t now, struct tm *result) { #if SIZEOF_TIME_T <= 4 int64_t secs_since_epoch = gldns_serial_arithmitics_time(time, now); return gldns_gmtime64_r(secs_since_epoch, result); #else time_t secs_since_epoch = gldns_serial_arithmitics_time(time, now); return gmtime_r(&secs_since_epoch, result); #endif } int gldns_hexdigit_to_int(char ch) { switch (ch) { case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; case 'a': case 'A': return 10; case 'b': case 'B': return 11; case 'c': case 'C': return 12; case 'd': case 'D': return 13; case 'e': case 'E': return 14; case 'f': case 'F': return 15; default: return -1; } } uint32_t gldns_str2period(const char *nptr, const char **endptr) { int sign = 0; uint32_t i = 0; uint32_t seconds = 0; for(*endptr = nptr; **endptr; (*endptr)++) { switch (**endptr) { case ' ': case '\t': break; case '-': if(sign == 0) { sign = -1; } else { return seconds; } break; case '+': if(sign == 0) { sign = 1; } else { return seconds; } break; case 's': case 'S': seconds += i; i = 0; break; case 'm': case 'M': seconds += i * 60; i = 0; break; case 'h': case 'H': seconds += i * 60 * 60; i = 0; break; case 'd': case 'D': seconds += i * 60 * 60 * 24; i = 0; break; case 'w': case 'W': seconds += i * 60 * 60 * 24 * 7; i = 0; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': i *= 10; i += (**endptr - '0'); break; default: seconds += i; /* disregard signedness */ return seconds; } } seconds += i; /* disregard signedness */ return seconds; } int gldns_parse_escape(uint8_t *ch_p, const char** str_p) { uint16_t val; if ((*str_p)[0] && isdigit((*str_p)[0]) && (*str_p)[1] && isdigit((*str_p)[1]) && (*str_p)[2] && isdigit((*str_p)[2])) { val = (uint16_t)(((*str_p)[0] - '0') * 100 + ((*str_p)[1] - '0') * 10 + ((*str_p)[2] - '0')); if (val > 255) { goto error; } *ch_p = (uint8_t)val; *str_p += 3; return 1; } else if ((*str_p)[0] && !isdigit((*str_p)[0])) { *ch_p = (uint8_t)*(*str_p)++; return 1; } error: *str_p = NULL; return 0; /* GLDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE */ } /** parse one character, with escape codes */ int gldns_parse_char(uint8_t *ch_p, const char** str_p) { switch (**str_p) { case '\0': return 0; case '\\': *str_p += 1; return gldns_parse_escape(ch_p, str_p); default: *ch_p = (uint8_t)*(*str_p)++; return 1; } } size_t gldns_b32_ntop_calculate_size(size_t src_data_length) { return src_data_length == 0 ? 0 : ((src_data_length - 1) / 5 + 1) * 8; } size_t gldns_b32_ntop_calculate_size_no_padding(size_t src_data_length) { return ((src_data_length + 3) * 8 / 5) - 4; } static int gldns_b32_ntop_base(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz, int extended_hex, int add_padding) { size_t ret_sz; const char* b32 = extended_hex ? "0123456789abcdefghijklmnopqrstuv" : "abcdefghijklmnopqrstuvwxyz234567"; size_t c = 0; /* c is used to carry partial base32 character over * byte boundaries for sizes with a remainder. * (i.e. src_sz % 5 != 0) */ ret_sz = add_padding ? gldns_b32_ntop_calculate_size(src_sz) : gldns_b32_ntop_calculate_size_no_padding(src_sz); /* Do we have enough space? */ if (dst_sz < ret_sz + 1) return -1; /* We know the size; terminate the string */ dst[ret_sz] = '\0'; /* First process all chunks of five */ while (src_sz >= 5) { /* 00000... ........ ........ ........ ........ */ dst[0] = b32[(src[0] ) >> 3]; /* .....111 11...... ........ ........ ........ */ dst[1] = b32[(src[0] & 0x07) << 2 | src[1] >> 6]; /* ........ ..22222. ........ ........ ........ */ dst[2] = b32[(src[1] & 0x3e) >> 1]; /* ........ .......3 3333.... ........ ........ */ dst[3] = b32[(src[1] & 0x01) << 4 | src[2] >> 4]; /* ........ ........ ....4444 4....... ........ */ dst[4] = b32[(src[2] & 0x0f) << 1 | src[3] >> 7]; /* ........ ........ ........ .55555.. ........ */ dst[5] = b32[(src[3] & 0x7c) >> 2]; /* ........ ........ ........ ......66 666..... */ dst[6] = b32[(src[3] & 0x03) << 3 | src[4] >> 5]; /* ........ ........ ........ ........ ...77777 */ dst[7] = b32[(src[4] & 0x1f) ]; src_sz -= 5; src += 5; dst += 8; } /* Process what remains */ switch (src_sz) { case 4: /* ........ ........ ........ ......66 666..... */ dst[6] = b32[(src[3] & 0x03) << 3]; /* ........ ........ ........ .55555.. ........ */ dst[5] = b32[(src[3] & 0x7c) >> 2]; /* ........ ........ ....4444 4....... ........ */ c = src[3] >> 7 ; case 3: dst[4] = b32[(src[2] & 0x0f) << 1 | c]; /* ........ .......3 3333.... ........ ........ */ c = src[2] >> 4 ; case 2: dst[3] = b32[(src[1] & 0x01) << 4 | c]; /* ........ ..22222. ........ ........ ........ */ dst[2] = b32[(src[1] & 0x3e) >> 1]; /* .....111 11...... ........ ........ ........ */ c = src[1] >> 6 ; case 1: dst[1] = b32[(src[0] & 0x07) << 2 | c]; /* 00000... ........ ........ ........ ........ */ dst[0] = b32[ src[0] >> 3]; } /* Add padding */ if (add_padding) { switch (src_sz) { case 1: dst[2] = '='; dst[3] = '='; case 2: dst[4] = '='; case 3: dst[5] = '='; dst[6] = '='; case 4: dst[7] = '='; } } return (int)ret_sz; } int gldns_b32_ntop(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz) { return gldns_b32_ntop_base(src, src_sz, dst, dst_sz, 0, 1); } int gldns_b32_ntop_extended_hex(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz) { return gldns_b32_ntop_base(src, src_sz, dst, dst_sz, 1, 1); } size_t gldns_b32_pton_calculate_size(size_t src_text_length) { return src_text_length * 5 / 8; } static int gldns_b32_pton_base(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz, int extended_hex, int check_padding) { size_t i = 0; char ch = '\0'; uint8_t buf[8]; uint8_t* start = dst; while (src_sz) { /* Collect 8 characters in buf (if possible) */ for (i = 0; i < 8; i++) { do { ch = *src++; --src_sz; } while (isspace(ch) && src_sz > 0); if (ch == '=' || ch == '\0') break; else if (extended_hex) if (ch >= '0' && ch <= '9') buf[i] = (uint8_t)ch - '0'; else if (ch >= 'a' && ch <= 'v') buf[i] = (uint8_t)ch - 'a' + 10; else if (ch >= 'A' && ch <= 'V') buf[i] = (uint8_t)ch - 'A' + 10; else return -1; else if (ch >= 'a' && ch <= 'z') buf[i] = (uint8_t)ch - 'a'; else if (ch >= 'A' && ch <= 'Z') buf[i] = (uint8_t)ch - 'A'; else if (ch >= '2' && ch <= '7') buf[i] = (uint8_t)ch - '2' + 26; else return -1; } /* Less that 8 characters. We're done. */ if (i < 8) break; /* Enough space available at the destination? */ if (dst_sz < 5) return -1; /* 00000... ........ ........ ........ ........ */ /* .....111 11...... ........ ........ ........ */ dst[0] = buf[0] << 3 | buf[1] >> 2; /* .....111 11...... ........ ........ ........ */ /* ........ ..22222. ........ ........ ........ */ /* ........ .......3 3333.... ........ ........ */ dst[1] = buf[1] << 6 | buf[2] << 1 | buf[3] >> 4; /* ........ .......3 3333.... ........ ........ */ /* ........ ........ ....4444 4....... ........ */ dst[2] = buf[3] << 4 | buf[4] >> 1; /* ........ ........ ....4444 4....... ........ */ /* ........ ........ ........ .55555.. ........ */ /* ........ ........ ........ ......66 666..... */ dst[3] = buf[4] << 7 | buf[5] << 2 | buf[6] >> 3; /* ........ ........ ........ ......66 666..... */ /* ........ ........ ........ ........ ...77777 */ dst[4] = buf[6] << 5 | buf[7]; dst += 5; dst_sz -= 5; } /* Not ending on a eight byte boundary? */ if (i > 0 && i < 8) { /* Enough space available at the destination? */ if (dst_sz < (i + 1) / 2) return -1; switch (i) { case 7: /* ........ ........ ........ ......66 666..... */ /* ........ ........ ........ .55555.. ........ */ /* ........ ........ ....4444 4....... ........ */ dst[3] = buf[4] << 7 | buf[5] << 2 | buf[6] >> 3; case 5: /* ........ ........ ....4444 4....... ........ */ /* ........ .......3 3333.... ........ ........ */ dst[2] = buf[3] << 4 | buf[4] >> 1; case 4: /* ........ .......3 3333.... ........ ........ */ /* ........ ..22222. ........ ........ ........ */ /* .....111 11...... ........ ........ ........ */ dst[1] = buf[1] << 6 | buf[2] << 1 | buf[3] >> 4; case 2: /* .....111 11...... ........ ........ ........ */ /* 00000... ........ ........ ........ ........ */ dst[0] = buf[0] << 3 | buf[1] >> 2; break; default: return -1; } dst += (i + 1) / 2; if (check_padding) { /* Check remaining padding characters */ if (ch != '=') return -1; /* One down, 8 - i - 1 more to come... */ for (i = 8 - i - 1; i > 0; i--) { do { if (src_sz == 0) return -1; ch = *src++; src_sz--; } while (isspace(ch)); if (ch != '=') return -1; } } } return dst - start; } int gldns_b32_pton(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz) { return gldns_b32_pton_base(src, src_sz, dst, dst_sz, 0, 1); } int gldns_b32_pton_extended_hex(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz) { return gldns_b32_pton_base(src, src_sz, dst, dst_sz, 1, 1); } size_t gldns_b64_ntop_calculate_size(size_t srcsize) { return ((((srcsize + 2) / 3) * 4) + 1); } /* RFC 1521, section 5.2. * * The encoding process represents 24-bit groups of input bits as output * strings of 4 encoded characters. Proceeding from left to right, a * 24-bit input group is formed by concatenating 3 8-bit input groups. * These 24 bits are then treated as 4 concatenated 6-bit groups, each * of which is translated into a single digit in the base64 alphabet. * * This routine does not insert spaces or linebreaks after 76 characters. */ int gldns_b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) { const char* b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; const char pad64 = '='; size_t i = 0, o = 0; if(targsize < gldns_b64_ntop_calculate_size(srclength)) return -1; /* whole chunks: xxxxxxyy yyyyzzzz zzwwwwww */ while(i+3 <= srclength) { if(o+4 > targsize) return -1; target[o] = b64[src[i] >> 2]; target[o+1] = b64[ ((src[i]&0x03)<<4) | (src[i+1]>>4) ]; target[o+2] = b64[ ((src[i+1]&0x0f)<<2) | (src[i+2]>>6) ]; target[o+3] = b64[ (src[i+2]&0x3f) ]; i += 3; o += 4; } /* remainder */ switch(srclength - i) { case 2: /* two at end, converted into A B C = */ target[o] = b64[src[i] >> 2]; target[o+1] = b64[ ((src[i]&0x03)<<4) | (src[i+1]>>4) ]; target[o+2] = b64[ ((src[i+1]&0x0f)<<2) ]; target[o+3] = pad64; i += 2; o += 4; break; case 1: /* one at end, converted into A B = = */ target[o] = b64[src[i] >> 2]; target[o+1] = b64[ ((src[i]&0x03)<<4) ]; target[o+2] = pad64; target[o+3] = pad64; i += 1; o += 4; break; case 0: default: /* nothing */ break; } /* assert: i == srclength */ if(o+1 > targsize) return -1; target[o] = 0; return (int)o; } size_t gldns_b64_pton_calculate_size(size_t srcsize) { return (((((srcsize + 3) / 4) * 3)) + 1); } int gldns_b64_pton(char const *src, uint8_t *target, size_t targsize) { const uint8_t pad64 = 64; /* is 64th in the b64 array */ const char* s = src; uint8_t in[4]; size_t o = 0, incount = 0; while(*s) { /* skip any character that is not base64 */ /* conceptually we do: const char* b64 = pad'=' is appended to array "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; const char* d = strchr(b64, *s++); and use d-b64; */ char d = *s++; if(d <= 'Z' && d >= 'A') d -= 'A'; else if(d <= 'z' && d >= 'a') d = d - 'a' + 26; else if(d <= '9' && d >= '0') d = d - '0' + 52; else if(d == '+') d = 62; else if(d == '/') d = 63; else if(d == '=') d = 64; else continue; in[incount++] = (uint8_t)d; if(incount != 4) continue; /* process whole block of 4 characters into 3 output bytes */ if(in[3] == pad64 && in[2] == pad64) { /* A B = = */ if(o+1 > targsize) return -1; target[o] = (in[0]<<2) | ((in[1]&0x30)>>4); o += 1; break; /* we are done */ } else if(in[3] == pad64) { /* A B C = */ if(o+2 > targsize) return -1; target[o] = (in[0]<<2) | ((in[1]&0x30)>>4); target[o+1]= ((in[1]&0x0f)<<4) | ((in[2]&0x3c)>>2); o += 2; break; /* we are done */ } else { if(o+3 > targsize) return -1; /* write xxxxxxyy yyyyzzzz zzwwwwww */ target[o] = (in[0]<<2) | ((in[1]&0x30)>>4); target[o+1]= ((in[1]&0x0f)<<4) | ((in[2]&0x3c)>>2); target[o+2]= ((in[2]&0x03)<<6) | in[3]; o += 3; } incount = 0; } return (int)o; } getdns-0.9.0/src/gldns/wire2str.h0000664000175100017510000011254012641212403013557 00000000000000/** * wire2str.h - txt presentation of RRs * * (c) NLnet Labs, 2005-2006 * * See the file LICENSE for the license */ /** * \file * * Contains functions to translate the wireformat to text * representation, as well as functions to print them. */ #ifndef GLDNS_WIRE2STR_H #define GLDNS_WIRE2STR_H #ifdef __cplusplus extern "C" { #endif struct gldns_struct_lookup_table; /* lookup tables for standard DNS stuff */ /** Taken from RFC 2535, section 7. */ extern struct gldns_struct_lookup_table* gldns_algorithms; /** DS record hash algorithms */ extern struct gldns_struct_lookup_table* gldns_hashes; /** Taken from RFC 2538, section 2.1. */ extern struct gldns_struct_lookup_table* gldns_cert_algorithms; /** Response codes */ extern struct gldns_struct_lookup_table* gldns_rcodes; /** Operation codes */ extern struct gldns_struct_lookup_table* gldns_opcodes; /** EDNS flags */ extern struct gldns_struct_lookup_table* gldns_edns_flags; /** EDNS option codes */ extern struct gldns_struct_lookup_table* gldns_edns_options; /** error string from wireparse */ extern struct gldns_struct_lookup_table* gldns_wireparse_errors; /** * Convert wireformat packet to a string representation * @param data: wireformat packet data (starting at ID bytes). * @param len: length of packet. * @return string(malloced) or NULL on failure. */ char* gldns_wire2str_pkt(uint8_t* data, size_t len); /** * Convert wireformat RR to a string representation. * @param rr: the wireformat RR, in uncompressed form. Starts at the domain * name start, ends with the rdata of the RR. * @param len: length of the rr wireformat. * @return string(malloced) or NULL on failure. */ char* gldns_wire2str_rr(uint8_t* rr, size_t len); /** * Conver wire dname to a string. * @param dname: the dname in uncompressed wireformat. * @param dname_len: length of the dname. * @return string or NULL on failure. */ char* gldns_wire2str_dname(uint8_t* dname, size_t dname_len); /** * Convert wire RR type to a string, 'MX', 'TYPE1234'... * @param rrtype: the RR type in host order. * @return malloced string with the RR type or NULL on malloc failure. */ char* gldns_wire2str_type(uint16_t rrtype); /** * Convert wire RR class to a string, 'IN', 'CLASS1'. * @param rrclass: the RR class in host order. * @return malloced string with the RR class or NULL on malloc failure. */ char* gldns_wire2str_class(uint16_t rrclass); /** * Convert wire packet rcode to a string, 'NOERROR', 'NXDOMAIN'... * @param rcode: as integer, host order * @return malloced string with the rcode or NULL on malloc failure. */ char* gldns_wire2str_rcode(int rcode); /** * Print to string, move string along for next content. With va_list. * @param str: string buffer. Adjusted at end to after the output. * @param slen: length of the string buffer. Adjusted at end. * @param format: printf format string. * @param args: arguments for printf. * @return number of characters needed. Can be larger than slen. */ int gldns_str_vprint(char** str, size_t* slen, const char* format, va_list args); /** * Print to string, move string along for next content. * @param str: string buffer. Adjusted at end to after the output. * @param slen: length of the string buffer. Adjusted at end. * @param format: printf format string and arguments for it. * @return number of characters needed. Can be larger than slen. */ int gldns_str_print(char** str, size_t* slen, const char* format, ...) ATTR_FORMAT(printf, 3, 4); /** * Convert wireformat packet to a string representation with user buffer * It appends every RR with default comments. * For more formatter options use the function: TBD(TODO) * @param data: wireformat packet data (starting at ID bytes). * @param data_len: length of packet. * @param str: the string buffer for the output. * If you pass NULL as the str the return value of the function is * the str_len you need for the entire packet. It does not include * the 0 byte at the end. * @param str_len: the size of the string buffer. If more is needed, it'll * silently truncate the output to fit in the buffer. * @return the number of characters for this element, excluding zerobyte. * Is larger than str_len if output was truncated. */ int gldns_wire2str_pkt_buf(uint8_t* data, size_t data_len, char* str, size_t str_len); /** * Scan wireformat packet to a string representation with user buffer * It appends every RR with default comments. * For more formatter options use the function: TBD(TODO) * @param data: wireformat packet data (starting at ID bytes). * @param data_len: length of packet. * @param str: the string buffer for the output. * @param str_len: the size of the string buffer. * @return number of characters for string. * returns the number of characters that are needed (except terminating null), * so it may return a value larger than str_len. * On error you get less output (i.e. shorter output in str (null terminated)) * On exit the data, data_len, str and str_len values are adjusted to move them * from their original position along the input and output for the content * that has been consumed (and produced) by this function. If the end of the * output string is reached, *str_len is set to 0. The output string is null * terminated (shortening the output if necessary). If the end of the input * is reached *data_len is set to 0. */ int gldns_wire2str_pkt_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat rr to string, with user buffers. It shifts the arguments * to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @param pkt: packet for decompression, if NULL no decompression. * @param pktlen: length of packet buffer. * @return number of characters (except null) needed to print. */ int gldns_wire2str_rr_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len, uint8_t* pkt, size_t pktlen); /** * Scan wireformat question rr to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @param pkt: packet for decompression, if NULL no decompression. * @param pktlen: length of packet buffer. * @return number of characters (except null) needed to print. */ int gldns_wire2str_rrquestion_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len, uint8_t* pkt, size_t pktlen); /** * Scan wireformat RR to string in unknown RR format, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @param pkt: packet for decompression, if NULL no decompression. * @param pktlen: length of packet buffer. * @return number of characters (except null) needed to print. */ int gldns_wire2str_rr_unknown_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len, uint8_t* pkt, size_t pktlen); /** * Print to string the RR-information comment in default format, * with user buffers. Moves string along. * @param str: string buffer. * @param str_len: length of string buffer. * @param rr: wireformat data. * @param rrlen: length of data buffer. * @param dname_off: offset in buffer behind owner dname, the compressed size * of the owner name. * @param rrtype: type of the RR, host format. * @return number of characters (except null) needed to print. */ int gldns_wire2str_rr_comment_print(char** str, size_t* str_len, uint8_t* rr, size_t rrlen, size_t dname_off, uint16_t rrtype); /** * Scan wireformat packet header to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. */ int gldns_wire2str_header_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat rdata to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. The length of the rdata in the * buffer. The rdatalen itself has already been scanned, the data * points to the rdata after the rdatalen. * @param str: string buffer. * @param str_len: length of string buffer. * @param rrtype: RR type of Rdata, host format. * @param pkt: packet for decompression, if NULL no decompression. * @param pktlen: length of packet buffer. * @return number of characters (except null) needed to print. */ int gldns_wire2str_rdata_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len, uint16_t rrtype, uint8_t* pkt, size_t pktlen); /** * Scan wireformat rdata to string in unknown format, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer, the length of the rdata in buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. */ int gldns_wire2str_rdata_unknown_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat domain name to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @param pkt: packet for decompression, if NULL no decompression. * @param pktlen: length of packet buffer. * @return number of characters (except null) needed to print. */ int gldns_wire2str_dname_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len, uint8_t* pkt, size_t pktlen); /** * Scan wireformat rr type to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. */ int gldns_wire2str_type_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat rr class to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. */ int gldns_wire2str_class_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat rr ttl to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. */ int gldns_wire2str_ttl_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Print host format rr type to string. Moves string along, user buffers. * @param str: string buffer. * @param str_len: length of string buffer. * @param rrtype: host format rr type. * @return number of characters (except null) needed to print. */ int gldns_wire2str_type_print(char** str, size_t* str_len, uint16_t rrtype); /** * Print host format rr class to string. Moves string along, user buffers. * @param str: string buffer. * @param str_len: length of string buffer. * @param rrclass: host format rr class. * @return number of characters (except null) needed to print. */ int gldns_wire2str_class_print(char** str, size_t* str_len, uint16_t rrclass); /** * Print host format rcode to string. Moves string along, user buffers. * @param str: string buffer. * @param str_len: length of string buffer. * @param rcode: host format rcode number. * @return number of characters (except null) needed to print. */ int gldns_wire2str_rcode_print(char** str, size_t* str_len, int rcode); /** * Print host format opcode to string. Moves string along, user buffers. * @param str: string buffer. * @param str_len: length of string buffer. * @param opcode: host format opcode number. * @return number of characters (except null) needed to print. */ int gldns_wire2str_opcode_print(char** str, size_t* str_len, int opcode); /** * Print host format EDNS0 option to string. Moves string along, user buffers. * @param str: string buffer. * @param str_len: length of string buffer. * @param opcode: host format option number. * @return number of characters (except null) needed to print. */ int gldns_wire2str_edns_option_code_print(char** str, size_t* str_len, uint16_t opcode); /** * Convert RR to string presentation format, on one line. User buffer. * @param rr: wireformat RR data * @param rr_len: length of the rr wire data. * @param str: the string buffer to write to. * If you pass NULL as the str, the return value of the function is * the str_len you need for the entire packet. It does not include * the 0 byte at the end. * @param str_len: the size of the string buffer. If more is needed, it'll * silently truncate the output to fit in the buffer. * @return the number of characters for this element, excluding zerobyte. * Is larger than str_len if output was truncated. */ int gldns_wire2str_rr_buf(uint8_t* rr, size_t rr_len, char* str, size_t str_len); /** * 3597 printout of an RR in unknown rr format. * There are more format and comment options available for printout * with the function: TBD(TODO) * @param rr: wireformat RR data * @param rr_len: length of the rr wire data. * @param str: the string buffer to write to. * If you pass NULL as the str, the return value of the function is * the str_len you need for the entire rr. It does not include * the 0 byte at the end. * @param str_len: the size of the string buffer. If more is needed, it'll * silently truncate the output to fit in the buffer. * @return the number of characters for this element, excluding zerobyte. * Is larger than str_len if output was truncated. */ int gldns_wire2str_rr_unknown_buf(uint8_t* rr, size_t rr_len, char* str, size_t str_len); /** * This creates the comment to print after the RR. ; keytag=... , and other * basic comments for RRs. * There are more format and comment options available for printout * with the function: TBD(TODO) * @param rr: wireformat RR data * @param rr_len: length of the rr wire data. * @param dname_len: length of the dname in front of the RR. * @param str: the string buffer to write to. * If you pass NULL as the str, the return value of the function is * the str_len you need for the entire comment. It does not include * the 0 byte at the end. * @param str_len: the size of the string buffer. If more is needed, it'll * silently truncate the output to fit in the buffer. * @return the number of characters for this element, excluding zerobyte. * Is larger than str_len if output was truncated. */ int gldns_wire2str_rr_comment_buf(uint8_t* rr, size_t rr_len, size_t dname_len, char* str, size_t str_len); /** * Convert RDATA to string presentation format, on one line. User buffer. * @param rdata: wireformat rdata part of an RR. * @param rdata_len: length of the rr wire data. * @param str: the string buffer to write to. * If you pass NULL as the str, the return value of the function is * the str_len you need for the entire packet. It does not include * the 0 byte at the end. * @param str_len: the size of the string buffer. If more is needed, it'll * silently truncate the output to fit in the buffer. * @param rrtype: rr type of the data * @return the number of characters for this element, excluding zerobyte. * Is larger than str_len if output was truncated. */ int gldns_wire2str_rdata_buf(uint8_t* rdata, size_t rdata_len, char* str, size_t str_len, uint16_t rrtype); /** * Convert wire RR type to a string, 'MX', 'TYPE12'. With user buffer. * @param rrtype: the RR type in host order. * @param str: the string to write to. * @param len: length of str. * @return the number of characters for this element, excluding zerobyte. * Is larger than str_len if output was truncated. */ int gldns_wire2str_type_buf(uint16_t rrtype, char* str, size_t len); /** * Convert wire RR class to a string, 'IN', 'CLASS12'. With user buffer. * @param rrclass: the RR class in host order. * @param str: the string to write to. * @param len: length of str. * @return the number of characters for this element, excluding zerobyte. * Is larger than str_len if output was truncated. */ int gldns_wire2str_class_buf(uint16_t rrclass, char* str, size_t len); /** * Convert wire RR rcode to a string, 'NOERROR', 'NXDOMAIN'. With user buffer. * @param rcode: rcode as integer in host order * @param str: the string to write to. * @param len: length of str. * @return the number of characters for this element, excluding zerobyte. * Is larger than str_len if output was truncated. */ int gldns_wire2str_rcode_buf(int rcode, char* str, size_t len); /** * Convert wire dname to a string, "example.com.". With user buffer. * @param dname: the dname in uncompressed wireformat. * @param dname_len: length of the dname. * @param str: the string to write to. * @param len: length of string. * @return the number of characters for this element, excluding zerobyte. * Is larger than str_len if output was truncated. */ int gldns_wire2str_dname_buf(uint8_t* dname, size_t dname_len, char* str, size_t len); /** * Scan wireformat rdf field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @param rdftype: the type of the rdata field, enum gldns_rdf_type. * @param pkt: packet for decompression, if NULL no decompression. * @param pktlen: length of packet buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_rdf_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len, int rdftype, uint8_t* pkt, size_t pktlen); /** * Scan wireformat int8 field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_int8_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat int16 field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_int16_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat int32 field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_int32_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat period field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_period_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat tsigtime field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_tsigtime_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat ip4 A field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_a_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat ip6 AAAA field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_aaaa_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat str field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_str_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat apl field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_apl_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat b32_ext field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_b32_ext_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat b64 field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_b64_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat hex field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_hex_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat nsec bitmap field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_nsec_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat nsec3_salt field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_nsec3_salt_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat cert_alg field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_cert_alg_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat alg field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_alg_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat type unknown field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_unknown_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat time field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_time_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat LOC field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_loc_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat WKS field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_wks_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat NSAP field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_nsap_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat ATMA field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_atma_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat IPSECKEY field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @param pkt: packet for decompression, if NULL no decompression. * @param pktlen: length of packet buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_ipseckey_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len, uint8_t* pkt, size_t pktlen); /** * Scan wireformat HIP (algo, HIT, pubkey) field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_hip_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat int16_data field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_int16_data_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat nsec3_next_owner field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_nsec3_next_owner_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat ILNP64 field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_ilnp64_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat EUI48 field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_eui48_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat EUI64 field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_eui64_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat TAG field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_tag_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Scan wireformat long_str field to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @return number of characters (except null) needed to print. * Can return -1 on failure. */ int gldns_wire2str_long_str_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len); /** * Print EDNS LLQ option data to string. User buffers, moves string pointers. * @param str: string buffer. * @param str_len: length of string buffer. * @param option_data: buffer with EDNS option code data. * @param option_len: length of the data for this option. * @return number of characters (except null) needed to print. */ int gldns_wire2str_edns_llq_print(char** str, size_t* str_len, uint8_t* option_data, size_t option_len); /** * Print EDNS UL option data to string. User buffers, moves string pointers. * @param str: string buffer. * @param str_len: length of string buffer. * @param option_data: buffer with EDNS option code data. * @param option_len: length of the data for this option. * @return number of characters (except null) needed to print. */ int gldns_wire2str_edns_ul_print(char** str, size_t* str_len, uint8_t* option_data, size_t option_len); /** * Print EDNS NSID option data to string. User buffers, moves string pointers. * @param str: string buffer. * @param str_len: length of string buffer. * @param option_data: buffer with EDNS option code data. * @param option_len: length of the data for this option. * @return number of characters (except null) needed to print. */ int gldns_wire2str_edns_nsid_print(char** str, size_t* str_len, uint8_t* option_data, size_t option_len); /** * Print EDNS DAU option data to string. User buffers, moves string pointers. * @param str: string buffer. * @param str_len: length of string buffer. * @param option_data: buffer with EDNS option code data. * @param option_len: length of the data for this option. * @return number of characters (except null) needed to print. */ int gldns_wire2str_edns_dau_print(char** str, size_t* str_len, uint8_t* option_data, size_t option_len); /** * Print EDNS DHU option data to string. User buffers, moves string pointers. * @param str: string buffer. * @param str_len: length of string buffer. * @param option_data: buffer with EDNS option code data. * @param option_len: length of the data for this option. * @return number of characters (except null) needed to print. */ int gldns_wire2str_edns_dhu_print(char** str, size_t* str_len, uint8_t* option_data, size_t option_len); /** * Print EDNS N3U option data to string. User buffers, moves string pointers. * @param str: string buffer. * @param str_len: length of string buffer. * @param option_data: buffer with EDNS option code data. * @param option_len: length of the data for this option. * @return number of characters (except null) needed to print. */ int gldns_wire2str_edns_n3u_print(char** str, size_t* str_len, uint8_t* option_data, size_t option_len); /** * Print EDNS SUBNET option data to string. User buffers, moves string pointers. * @param str: string buffer. * @param str_len: length of string buffer. * @param option_data: buffer with EDNS option code data. * @param option_len: length of the data for this option. * @return number of characters (except null) needed to print. */ int gldns_wire2str_edns_subnet_print(char** str, size_t* str_len, uint8_t* option_data, size_t option_len); /** * Print an EDNS option as OPT: VALUE. User buffers, moves string pointers. * @param str: string buffer. * @param str_len: length of string buffer. * @param option_code: host format EDNS option code. * @param option_data: buffer with EDNS option code data. * @param option_len: length of the data for this option. * @return number of characters (except null) needed to print. */ int gldns_wire2str_edns_option_print(char** str, size_t* str_len, uint16_t option_code, uint8_t* option_data, size_t option_len); /** * Scan wireformat EDNS OPT to string, with user buffers. * It shifts the arguments to move along (see gldns_wire2str_pkt_scan). * @param data: wireformat data. * @param data_len: length of data buffer. * @param str: string buffer. * @param str_len: length of string buffer. * @param pkt: packet with header and other info (may be NULL) * @param pktlen: length of packet buffer. * @return number of characters (except null) needed to print. */ int gldns_wire2str_edns_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len, uint8_t* pkt, size_t pktlen); #ifdef __cplusplus } #endif #endif /* GLDNS_WIRE2STR_H */ getdns-0.9.0/src/gldns/keyraw.h0000664000175100017510000000631112641212403013276 00000000000000/* * keyraw.h -- raw key and signature access and conversion * * Copyright (c) 2005-2008, NLnet Labs. All rights reserved. * * See LICENSE for the license. * */ /** * \file * * raw key and signature access and conversion * * Since those functions heavily rely op cryptographic operations, * this module is dependent on openssl. * */ #ifndef GLDNS_KEYRAW_H #define GLDNS_KEYRAW_H #ifdef __cplusplus extern "C" { #endif #if GLDNS_BUILD_CONFIG_HAVE_SSL # include # include #endif /* GLDNS_BUILD_CONFIG_HAVE_SSL */ /** * get the length of the keydata in bits * \param[in] keydata the raw key data * \param[in] len the length of the keydata * \param[in] alg the cryptographic algorithm this is a key for * \return the keysize in bits, or 0 on error */ size_t gldns_rr_dnskey_key_size_raw(const unsigned char *keydata, const size_t len, int alg); /** * Calculates keytag of DNSSEC key, operates on wireformat rdata. * \param[in] key the key as uncompressed wireformat rdata. * \param[in] keysize length of key data. * \return the keytag */ uint16_t gldns_calc_keytag_raw(uint8_t* key, size_t keysize); #if GLDNS_BUILD_CONFIG_HAVE_SSL /** * Get the PKEY id for GOST, loads GOST into openssl as a side effect. * Only available if GOST is compiled into the library and openssl. * \return the gost id for EVP_CTX creation. */ int gldns_key_EVP_load_gost_id(void); /** Release the engine reference held for the GOST engine. */ void gldns_key_EVP_unload_gost(void); /** * Like gldns_key_buf2dsa, but uses raw buffer. * \param[in] key the uncompressed wireformat of the key. * \param[in] len length of key data * \return a DSA * structure with the key material */ DSA *gldns_key_buf2dsa_raw(unsigned char* key, size_t len); /** * Converts a holding buffer with key material to EVP PKEY in openssl. * Only available if ldns was compiled with GOST. * \param[in] key data to convert * \param[in] keylen length of the key data * \return the key or NULL on error. */ EVP_PKEY* gldns_gost2pkey_raw(unsigned char* key, size_t keylen); /** * Converts a holding buffer with key material to EVP PKEY in openssl. * Only available if ldns was compiled with ECDSA. * \param[in] key data to convert * \param[in] keylen length of the key data * \param[in] algo precise algorithm to initialize ECC group values. * \return the key or NULL on error. */ EVP_PKEY* gldns_ecdsa2pkey_raw(unsigned char* key, size_t keylen, uint8_t algo); /** * Like gldns_key_buf2rsa, but uses raw buffer. * \param[in] key the uncompressed wireformat of the key. * \param[in] len length of key data * \return a RSA * structure with the key material */ RSA *gldns_key_buf2rsa_raw(unsigned char* key, size_t len); /** * Utility function to calculate hash using generic EVP_MD pointer. * \param[in] data the data to hash. * \param[in] len length of data. * \param[out] dest the destination of the hash, must be large enough. * \param[in] md the message digest to use. * \return true if worked, false on failure. */ int gldns_digest_evp(unsigned char* data, unsigned int len, unsigned char* dest, const EVP_MD* md); #endif /* GLDNS_BUILD_CONFIG_HAVE_SSL */ #ifdef __cplusplus } #endif #endif /* GLDNS_KEYRAW_H */ getdns-0.9.0/src/gldns/gbuffer.c0000664000175100017510000000725512641212403013417 00000000000000/* * buffer.c -- generic memory buffer . * * Copyright (c) 2001-2008, NLnet Labs. All rights reserved. * * See LICENSE for the license. * */ /** * \file * * This file contains the definition of gldns_buffer, and functions to manipulate those. */ #include "config.h" #include "gldns/gbuffer.h" #include gldns_buffer * gldns_buffer_new(size_t capacity) { gldns_buffer *buffer = (gldns_buffer*)malloc(sizeof(gldns_buffer)); if (!buffer) { return NULL; } buffer->_data = (uint8_t *) malloc(capacity); if (!buffer->_data) { free(buffer); return NULL; } buffer->_position = 0; buffer->_limit = buffer->_capacity = capacity; buffer->_fixed = 0; buffer->_status_err = 0; gldns_buffer_invariant(buffer); return buffer; } void gldns_buffer_new_frm_data(gldns_buffer *buffer, void *data, size_t size) { assert(data != NULL); buffer->_position = 0; buffer->_limit = buffer->_capacity = size; buffer->_fixed = 0; buffer->_data = malloc(size); if(!buffer->_data) { buffer->_status_err = 1; return; } memcpy(buffer->_data, data, size); buffer->_status_err = 0; gldns_buffer_invariant(buffer); } void gldns_buffer_init_frm_data(gldns_buffer *buffer, void *data, size_t size) { memset(buffer, 0, sizeof(*buffer)); buffer->_data = data; buffer->_capacity = buffer->_limit = size; buffer->_fixed = 1; } int gldns_buffer_set_capacity(gldns_buffer *buffer, size_t capacity) { void *data; gldns_buffer_invariant(buffer); assert(buffer->_position <= capacity && !buffer->_fixed); data = (uint8_t *) realloc(buffer->_data, capacity); if (!data) { buffer->_status_err = 1; return 0; } else { buffer->_data = data; buffer->_limit = buffer->_capacity = capacity; return 1; } } int gldns_buffer_reserve(gldns_buffer *buffer, size_t amount) { gldns_buffer_invariant(buffer); assert(!buffer->_fixed); if (buffer->_capacity < buffer->_position + amount) { size_t new_capacity = buffer->_capacity * 3 / 2; if (new_capacity < buffer->_position + amount) { new_capacity = buffer->_position + amount; } if (!gldns_buffer_set_capacity(buffer, new_capacity)) { buffer->_status_err = 1; return 0; } } buffer->_limit = buffer->_capacity; return 1; } int gldns_buffer_printf(gldns_buffer *buffer, const char *format, ...) { va_list args; int written = 0; size_t remaining; if (gldns_buffer_status_ok(buffer)) { gldns_buffer_invariant(buffer); assert(buffer->_limit == buffer->_capacity); remaining = gldns_buffer_remaining(buffer); va_start(args, format); written = vsnprintf((char *) gldns_buffer_current(buffer), remaining, format, args); va_end(args); if (written == -1) { buffer->_status_err = 1; return -1; } else if (!buffer->_fixed && (size_t) written >= remaining) { if (!gldns_buffer_reserve(buffer, (size_t) written + 1)) { buffer->_status_err = 1; return -1; } va_start(args, format); written = vsnprintf((char *) gldns_buffer_current(buffer), gldns_buffer_remaining(buffer), format, args); va_end(args); if (written == -1) { buffer->_status_err = 1; return -1; } } buffer->_position += written; } return written; } void gldns_buffer_free(gldns_buffer *buffer) { if (!buffer) { return; } if (!buffer->_fixed) free(buffer->_data); free(buffer); } void * gldns_buffer_export(gldns_buffer *buffer) { buffer->_fixed = 1; return buffer->_data; } void gldns_buffer_copy(gldns_buffer* result, gldns_buffer* from) { size_t tocopy = gldns_buffer_limit(from); if(tocopy > gldns_buffer_capacity(result)) tocopy = gldns_buffer_capacity(result); gldns_buffer_clear(result); gldns_buffer_write(result, gldns_buffer_begin(from), tocopy); gldns_buffer_flip(result); } getdns-0.9.0/src/gldns/parse.h0000664000175100017510000001472712641212403013120 00000000000000/* * parse.h * * a Net::DNS like library for C * LibDNS Team @ NLnet Labs * (c) NLnet Labs, 2005-2006 * See the file LICENSE for the license */ #ifndef GLDNS_PARSE_H #define GLDNS_PARSE_H struct gldns_buffer; #ifdef __cplusplus extern "C" { #endif #define GLDNS_PARSE_SKIP_SPACE "\f\n\r\v" #define GLDNS_PARSE_NORMAL " \f\n\r\t\v" #define GLDNS_PARSE_NO_NL " \t" #define GLDNS_MAX_LINELEN 10230 #define GLDNS_MAX_KEYWORDLEN 32 /** * \file * * Contains some low-level parsing functions, mostly used in the _frm_str * family of functions. */ /** * different type of directives in zone files * We now deal with $TTL, $ORIGIN and $INCLUDE. * The latter is not implemented in ldns (yet) */ enum gldns_enum_directive { GLDNS_DIR_TTL, GLDNS_DIR_ORIGIN, GLDNS_DIR_INCLUDE }; typedef enum gldns_enum_directive gldns_directive; /** * returns a token/char from the stream F. * This function deals with ( and ) in the stream, * and ignores them when encountered * \param[in] *f the file to read from * \param[out] *token the read token is put here * \param[in] *delim chars at which the parsing should stop * \param[in] *limit how much to read. If 0 the builtin maximum is used * \return 0 on error of EOF of the stream F. Otherwise return the length of what is read */ ssize_t gldns_fget_token(FILE *f, char *token, const char *delim, size_t limit); /** * returns a token/char from the stream F. * This function deals with ( and ) in the stream, * and ignores when it finds them. * \param[in] *f the file to read from * \param[out] *token the token is put here * \param[in] *delim chars at which the parsing should stop * \param[in] *limit how much to read. If 0 use builtin maximum * \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes) * \return 0 on error of EOF of F otherwise return the length of what is read */ ssize_t gldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *line_nr); /** * returns a token/char from the buffer b. * This function deals with ( and ) in the buffer, * and ignores when it finds them. * \param[in] *b the buffer to read from * \param[out] *token the token is put here * \param[in] *delim chars at which the parsing should stop * \param[in] *limit how much to read. If 0 the builtin maximum is used * \param[in] *par if you pass nonNULL, set to 0 on first call, the parenthesis * state is stored in it, for use on next call. User must check it is back * to zero after last bget in string (for parse error). If you pass NULL, * the entire parenthesized string is read in. * \param[in] skipw string with whitespace to skip before the start of the * token, like " ", or " \t", or NULL for none. * \returns 0 on error of EOF of b. Otherwise return the length of what is read */ ssize_t gldns_bget_token_par(struct gldns_buffer *b, char *token, const char *delim, size_t limit, int* par, const char* skipw); /** * returns a token/char from the buffer b. * This function deals with ( and ) in the buffer, * and ignores when it finds them. * \param[in] *b the buffer to read from * \param[out] *token the token is put here * \param[in] *delim chars at which the parsing should stop * \param[in] *limit how much to read. If 0 the builtin maximum is used * \returns 0 on error of EOF of b. Otherwise return the length of what is read */ ssize_t gldns_bget_token(struct gldns_buffer *b, char *token, const char *delim, size_t limit); /* * searches for keyword and delim in a file. Gives everything back * after the keyword + k_del until we hit d_del * \param[in] f file pointer to read from * \param[in] keyword keyword to look for * \param[in] k_del keyword delimeter * \param[out] data the data found * \param[in] d_del the data delimeter * \param[in] data_limit maximum size the the data buffer * \return the number of character read */ ssize_t gldns_fget_keyword_data(FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit); /* * searches for keyword and delim. Gives everything back * after the keyword + k_del until we hit d_del * \param[in] f file pointer to read from * \param[in] keyword keyword to look for * \param[in] k_del keyword delimeter * \param[out] data the data found * \param[in] d_del the data delimeter * \param[in] data_limit maximum size the the data buffer * \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes) * \return the number of character read */ ssize_t gldns_fget_keyword_data_l(FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit, int *line_nr); /* * searches for keyword and delim in a buffer. Gives everything back * after the keyword + k_del until we hit d_del * \param[in] b buffer pointer to read from * \param[in] keyword keyword to look for * \param[in] k_del keyword delimeter * \param[out] data the data found * \param[in] d_del the data delimeter * \param[in] data_limit maximum size the the data buffer * \return the number of character read */ ssize_t gldns_bget_keyword_data(struct gldns_buffer *b, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit); /** * returns the next character from a buffer. Advances the position pointer with 1. * When end of buffer is reached returns EOF. This is the buffer's equivalent * for getc(). * \param[in] *buffer buffer to read from * \return EOF on failure otherwise return the character */ int gldns_bgetc(struct gldns_buffer *buffer); /** * skips all of the characters in the given string in the buffer, moving * the position to the first character that is not in *s. * \param[in] *buffer buffer to use * \param[in] *s characters to skip * \return void */ void gldns_bskipcs(struct gldns_buffer *buffer, const char *s); /** * skips all of the characters in the given string in the fp, moving * the position to the first character that is not in *s. * \param[in] *fp file to use * \param[in] *s characters to skip * \return void */ void gldns_fskipcs(FILE *fp, const char *s); /** * skips all of the characters in the given string in the fp, moving * the position to the first character that is not in *s. * \param[in] *fp file to use * \param[in] *s characters to skip * \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes) * \return void */ void gldns_fskipcs_l(FILE *fp, const char *s, int *line_nr); #ifdef __cplusplus } #endif #endif /* GLDNS_PARSE_H */ getdns-0.9.0/src/gldns/gbuffer.h0000664000175100017510000004711112641212403013417 00000000000000/* * buffer.h -- generic memory buffer. * * Copyright (c) 2005-2008, NLnet Labs. All rights reserved. * * See LICENSE for the license. * * * The buffer module implements a generic buffer. The API is based on * the java.nio.Buffer interface. */ #ifndef GLDNS_SBUFFER_H #define GLDNS_SBUFFER_H #ifdef __cplusplus extern "C" { #endif #ifdef S_SPLINT_S # define INLINE #else # ifdef SWIG # define INLINE static # else # define INLINE static inline # endif #endif /* * Copy data allowing for unaligned accesses in network byte order * (big endian). */ INLINE uint16_t gldns_read_uint16(const void *src) { #ifdef ALLOW_UNALIGNED_ACCESSES return ntohs(*(uint16_t *) src); #else uint8_t *p = (uint8_t *) src; return ((uint16_t) p[0] << 8) | (uint16_t) p[1]; #endif } INLINE uint32_t gldns_read_uint32(const void *src) { #ifdef ALLOW_UNALIGNED_ACCESSES return ntohl(*(uint32_t *) src); #else uint8_t *p = (uint8_t *) src; return ( ((uint32_t) p[0] << 24) | ((uint32_t) p[1] << 16) | ((uint32_t) p[2] << 8) | (uint32_t) p[3]); #endif } /* * Copy data allowing for unaligned accesses in network byte order * (big endian). */ INLINE void gldns_write_uint16(void *dst, uint16_t data) { #ifdef ALLOW_UNALIGNED_ACCESSES * (uint16_t *) dst = htons(data); #else uint8_t *p = (uint8_t *) dst; p[0] = (uint8_t) ((data >> 8) & 0xff); p[1] = (uint8_t) (data & 0xff); #endif } INLINE void gldns_write_uint32(void *dst, uint32_t data) { #ifdef ALLOW_UNALIGNED_ACCESSES * (uint32_t *) dst = htonl(data); #else uint8_t *p = (uint8_t *) dst; p[0] = (uint8_t) ((data >> 24) & 0xff); p[1] = (uint8_t) ((data >> 16) & 0xff); p[2] = (uint8_t) ((data >> 8) & 0xff); p[3] = (uint8_t) (data & 0xff); #endif } INLINE void gldns_write_uint48(void *dst, uint64_t data) { uint8_t *p = (uint8_t *) dst; p[0] = (uint8_t) ((data >> 40) & 0xff); p[1] = (uint8_t) ((data >> 32) & 0xff); p[2] = (uint8_t) ((data >> 24) & 0xff); p[3] = (uint8_t) ((data >> 16) & 0xff); p[4] = (uint8_t) ((data >> 8) & 0xff); p[5] = (uint8_t) (data & 0xff); } /** * \file gbuffer.h * * This file contains the definition of gldns_buffer, and functions to manipulate those. */ /** * implementation of buffers to ease operations * * gldns_buffers can contain arbitrary information, per octet. You can write * to the current end of a buffer, read from the current position, and * access any data within it. */ struct gldns_buffer { /** The current position used for reading/writing */ size_t _position; /** The read/write limit */ size_t _limit; /** The amount of data the buffer can contain */ size_t _capacity; /** The data contained in the buffer */ uint8_t *_data; /** If the buffer is fixed it cannot be resized */ unsigned _fixed : 1; /** The current state of the buffer. If writing to the buffer fails * for any reason, this value is changed. This way, you can perform * multiple writes in sequence and check for success afterwards. */ unsigned _status_err : 1; }; typedef struct gldns_buffer gldns_buffer; #ifdef NDEBUG INLINE void gldns_buffer_invariant(gldns_buffer *ATTR_UNUSED(buffer)) { } #else INLINE void gldns_buffer_invariant(gldns_buffer *buffer) { assert(buffer != NULL); assert(buffer->_position <= buffer->_limit || buffer->_fixed); assert(buffer->_limit <= buffer->_capacity); assert(buffer->_data != NULL); } #endif /** * creates a new buffer with the specified capacity. * * \param[in] capacity the size (in bytes) to allocate for the buffer * \return the created buffer */ gldns_buffer *gldns_buffer_new(size_t capacity); /** * creates a buffer with the specified data. The data IS copied * and MEMORY allocations are done. The buffer is not fixed and can * be resized using buffer_reserve(). * * \param[in] buffer pointer to the buffer to put the data in * \param[in] data the data to encapsulate in the buffer * \param[in] size the size of the data */ void gldns_buffer_new_frm_data(gldns_buffer *buffer, void *data, size_t size); /** * Setup a buffer with the data pointed to. No data copied, no memory allocs. * The buffer is fixed. * \param[in] buffer pointer to the buffer to put the data in * \param[in] data the data to encapsulate in the buffer * \param[in] size the size of the data */ void gldns_buffer_init_frm_data(gldns_buffer *buffer, void *data, size_t size); /** * clears the buffer and make it ready for writing. The buffer's limit * is set to the capacity and the position is set to 0. * \param[in] buffer the buffer to clear */ INLINE void gldns_buffer_clear(gldns_buffer *buffer) { gldns_buffer_invariant(buffer); /* reset status here? */ buffer->_position = 0; buffer->_limit = buffer->_capacity; } /** * makes the buffer ready for reading the data that has been written to * the buffer. The buffer's limit is set to the current position and * the position is set to 0. * * \param[in] buffer the buffer to flip * \return void */ INLINE void gldns_buffer_flip(gldns_buffer *buffer) { gldns_buffer_invariant(buffer); buffer->_limit = buffer->_position; buffer->_position = 0; } /** * make the buffer ready for re-reading the data. The buffer's * position is reset to 0. * \param[in] buffer the buffer to rewind */ INLINE void gldns_buffer_rewind(gldns_buffer *buffer) { gldns_buffer_invariant(buffer); buffer->_position = 0; } /** * returns the current position in the buffer (as a number of bytes) * \param[in] buffer the buffer * \return the current position */ INLINE size_t gldns_buffer_position(gldns_buffer *buffer) { return buffer->_position; } /** * sets the buffer's position to MARK. The position must be less than * or equal to the buffer's limit. * \param[in] buffer the buffer * \param[in] mark the mark to use */ INLINE void gldns_buffer_set_position(gldns_buffer *buffer, size_t mark) { assert(mark <= buffer->_limit || buffer->_fixed); buffer->_position = mark; } /** * changes the buffer's position by COUNT bytes. The position must not * be moved behind the buffer's limit or before the beginning of the * buffer. * \param[in] buffer the buffer * \param[in] count the count to use */ INLINE void gldns_buffer_skip(gldns_buffer *buffer, ssize_t count) { assert(buffer->_position + count <= buffer->_limit || buffer->_fixed); buffer->_position += count; } /** * returns the maximum size of the buffer * \param[in] buffer * \return the size */ INLINE size_t gldns_buffer_limit(gldns_buffer *buffer) { return buffer->_limit; } /** * changes the buffer's limit. If the buffer's position is greater * than the new limit the position is set to the limit. * \param[in] buffer the buffer * \param[in] limit the new limit */ INLINE void gldns_buffer_set_limit(gldns_buffer *buffer, size_t limit) { assert(limit <= buffer->_capacity); buffer->_limit = limit; if (buffer->_position > buffer->_limit) buffer->_position = buffer->_limit; } /** * returns the number of bytes the buffer can hold. * \param[in] buffer the buffer * \return the number of bytes */ INLINE size_t gldns_buffer_capacity(gldns_buffer *buffer) { return buffer->_capacity; } /** * changes the buffer's capacity. The data is reallocated so any * pointers to the data may become invalid. The buffer's limit is set * to the buffer's new capacity. * \param[in] buffer the buffer * \param[in] capacity the capacity to use * \return whether this failed or succeeded */ int gldns_buffer_set_capacity(gldns_buffer *buffer, size_t capacity); /** * ensures BUFFER can contain at least AMOUNT more bytes. The buffer's * capacity is increased if necessary using buffer_set_capacity(). * * The buffer's limit is always set to the (possibly increased) * capacity. * \param[in] buffer the buffer * \param[in] amount amount to use * \return whether this failed or succeeded */ int gldns_buffer_reserve(gldns_buffer *buffer, size_t amount); /** * returns a pointer to the data at the indicated position. * \param[in] buffer the buffer * \param[in] at position * \return the pointer to the data */ INLINE uint8_t * gldns_buffer_at(const gldns_buffer *buffer, size_t at) { assert(at <= buffer->_limit || buffer->_fixed); return buffer->_data + at; } /** * returns a pointer to the beginning of the buffer (the data at * position 0). * \param[in] buffer the buffer * \return the pointer */ INLINE uint8_t * gldns_buffer_begin(const gldns_buffer *buffer) { return gldns_buffer_at(buffer, 0); } /** * returns a pointer to the end of the buffer (the data at the buffer's * limit). * \param[in] buffer the buffer * \return the pointer */ INLINE uint8_t * gldns_buffer_end(gldns_buffer *buffer) { return gldns_buffer_at(buffer, buffer->_limit); } /** * returns a pointer to the data at the buffer's current position. * \param[in] buffer the buffer * \return the pointer */ INLINE uint8_t * gldns_buffer_current(gldns_buffer *buffer) { assert(buffer->_position <= buffer->_limit || buffer->_fixed); return gldns_buffer_at(buffer, buffer->_position); } /** * returns the number of bytes remaining between the indicated position and * the limit. * \param[in] buffer the buffer * \param[in] at indicated position * \return number of bytes */ INLINE size_t gldns_buffer_remaining_at(gldns_buffer *buffer, size_t at) { gldns_buffer_invariant(buffer); return at < buffer->_limit ? buffer->_limit - at : 0; } /** * returns the number of bytes remaining between the buffer's position and * limit. * \param[in] buffer the buffer * \return the number of bytes */ INLINE size_t gldns_buffer_remaining(gldns_buffer *buffer) { return gldns_buffer_remaining_at(buffer, buffer->_position); } /** * checks if the buffer has at least COUNT more bytes available. * Before reading or writing the caller needs to ensure enough space * is available! * \param[in] buffer the buffer * \param[in] at indicated position * \param[in] count how much is available * \return true or false (as int?) */ INLINE int gldns_buffer_available_at(gldns_buffer *buffer, size_t at, size_t count) { return count <= gldns_buffer_remaining_at(buffer, at); } /** * checks if the buffer has count bytes available at the current position * \param[in] buffer the buffer * \param[in] count how much is available * \return true or false (as int?) */ INLINE int gldns_buffer_available(gldns_buffer *buffer, size_t count) { return gldns_buffer_available_at(buffer, buffer->_position, count); } /** * writes the given data to the buffer at the specified position * \param[in] buffer the buffer * \param[in] at the position (in number of bytes) to write the data at * \param[in] data pointer to the data to write to the buffer * \param[in] count the number of bytes of data to write */ INLINE void gldns_buffer_write_at(gldns_buffer *buffer, size_t at, const void *data, size_t count) { if (!buffer->_fixed) assert(gldns_buffer_available_at(buffer, at, count)); else if (gldns_buffer_remaining_at(buffer, at) == 0) return; else if (count > gldns_buffer_remaining_at(buffer, at)) { memcpy(buffer->_data + at, data, gldns_buffer_remaining_at(buffer, at)); return; } memcpy(buffer->_data + at, data, count); } /** * writes count bytes of data to the current position of the buffer * \param[in] buffer the buffer * \param[in] data the data to write * \param[in] count the lenght of the data to write */ INLINE void gldns_buffer_write(gldns_buffer *buffer, const void *data, size_t count) { gldns_buffer_write_at(buffer, buffer->_position, data, count); buffer->_position += count; } /** * copies the given (null-delimited) string to the specified position at the buffer * \param[in] buffer the buffer * \param[in] at the position in the buffer * \param[in] str the string to write */ INLINE void gldns_buffer_write_string_at(gldns_buffer *buffer, size_t at, const char *str) { gldns_buffer_write_at(buffer, at, str, strlen(str)); } /** * copies the given (null-delimited) string to the current position at the buffer * \param[in] buffer the buffer * \param[in] str the string to write */ INLINE void gldns_buffer_write_string(gldns_buffer *buffer, const char *str) { gldns_buffer_write(buffer, str, strlen(str)); } /** * writes the given byte of data at the given position in the buffer * \param[in] buffer the buffer * \param[in] at the position in the buffer * \param[in] data the 8 bits to write */ INLINE void gldns_buffer_write_u8_at(gldns_buffer *buffer, size_t at, uint8_t data) { if (buffer->_fixed && at + sizeof(data) > buffer->_limit) return; assert(gldns_buffer_available_at(buffer, at, sizeof(data))); buffer->_data[at] = data; } /** * writes the given byte of data at the current position in the buffer * \param[in] buffer the buffer * \param[in] data the 8 bits to write */ INLINE void gldns_buffer_write_u8(gldns_buffer *buffer, uint8_t data) { gldns_buffer_write_u8_at(buffer, buffer->_position, data); buffer->_position += sizeof(data); } /** * writes the given 2 byte integer at the given position in the buffer * \param[in] buffer the buffer * \param[in] at the position in the buffer * \param[in] data the 16 bits to write */ INLINE void gldns_buffer_write_u16_at(gldns_buffer *buffer, size_t at, uint16_t data) { if (buffer->_fixed && at + sizeof(data) > buffer->_limit) return; assert(gldns_buffer_available_at(buffer, at, sizeof(data))); gldns_write_uint16(buffer->_data + at, data); } /** * writes the given 2 byte integer at the current position in the buffer * \param[in] buffer the buffer * \param[in] data the 16 bits to write */ INLINE void gldns_buffer_write_u16(gldns_buffer *buffer, uint16_t data) { gldns_buffer_write_u16_at(buffer, buffer->_position, data); buffer->_position += sizeof(data); } /** * writes the given 4 byte integer at the given position in the buffer * \param[in] buffer the buffer * \param[in] at the position in the buffer * \param[in] data the 32 bits to write */ INLINE void gldns_buffer_write_u32_at(gldns_buffer *buffer, size_t at, uint32_t data) { if (buffer->_fixed && at + sizeof(data) > buffer->_limit) return; assert(gldns_buffer_available_at(buffer, at, sizeof(data))); gldns_write_uint32(buffer->_data + at, data); } /** * writes the given 6 byte integer at the given position in the buffer * \param[in] buffer the buffer * \param[in] at the position in the buffer * \param[in] data the (lower) 48 bits to write */ INLINE void gldns_buffer_write_u48_at(gldns_buffer *buffer, size_t at, uint64_t data) { if (buffer->_fixed && at + 6 > buffer->_limit) return; assert(gldns_buffer_available_at(buffer, at, 6)); gldns_write_uint48(buffer->_data + at, data); } /** * writes the given 4 byte integer at the current position in the buffer * \param[in] buffer the buffer * \param[in] data the 32 bits to write */ INLINE void gldns_buffer_write_u32(gldns_buffer *buffer, uint32_t data) { gldns_buffer_write_u32_at(buffer, buffer->_position, data); buffer->_position += sizeof(data); } /** * writes the given 6 byte integer at the current position in the buffer * \param[in] buffer the buffer * \param[in] data the 48 bits to write */ INLINE void gldns_buffer_write_u48(gldns_buffer *buffer, uint64_t data) { gldns_buffer_write_u48_at(buffer, buffer->_position, data); buffer->_position += 6; } /** * copies count bytes of data at the given position to the given data-array * \param[in] buffer the buffer * \param[in] at the position in the buffer to start * \param[out] data buffer to copy to * \param[in] count the length of the data to copy */ INLINE void gldns_buffer_read_at(gldns_buffer *buffer, size_t at, void *data, size_t count) { assert(gldns_buffer_available_at(buffer, at, count)); memcpy(data, buffer->_data + at, count); } /** * copies count bytes of data at the current position to the given data-array * \param[in] buffer the buffer * \param[out] data buffer to copy to * \param[in] count the length of the data to copy */ INLINE void gldns_buffer_read(gldns_buffer *buffer, void *data, size_t count) { gldns_buffer_read_at(buffer, buffer->_position, data, count); buffer->_position += count; } /** * returns the byte value at the given position in the buffer * \param[in] buffer the buffer * \param[in] at the position in the buffer * \return 1 byte integer */ INLINE uint8_t gldns_buffer_read_u8_at(gldns_buffer *buffer, size_t at) { assert(gldns_buffer_available_at(buffer, at, sizeof(uint8_t))); return buffer->_data[at]; } /** * returns the byte value at the current position in the buffer * \param[in] buffer the buffer * \return 1 byte integer */ INLINE uint8_t gldns_buffer_read_u8(gldns_buffer *buffer) { uint8_t result = gldns_buffer_read_u8_at(buffer, buffer->_position); buffer->_position += sizeof(uint8_t); return result; } /** * returns the 2-byte integer value at the given position in the buffer * \param[in] buffer the buffer * \param[in] at position in the buffer * \return 2 byte integer */ INLINE uint16_t gldns_buffer_read_u16_at(gldns_buffer *buffer, size_t at) { assert(gldns_buffer_available_at(buffer, at, sizeof(uint16_t))); return gldns_read_uint16(buffer->_data + at); } /** * returns the 2-byte integer value at the current position in the buffer * \param[in] buffer the buffer * \return 2 byte integer */ INLINE uint16_t gldns_buffer_read_u16(gldns_buffer *buffer) { uint16_t result = gldns_buffer_read_u16_at(buffer, buffer->_position); buffer->_position += sizeof(uint16_t); return result; } /** * returns the 4-byte integer value at the given position in the buffer * \param[in] buffer the buffer * \param[in] at position in the buffer * \return 4 byte integer */ INLINE uint32_t gldns_buffer_read_u32_at(gldns_buffer *buffer, size_t at) { assert(gldns_buffer_available_at(buffer, at, sizeof(uint32_t))); return gldns_read_uint32(buffer->_data + at); } /** * returns the 4-byte integer value at the current position in the buffer * \param[in] buffer the buffer * \return 4 byte integer */ INLINE uint32_t gldns_buffer_read_u32(gldns_buffer *buffer) { uint32_t result = gldns_buffer_read_u32_at(buffer, buffer->_position); buffer->_position += sizeof(uint32_t); return result; } /** * returns the status of the buffer * \param[in] buffer * \return the status */ INLINE int gldns_buffer_status(gldns_buffer *buffer) { return (int)buffer->_status_err; } /** * returns true if the status of the buffer is GLDNS_STATUS_OK, false otherwise * \param[in] buffer the buffer * \return true or false */ INLINE int gldns_buffer_status_ok(gldns_buffer *buffer) { if (buffer) { return gldns_buffer_status(buffer) == 0; } else { return 0; } } /** * prints to the buffer, increasing the capacity if required using * buffer_reserve(). The buffer's position is set to the terminating '\\0' * Returns the number of characters written (not including the * terminating '\\0') or -1 on failure. */ int gldns_buffer_printf(gldns_buffer *buffer, const char *format, ...) ATTR_FORMAT(printf, 2, 3); /** * frees the buffer. * \param[in] *buffer the buffer to be freed * \return void */ void gldns_buffer_free(gldns_buffer *buffer); /** * Makes the buffer fixed and returns a pointer to the data. The * caller is responsible for free'ing the result. * \param[in] *buffer the buffer to be exported * \return void */ void *gldns_buffer_export(gldns_buffer *buffer); /** * Copy contents of the from buffer to the result buffer and then flips * the result buffer. Data will be silently truncated if the result buffer is * too small. * \param[out] *result resulting buffer which is copied to. * \param[in] *from what to copy to result. */ void gldns_buffer_copy(gldns_buffer* result, gldns_buffer* from); #ifdef __cplusplus } #endif #endif /* GLDNS_SBUFFER_H */ getdns-0.9.0/src/gldns/str2wire.h0000664000175100017510000005130112641212403013554 00000000000000/** * str2wire.h - read txt presentation of RRs * * (c) NLnet Labs, 2005-2006 * * See the file LICENSE for the license */ /** * \file * * Parses text to wireformat. */ #ifndef GLDNS_STR2WIRE_H #define GLDNS_STR2WIRE_H /* include rrdef for MAX_DOMAINLEN constant */ #include "gldns/rrdef.h" #ifdef __cplusplus extern "C" { #endif struct gldns_struct_lookup_table; /** buffer to read an RR, cannot be larger than 64K because of packet size */ #define GLDNS_RR_BUF_SIZE 65535 /* bytes */ #define GLDNS_DEFAULT_TTL 3600 /* * To convert class and type to string see * gldns_get_rr_class_by_name(str) * gldns_get_rr_type_by_name(str) * from rrdef.h */ /** * Convert text string into dname wireformat, mallocless, with user buffer. * @param str: the text string with the domain name. * @param buf: the result buffer, suggested size GLDNS_MAX_DOMAINLEN+1 * @param len: length of the buffer on input, length of the result on output. * @return 0 on success, otherwise an error. */ int gldns_str2wire_dname_buf(const char* str, uint8_t* buf, size_t* len); /** * Same as gldns_str2wire_dname_buf, but concatenates origin if the domain * name is relative (does not end in '.'). * @param str: the text string with the domain name. * @param buf: the result buffer, suggested size GLDNS_MAX_DOMAINLEN+1 * @param len: length of the buffer on input, length of the result on output. * @param origin: the origin to append or NULL (nothing is appended). * @param origin_len: length of origin. * @return 0 on success, otherwise an error. */ int gldns_str2wire_dname_buf_origin(const char* str, uint8_t* buf, size_t* len, uint8_t* origin, size_t origin_len); /** * Convert text string into dname wireformat * @param str: the text string with the domain name. * @param len: returned length of wireformat. * @return wireformat dname (malloced) or NULL on failure. */ uint8_t* gldns_str2wire_dname(const char* str, size_t* len); /** * Convert text RR to wireformat, with user buffer. * @param str: the RR data in text presentation format. * @param rr: the buffer where the result is stored into. This buffer has * the wire-dname(uncompressed), type, class, ttl, rdatalen, rdata. * These values are probably not aligned, and in network format. * Use the gldns_wirerr_get_xxx functions to access them safely. * buffer size GLDNS_RR_BUF_SIZE is suggested. * @param len: on input the length of the buffer, on output the amount of * the buffer used for the rr. * @param dname_len: if non-NULL, filled with the dname length as result. * Because after the dname you find the type, class, ttl, rdatalen, rdata. * @param default_ttl: TTL used if no TTL available. * @param origin: used for origin dname (if not NULL) * @param origin_len: length of origin. * @param prev: used for prev_rr dname (if not NULL) * @param prev_len: length of prev. * @return 0 on success, an error on failure. */ int gldns_str2wire_rr_buf(const char* str, uint8_t* rr, size_t* len, size_t* dname_len, uint32_t default_ttl, uint8_t* origin, size_t origin_len, uint8_t* prev, size_t prev_len); /** * Same as gldns_str2wire_rr_buf, but there is no rdata, it returns an RR * with zero rdata and no ttl. It has name, type, class. * You can access those with the gldns_wirerr_get_type and class functions. * @param str: the RR data in text presentation format. * @param rr: the buffer where the result is stored into. * @param len: on input the length of the buffer, on output the amount of * the buffer used for the rr. * @param dname_len: if non-NULL, filled with the dname length as result. * Because after the dname you find the type, class, ttl, rdatalen, rdata. * @param origin: used for origin dname (if not NULL) * @param origin_len: length of origin. * @param prev: used for prev_rr dname (if not NULL) * @param prev_len: length of prev. * @return 0 on success, an error on failure. */ int gldns_str2wire_rr_question_buf(const char* str, uint8_t* rr, size_t* len, size_t* dname_len, uint8_t* origin, size_t origin_len, uint8_t* prev, size_t prev_len); /** * Get the type of the RR. * @param rr: the RR in wire format. * @param len: rr length. * @param dname_len: dname length to skip. * @return type in host byteorder */ uint16_t gldns_wirerr_get_type(uint8_t* rr, size_t len, size_t dname_len); /** * Get the class of the RR. * @param rr: the RR in wire format. * @param len: rr length. * @param dname_len: dname length to skip. * @return class in host byteorder */ uint16_t gldns_wirerr_get_class(uint8_t* rr, size_t len, size_t dname_len); /** * Get the ttl of the RR. * @param rr: the RR in wire format. * @param len: rr length. * @param dname_len: dname length to skip. * @return ttl in host byteorder */ uint32_t gldns_wirerr_get_ttl(uint8_t* rr, size_t len, size_t dname_len); /** * Get the rdata length of the RR. * @param rr: the RR in wire format. * @param len: rr length. * @param dname_len: dname length to skip. * @return rdata length in host byteorder * If the rdata length is larger than the rr-len allows, it is truncated. * So, that it is safe to read the data length returned * from this function from the rdata pointer of gldns_wirerr_get_rdata. */ uint16_t gldns_wirerr_get_rdatalen(uint8_t* rr, size_t len, size_t dname_len); /** * Get the rdata pointer of the RR. * @param rr: the RR in wire format. * @param len: rr length. * @param dname_len: dname length to skip. * @return rdata pointer */ uint8_t* gldns_wirerr_get_rdata(uint8_t* rr, size_t len, size_t dname_len); /** * Get the rdata pointer of the RR. prefixed with rdata length. * @param rr: the RR in wire format. * @param len: rr length. * @param dname_len: dname length to skip. * @return pointer to rdatalength, followed by the rdata. */ uint8_t* gldns_wirerr_get_rdatawl(uint8_t* rr, size_t len, size_t dname_len); /** * Parse result codes */ #define GLDNS_WIREPARSE_MASK 0x0fff #define GLDNS_WIREPARSE_SHIFT 12 #define GLDNS_WIREPARSE_ERROR(e) ((e)&GLDNS_WIREPARSE_MASK) #define GLDNS_WIREPARSE_OFFSET(e) (((e)&~GLDNS_WIREPARSE_MASK)>>GLDNS_WIREPARSE_SHIFT) /* use lookuptable to get error string, gldns_wireparse_errors */ #define GLDNS_WIREPARSE_ERR_OK 0 #define GLDNS_WIREPARSE_ERR_GENERAL 342 #define GLDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW 343 #define GLDNS_WIREPARSE_ERR_DOMAINNAME_UNDERFLOW 344 #define GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL 345 #define GLDNS_WIREPARSE_ERR_LABEL_OVERFLOW 346 #define GLDNS_WIREPARSE_ERR_EMPTY_LABEL 347 #define GLDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE 348 #define GLDNS_WIREPARSE_ERR_SYNTAX 349 #define GLDNS_WIREPARSE_ERR_SYNTAX_TTL 350 #define GLDNS_WIREPARSE_ERR_SYNTAX_TYPE 351 #define GLDNS_WIREPARSE_ERR_SYNTAX_CLASS 352 #define GLDNS_WIREPARSE_ERR_SYNTAX_RDATA 353 #define GLDNS_WIREPARSE_ERR_SYNTAX_MISSING_VALUE 354 #define GLDNS_WIREPARSE_ERR_INVALID_STR 355 #define GLDNS_WIREPARSE_ERR_SYNTAX_B64 356 #define GLDNS_WIREPARSE_ERR_SYNTAX_B32_EXT 357 #define GLDNS_WIREPARSE_ERR_SYNTAX_HEX 358 #define GLDNS_WIREPARSE_ERR_CERT_BAD_ALGORITHM 359 #define GLDNS_WIREPARSE_ERR_SYNTAX_TIME 360 #define GLDNS_WIREPARSE_ERR_SYNTAX_PERIOD 361 #define GLDNS_WIREPARSE_ERR_SYNTAX_ILNP64 362 #define GLDNS_WIREPARSE_ERR_SYNTAX_EUI48 363 #define GLDNS_WIREPARSE_ERR_SYNTAX_EUI64 364 #define GLDNS_WIREPARSE_ERR_SYNTAX_TAG 365 #define GLDNS_WIREPARSE_ERR_NOT_IMPL 366 #define GLDNS_WIREPARSE_ERR_SYNTAX_INT 367 #define GLDNS_WIREPARSE_ERR_SYNTAX_IP4 368 #define GLDNS_WIREPARSE_ERR_SYNTAX_IP6 369 #define GLDNS_WIREPARSE_ERR_SYNTAX_INTEGER_OVERFLOW 370 #define GLDNS_WIREPARSE_ERR_INCLUDE 371 #define GLDNS_WIREPARSE_ERR_PARENTHESIS 372 /** * Get reference to a constant string for the (parse) error. * @param e: error return value * @return string. */ const char* gldns_get_errorstr_parse(int e); /** * wire parse state for parsing files */ struct gldns_file_parse_state { /** the origin domain name, if len!=0. uncompressed wireformat */ uint8_t origin[GLDNS_MAX_DOMAINLEN+1]; /** length of origin domain name, in bytes. 0 if not set. */ size_t origin_len; /** the previous domain name, if len!=0. uncompressed wireformat*/ uint8_t prev_rr[GLDNS_MAX_DOMAINLEN+1]; /** length of the previous domain name, in bytes. 0 if not set. */ size_t prev_rr_len; /** default TTL, this is used if the text does not specify a TTL, * host byteorder */ uint32_t default_ttl; /** line number information */ int lineno; }; /** * Read one RR from zonefile with buffer for the data. * @param in: file that is read from (one RR, multiple lines if it spans them). * @param rr: this is malloced by the user and the result is stored here, * if an RR is read. If no RR is read this is signalled with the * return len set to 0 (for ORIGIN, TTL directives). * @param len: on input, the length of the rr buffer. on output the rr len. * Buffer size of 64k should be enough. * @param dname_len: returns the length of the dname initial part of the rr. * @param parse_state: pass a pointer to user-allocated struct. * Contents are maintained by this function. * If you pass NULL then ORIGIN and TTL directives are not honored. * You can start out with a particular origin by pre-filling it. * otherwise, zero the structure before passing it. * lineno is incremented when a newline is passed by the parser, * you should initialize it at 1 at the start of the file. * @return 0 on success, error on failure. */ int gldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len, struct gldns_file_parse_state* parse_state); /** * Convert one rdf in rdata to wireformat and parse from string. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @param rdftype: the type of the rdf. * @return 0 on success, error on failure. */ int gldns_str2wire_rdf_buf(const char* str, uint8_t* rd, size_t* len, gldns_rdf_type rdftype); /** * Convert rdf of type GLDNS_RDF_TYPE_INT8 from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_int8_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_INT16 from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_int16_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_INT32 from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_int32_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_A from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_a_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_AAAA from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_aaaa_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_STR from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_str_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_APL from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_apl_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_B64 from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_b64_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_B32_EXT from string to wireformat. * And also GLDNS_RDF_TYPE_NSEC3_NEXT_OWNER. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_b32_ext_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_HEX from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_hex_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_NSEC from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_nsec_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_TYPE from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_type_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_CLASS from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_class_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_CERT_ALG from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_cert_alg_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_ALG from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_alg_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_TIME from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_PERIOD from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_period_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_LOC from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_loc_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_WKS from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_wks_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_NSAP from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_nsap_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_ATMA from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_atma_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_IPSECKEY from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_ipseckey_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_NSEC3_SALT from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_nsec3_salt_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_ILNP64 from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_ilnp64_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_EUI48 from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_eui48_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_EUI64 from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_eui64_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_TAG from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_tag_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_LONG_STR from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_long_str_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_HIP from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_hip_buf(const char* str, uint8_t* rd, size_t* len); /** * Convert rdf of type GLDNS_RDF_TYPE_INT16_DATA from string to wireformat. * @param str: the text to convert for this rdata element. * @param rd: rdata buffer for the wireformat. * @param len: length of rd buffer on input, used length on output. * @return 0 on success, error on failure. */ int gldns_str2wire_int16_data_buf(const char* str, uint8_t* rd, size_t* len); #ifdef __cplusplus } #endif #endif /* GLDNS_STR2WIRE_H */ getdns-0.9.0/src/gldns/wire2str.c0000664000175100017510000015564312641212403013565 00000000000000/* * wire2str.c * * conversion routines from the wire format * to the presentation format (strings) * * (c) NLnet Labs, 2004-2006 * * See the file LICENSE for the license */ /** * \file * * Contains functions to translate the wireformat to text * representation, as well as functions to print them. */ #include "config.h" #include "gldns/wire2str.h" #include "gldns/str2wire.h" #include "gldns/rrdef.h" #include "gldns/pkthdr.h" #include "gldns/parseutil.h" #include "gldns/gbuffer.h" #include "gldns/keyraw.h" #ifdef HAVE_TIME_H #include #endif #include #include #include #ifdef HAVE_NETDB_H #include #endif /* lookup tables for standard DNS stuff */ /* Taken from RFC 2535, section 7. */ static gldns_lookup_table gldns_algorithms_data[] = { { GLDNS_RSAMD5, "RSAMD5" }, { GLDNS_DH, "DH" }, { GLDNS_DSA, "DSA" }, { GLDNS_ECC, "ECC" }, { GLDNS_RSASHA1, "RSASHA1" }, { GLDNS_DSA_NSEC3, "DSA-NSEC3-SHA1" }, { GLDNS_RSASHA1_NSEC3, "RSASHA1-NSEC3-SHA1" }, { GLDNS_RSASHA256, "RSASHA256"}, { GLDNS_RSASHA512, "RSASHA512"}, { GLDNS_ECC_GOST, "ECC-GOST"}, { GLDNS_ECDSAP256SHA256, "ECDSAP256SHA256"}, { GLDNS_ECDSAP384SHA384, "ECDSAP384SHA384"}, { GLDNS_INDIRECT, "INDIRECT" }, { GLDNS_PRIVATEDNS, "PRIVATEDNS" }, { GLDNS_PRIVATEOID, "PRIVATEOID" }, { 0, NULL } }; gldns_lookup_table* gldns_algorithms = gldns_algorithms_data; /* hash algorithms in DS record */ static gldns_lookup_table gldns_hashes_data[] = { { GLDNS_SHA1, "SHA1" }, { GLDNS_SHA256, "SHA256" }, { GLDNS_HASH_GOST, "HASH-GOST" }, { GLDNS_SHA384, "SHA384" }, { 0, NULL } }; gldns_lookup_table* gldns_hashes = gldns_hashes_data; /* Taken from RFC 4398 */ static gldns_lookup_table gldns_cert_algorithms_data[] = { { GLDNS_CERT_PKIX, "PKIX" }, { GLDNS_CERT_SPKI, "SPKI" }, { GLDNS_CERT_PGP, "PGP" }, { GLDNS_CERT_IPKIX, "IPKIX" }, { GLDNS_CERT_ISPKI, "ISPKI" }, { GLDNS_CERT_IPGP, "IPGP" }, { GLDNS_CERT_ACPKIX, "ACPKIX" }, { GLDNS_CERT_IACPKIX, "IACPKIX" }, { GLDNS_CERT_URI, "URI" }, { GLDNS_CERT_OID, "OID" }, { 0, NULL } }; gldns_lookup_table* gldns_cert_algorithms = gldns_cert_algorithms_data; /* if these are used elsewhere */ static gldns_lookup_table gldns_rcodes_data[] = { { GLDNS_RCODE_NOERROR, "NOERROR" }, { GLDNS_RCODE_FORMERR, "FORMERR" }, { GLDNS_RCODE_SERVFAIL, "SERVFAIL" }, { GLDNS_RCODE_NXDOMAIN, "NXDOMAIN" }, { GLDNS_RCODE_NOTIMPL, "NOTIMPL" }, { GLDNS_RCODE_REFUSED, "REFUSED" }, { GLDNS_RCODE_YXDOMAIN, "YXDOMAIN" }, { GLDNS_RCODE_YXRRSET, "YXRRSET" }, { GLDNS_RCODE_NXRRSET, "NXRRSET" }, { GLDNS_RCODE_NOTAUTH, "NOTAUTH" }, { GLDNS_RCODE_NOTZONE, "NOTZONE" }, { 0, NULL } }; gldns_lookup_table* gldns_rcodes = gldns_rcodes_data; static gldns_lookup_table gldns_opcodes_data[] = { { GLDNS_PACKET_QUERY, "QUERY" }, { GLDNS_PACKET_IQUERY, "IQUERY" }, { GLDNS_PACKET_STATUS, "STATUS" }, { GLDNS_PACKET_NOTIFY, "NOTIFY" }, { GLDNS_PACKET_UPDATE, "UPDATE" }, { 0, NULL } }; gldns_lookup_table* gldns_opcodes = gldns_opcodes_data; static gldns_lookup_table gldns_wireparse_errors_data[] = { { GLDNS_WIREPARSE_ERR_OK, "no parse error" }, { GLDNS_WIREPARSE_ERR_GENERAL, "parse error" }, { GLDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, "Domainname length overflow" }, { GLDNS_WIREPARSE_ERR_DOMAINNAME_UNDERFLOW, "Domainname length underflow (zero length)" }, { GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, "buffer too small" }, { GLDNS_WIREPARSE_ERR_LABEL_OVERFLOW, "Label length overflow" }, { GLDNS_WIREPARSE_ERR_EMPTY_LABEL, "Empty label" }, { GLDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE, "Syntax error, bad escape sequence" }, { GLDNS_WIREPARSE_ERR_SYNTAX, "Syntax error, could not parse the RR" }, { GLDNS_WIREPARSE_ERR_SYNTAX_TTL, "Syntax error, could not parse the RR's TTL" }, { GLDNS_WIREPARSE_ERR_SYNTAX_TYPE, "Syntax error, could not parse the RR's type" }, { GLDNS_WIREPARSE_ERR_SYNTAX_CLASS, "Syntax error, could not parse the RR's class" }, { GLDNS_WIREPARSE_ERR_SYNTAX_RDATA, "Syntax error, could not parse the RR's rdata" }, { GLDNS_WIREPARSE_ERR_SYNTAX_MISSING_VALUE, "Syntax error, value expected" }, { GLDNS_WIREPARSE_ERR_INVALID_STR, "Conversion error, string expected" }, { GLDNS_WIREPARSE_ERR_SYNTAX_B64, "Conversion error, b64 encoding expected" }, { GLDNS_WIREPARSE_ERR_SYNTAX_B32_EXT, "Conversion error, b32 ext encoding expected" }, { GLDNS_WIREPARSE_ERR_SYNTAX_HEX, "Conversion error, hex encoding expected" }, { GLDNS_WIREPARSE_ERR_CERT_BAD_ALGORITHM, "Bad algorithm type for CERT record" }, { GLDNS_WIREPARSE_ERR_SYNTAX_TIME, "Conversion error, time encoding expected" }, { GLDNS_WIREPARSE_ERR_SYNTAX_PERIOD, "Conversion error, time period encoding expected" }, { GLDNS_WIREPARSE_ERR_SYNTAX_ILNP64, "Conversion error, 4 colon separated hex numbers expected" }, { GLDNS_WIREPARSE_ERR_SYNTAX_EUI48, "Conversion error, 6 two character hex numbers " "separated by dashes expected (i.e. xx-xx-xx-xx-xx-xx" }, { GLDNS_WIREPARSE_ERR_SYNTAX_EUI64, "Conversion error, 8 two character hex numbers " "separated by dashes expected (i.e. xx-xx-xx-xx-xx-xx-xx-xx" }, { GLDNS_WIREPARSE_ERR_SYNTAX_TAG, "Conversion error, a non-zero sequence of US-ASCII letters " "and numbers in lower case expected" }, { GLDNS_WIREPARSE_ERR_NOT_IMPL, "not implemented" }, { GLDNS_WIREPARSE_ERR_SYNTAX_INT, "Conversion error, integer expected" }, { GLDNS_WIREPARSE_ERR_SYNTAX_IP4, "Conversion error, ip4 addr expected" }, { GLDNS_WIREPARSE_ERR_SYNTAX_IP6, "Conversion error, ip6 addr expected" }, { GLDNS_WIREPARSE_ERR_SYNTAX_INTEGER_OVERFLOW, "Syntax error, integer overflow" }, { GLDNS_WIREPARSE_ERR_INCLUDE, "$INCLUDE directive was seen in the zone" }, { GLDNS_WIREPARSE_ERR_PARENTHESIS, "Parse error, parenthesis mismatch" }, { 0, NULL } }; gldns_lookup_table* gldns_wireparse_errors = gldns_wireparse_errors_data; static gldns_lookup_table gldns_edns_flags_data[] = { { 3600, "do"}, { 0, NULL} }; gldns_lookup_table* gldns_edns_flags = gldns_edns_flags_data; static gldns_lookup_table gldns_edns_options_data[] = { { 1, "LLQ" }, { 2, "UL" }, { 3, "NSID" }, /* 4 draft-cheshire-edns0-owner-option */ { 5, "DAU" }, { 6, "DHU" }, { 7, "N3U" }, { 8, "edns-client-subnet" }, { 11, "edns-tcp-keepalive"}, { 0, NULL} }; gldns_lookup_table* gldns_edns_options = gldns_edns_options_data; char* gldns_wire2str_pkt(uint8_t* data, size_t len) { size_t slen = (size_t)gldns_wire2str_pkt_buf(data, len, NULL, 0); char* result = (char*)malloc(slen+1); if(!result) return NULL; gldns_wire2str_pkt_buf(data, len, result, slen+1); return result; } char* gldns_wire2str_rr(uint8_t* rr, size_t len) { size_t slen = (size_t)gldns_wire2str_rr_buf(rr, len, NULL, 0); char* result = (char*)malloc(slen+1); if(!result) return NULL; gldns_wire2str_rr_buf(rr, len, result, slen+1); return result; } char* gldns_wire2str_type(uint16_t rrtype) { char buf[16]; gldns_wire2str_type_buf(rrtype, buf, sizeof(buf)); return strdup(buf); } char* gldns_wire2str_class(uint16_t rrclass) { char buf[16]; gldns_wire2str_class_buf(rrclass, buf, sizeof(buf)); return strdup(buf); } char* gldns_wire2str_dname(uint8_t* dname, size_t dname_len) { size_t slen=(size_t)gldns_wire2str_dname_buf(dname, dname_len, NULL, 0); char* result = (char*)malloc(slen+1); if(!result) return NULL; gldns_wire2str_dname_buf(dname, dname_len, result, slen+1); return result; } char* gldns_wire2str_rcode(int rcode) { char buf[16]; gldns_wire2str_rcode_buf(rcode, buf, sizeof(buf)); return strdup(buf); } int gldns_wire2str_pkt_buf(uint8_t* d, size_t dlen, char* s, size_t slen) { /* use arguments as temporary variables */ return gldns_wire2str_pkt_scan(&d, &dlen, &s, &slen); } int gldns_wire2str_rr_buf(uint8_t* d, size_t dlen, char* s, size_t slen) { /* use arguments as temporary variables */ return gldns_wire2str_rr_scan(&d, &dlen, &s, &slen, NULL, 0); } int gldns_wire2str_rdata_buf(uint8_t* rdata, size_t rdata_len, char* str, size_t str_len, uint16_t rrtype) { /* use arguments as temporary variables */ return gldns_wire2str_rdata_scan(&rdata, &rdata_len, &str, &str_len, rrtype, NULL, 0); } int gldns_wire2str_rr_unknown_buf(uint8_t* d, size_t dlen, char* s, size_t slen) { /* use arguments as temporary variables */ return gldns_wire2str_rr_unknown_scan(&d, &dlen, &s, &slen, NULL, 0); } int gldns_wire2str_rr_comment_buf(uint8_t* rr, size_t rrlen, size_t dname_len, char* s, size_t slen) { uint16_t rrtype = gldns_wirerr_get_type(rr, rrlen, dname_len); return gldns_wire2str_rr_comment_print(&s, &slen, rr, rrlen, dname_len, rrtype); } int gldns_wire2str_type_buf(uint16_t rrtype, char* s, size_t slen) { /* use arguments as temporary variables */ return gldns_wire2str_type_print(&s, &slen, rrtype); } int gldns_wire2str_class_buf(uint16_t rrclass, char* s, size_t slen) { /* use arguments as temporary variables */ return gldns_wire2str_class_print(&s, &slen, rrclass); } int gldns_wire2str_rcode_buf(int rcode, char* s, size_t slen) { /* use arguments as temporary variables */ return gldns_wire2str_rcode_print(&s, &slen, rcode); } int gldns_wire2str_dname_buf(uint8_t* d, size_t dlen, char* s, size_t slen) { /* use arguments as temporary variables */ return gldns_wire2str_dname_scan(&d, &dlen, &s, &slen, NULL, 0); } int gldns_str_vprint(char** str, size_t* slen, const char* format, va_list args) { int w = vsnprintf(*str, *slen, format, args); if(w < 0) { /* error in printout */ return 0; } else if((size_t)w >= *slen) { *str = NULL; /* we do not want str to point outside of buffer*/ *slen = 0; } else { *str += w; *slen -= w; } return w; } int gldns_str_print(char** str, size_t* slen, const char* format, ...) { int w; va_list args; va_start(args, format); w = gldns_str_vprint(str, slen, format, args); va_end(args); return w; } /** print hex format into text buffer for specified length */ static int print_hex_buf(char** s, size_t* slen, uint8_t* buf, size_t len) { const char* hex = "0123456789ABCDEF"; size_t i; for(i=0; i>4], hex[buf[i]&0x0f]); } return (int)len*2; } /** print remainder of buffer in hex format with prefixed text */ static int print_remainder_hex(const char* pref, uint8_t** d, size_t* dlen, char** s, size_t* slen) { int w = 0; w += gldns_str_print(s, slen, "%s", pref); w += print_hex_buf(s, slen, *d, *dlen); *d += *dlen; *dlen = 0; return w; } int gldns_wire2str_pkt_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen) { int w = 0; unsigned qdcount, ancount, nscount, arcount, i; uint8_t* pkt = *d; size_t pktlen = *dlen; if(*dlen >= GLDNS_HEADER_SIZE) { qdcount = (unsigned)GLDNS_QDCOUNT(*d); ancount = (unsigned)GLDNS_ANCOUNT(*d); nscount = (unsigned)GLDNS_NSCOUNT(*d); arcount = (unsigned)GLDNS_ARCOUNT(*d); } else { qdcount = ancount = nscount = arcount = 0; } w += gldns_wire2str_header_scan(d, dlen, s, slen); w += gldns_str_print(s, slen, "\n"); w += gldns_str_print(s, slen, ";; QUESTION SECTION:\n"); for(i=0; i 0) { w += print_remainder_hex(";; trailing garbage 0x", d, dlen, s, slen); w += gldns_str_print(s, slen, "\n"); } return w; } /** scan type, class and ttl and printout, for rr */ static int gldns_rr_tcttl_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { int w = 0; uint16_t t, c; uint32_t ttl; if(*dl < 8) { if(*dl < 4) return w + print_remainder_hex("; Error malformed 0x", d, dl, s, sl); /* these print values or 0x.. if none left */ t = gldns_read_uint16(*d); c = gldns_read_uint16((*d)+2); (*d)+=4; (*dl)-=4; w += gldns_wire2str_class_print(s, sl, c); w += gldns_str_print(s, sl, "\t"); w += gldns_wire2str_type_print(s, sl, t); if(*dl == 0) return w + gldns_str_print(s, sl, "; Error no ttl"); return w + print_remainder_hex( "; Error malformed ttl 0x", d, dl, s, sl); } t = gldns_read_uint16(*d); c = gldns_read_uint16((*d)+2); ttl = gldns_read_uint32((*d)+4); (*d)+=8; (*dl)-=8; w += gldns_str_print(s, sl, "%lu\t", (unsigned long)ttl); w += gldns_wire2str_class_print(s, sl, c); w += gldns_str_print(s, sl, "\t"); w += gldns_wire2str_type_print(s, sl, t); return w; } int gldns_wire2str_rr_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen, uint8_t* pkt, size_t pktlen) { int w = 0; uint8_t* rr = *d; size_t rrlen = *dlen, dname_off, rdlen, ordlen; uint16_t rrtype = 0; if(*dlen >= 3 && (*d)[0]==0 && gldns_read_uint16((*d)+1)==GLDNS_RR_TYPE_OPT) { /* perform EDNS OPT processing */ return gldns_wire2str_edns_scan(d, dlen, s, slen, pkt, pktlen); } /* try to scan the rdata with pretty-printing, but if that fails, then * scan the rdata as an unknown RR type */ w += gldns_wire2str_dname_scan(d, dlen, s, slen, pkt, pktlen); w += gldns_str_print(s, slen, "\t"); dname_off = rrlen-(*dlen); if(*dlen == 4) { /* like a question-RR */ uint16_t t = gldns_read_uint16(*d); uint16_t c = gldns_read_uint16((*d)+2); (*d)+=4; (*dlen)-=4; w += gldns_wire2str_class_print(s, slen, c); w += gldns_str_print(s, slen, "\t"); w += gldns_wire2str_type_print(s, slen, t); w += gldns_str_print(s, slen, " ; Error no ttl,rdata\n"); return w; } if(*dlen < 8) { if(*dlen == 0) return w + gldns_str_print(s, slen, ";Error missing RR\n"); w += print_remainder_hex(";Error partial RR 0x", d, dlen, s, slen); return w + gldns_str_print(s, slen, "\n"); } rrtype = gldns_read_uint16(*d); w += gldns_rr_tcttl_scan(d, dlen, s, slen); w += gldns_str_print(s, slen, "\t"); /* rdata */ if(*dlen < 2) { if(*dlen == 0) return w + gldns_str_print(s, slen, ";Error missing rdatalen\n"); w += print_remainder_hex(";Error missing rdatalen 0x", d, dlen, s, slen); return w + gldns_str_print(s, slen, "\n"); } rdlen = gldns_read_uint16(*d); ordlen = rdlen; (*d)+=2; (*dlen)-=2; if(*dlen < rdlen) { w += gldns_str_print(s, slen, "\\# %u ", (unsigned)rdlen); if(*dlen == 0) return w + gldns_str_print(s, slen, ";Error missing rdata\n"); w += print_remainder_hex(";Error partial rdata 0x", d, dlen, s, slen); return w + gldns_str_print(s, slen, "\n"); } w += gldns_wire2str_rdata_scan(d, &rdlen, s, slen, rrtype, pkt, pktlen); (*dlen) -= (ordlen-rdlen); /* default comment */ w += gldns_wire2str_rr_comment_print(s, slen, rr, rrlen, dname_off, rrtype); w += gldns_str_print(s, slen, "\n"); return w; } int gldns_wire2str_rrquestion_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen, uint8_t* pkt, size_t pktlen) { int w = 0; uint16_t t, c; w += gldns_wire2str_dname_scan(d, dlen, s, slen, pkt, pktlen); w += gldns_str_print(s, slen, "\t"); if(*dlen < 4) { if(*dlen == 0) return w + gldns_str_print(s, slen, "Error malformed\n"); w += print_remainder_hex("Error malformed 0x", d, dlen, s, slen); return w + gldns_str_print(s, slen, "\n"); } t = gldns_read_uint16(*d); c = gldns_read_uint16((*d)+2); (*d)+=4; (*dlen)-=4; w += gldns_wire2str_class_print(s, slen, c); w += gldns_str_print(s, slen, "\t"); w += gldns_wire2str_type_print(s, slen, t); w += gldns_str_print(s, slen, "\n"); return w; } int gldns_wire2str_rr_unknown_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen, uint8_t* pkt, size_t pktlen) { size_t rdlen, ordlen; int w = 0; w += gldns_wire2str_dname_scan(d, dlen, s, slen, pkt, pktlen); w += gldns_str_print(s, slen, "\t"); w += gldns_rr_tcttl_scan(d, dlen, s, slen); w += gldns_str_print(s, slen, "\t"); if(*dlen < 2) { if(*dlen == 0) return w + gldns_str_print(s, slen, ";Error missing rdatalen\n"); w += print_remainder_hex(";Error missing rdatalen 0x", d, dlen, s, slen); return w + gldns_str_print(s, slen, "\n"); } rdlen = gldns_read_uint16(*d); ordlen = rdlen; (*d) += 2; (*dlen) -= 2; if(*dlen < rdlen) { w += gldns_str_print(s, slen, "\\# %u ", (unsigned)rdlen); if(*dlen == 0) return w + gldns_str_print(s, slen, ";Error missing rdata\n"); w += print_remainder_hex(";Error partial rdata 0x", d, dlen, s, slen); return w + gldns_str_print(s, slen, "\n"); } w += gldns_wire2str_rdata_unknown_scan(d, &rdlen, s, slen); (*dlen) -= (ordlen-rdlen); w += gldns_str_print(s, slen, "\n"); return w; } /** print rr comment for type DNSKEY */ static int rr_comment_dnskey(char** s, size_t* slen, uint8_t* rr, size_t rrlen, size_t dname_off) { size_t rdlen; uint8_t* rdata; int flags, w = 0; if(rrlen < dname_off + 10) return 0; rdlen = gldns_read_uint16(rr+dname_off+8); if(rrlen < dname_off + 10 + rdlen) return 0; rdata = rr + dname_off + 10; flags = (int)gldns_read_uint16(rdata); w += gldns_str_print(s, slen, " ;{"); /* id */ w += gldns_str_print(s, slen, "id = %u", gldns_calc_keytag_raw(rdata, rdlen)); /* flags */ if((flags&GLDNS_KEY_ZONE_KEY)) { if((flags&GLDNS_KEY_SEP_KEY)) w += gldns_str_print(s, slen, " (ksk)"); else w += gldns_str_print(s, slen, " (zsk)"); } /* keysize */ if(rdlen > 4) { w += gldns_str_print(s, slen, ", "); w += gldns_str_print(s, slen, "size = %db", (int)gldns_rr_dnskey_key_size_raw( (unsigned char*)rdata+4, rdlen-4, (int)(rdata[3]))); } w += gldns_str_print(s, slen, "}"); return w; } /** print rr comment for type RRSIG */ static int rr_comment_rrsig(char** s, size_t* slen, uint8_t* rr, size_t rrlen, size_t dname_off) { size_t rdlen; uint8_t* rdata; if(rrlen < dname_off + 10) return 0; rdlen = gldns_read_uint16(rr+dname_off+8); if(rrlen < dname_off + 10 + rdlen) return 0; rdata = rr + dname_off + 10; if(rdlen < 18) return 0; return gldns_str_print(s, slen, " ;{id = %d}", (int)gldns_read_uint16(rdata+16)); } /** print rr comment for type NSEC3 */ static int rr_comment_nsec3(char** s, size_t* slen, uint8_t* rr, size_t rrlen, size_t dname_off) { size_t rdlen; uint8_t* rdata; int w = 0; if(rrlen < dname_off + 10) return 0; rdlen = gldns_read_uint16(rr+dname_off+8); if(rrlen < dname_off + 10 + rdlen) return 0; rdata = rr + dname_off + 10; if(rdlen < 2) return 0; if((rdata[1] & GLDNS_NSEC3_VARS_OPTOUT_MASK)) w += gldns_str_print(s, slen, " ;{flags: optout}"); return w; } int gldns_wire2str_rr_comment_print(char** s, size_t* slen, uint8_t* rr, size_t rrlen, size_t dname_off, uint16_t rrtype) { if(rrtype == GLDNS_RR_TYPE_DNSKEY) { return rr_comment_dnskey(s, slen, rr, rrlen, dname_off); } else if(rrtype == GLDNS_RR_TYPE_RRSIG) { return rr_comment_rrsig(s, slen, rr, rrlen, dname_off); } else if(rrtype == GLDNS_RR_TYPE_NSEC3) { return rr_comment_nsec3(s, slen, rr, rrlen, dname_off); } return 0; } int gldns_wire2str_header_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen) { int w = 0; int opcode, rcode; w += gldns_str_print(s, slen, ";; ->>HEADER<<- "); if(*dlen == 0) return w+gldns_str_print(s, slen, "Error empty packet"); if(*dlen < 4) return w+print_remainder_hex("Error header too short 0x", d, dlen, s, slen); opcode = (int)GLDNS_OPCODE_WIRE(*d); rcode = (int)GLDNS_RCODE_WIRE(*d); w += gldns_str_print(s, slen, "opcode: "); w += gldns_wire2str_opcode_print(s, slen, opcode); w += gldns_str_print(s, slen, ", "); w += gldns_str_print(s, slen, "rcode: "); w += gldns_wire2str_rcode_print(s, slen, rcode); w += gldns_str_print(s, slen, ", "); w += gldns_str_print(s, slen, "id: %d\n", (int)GLDNS_ID_WIRE(*d)); w += gldns_str_print(s, slen, ";; flags:"); if(GLDNS_QR_WIRE(*d)) w += gldns_str_print(s, slen, " qr"); if(GLDNS_AA_WIRE(*d)) w += gldns_str_print(s, slen, " aa"); if(GLDNS_TC_WIRE(*d)) w += gldns_str_print(s, slen, " tc"); if(GLDNS_RD_WIRE(*d)) w += gldns_str_print(s, slen, " rd"); if(GLDNS_CD_WIRE(*d)) w += gldns_str_print(s, slen, " cd"); if(GLDNS_RA_WIRE(*d)) w += gldns_str_print(s, slen, " ra"); if(GLDNS_AD_WIRE(*d)) w += gldns_str_print(s, slen, " ad"); if(GLDNS_Z_WIRE(*d)) w += gldns_str_print(s, slen, " z"); w += gldns_str_print(s, slen, " ; "); if(*dlen < GLDNS_HEADER_SIZE) return w+print_remainder_hex("Error header too short 0x", d, dlen, s, slen); w += gldns_str_print(s, slen, "QUERY: %d, ", (int)GLDNS_QDCOUNT(*d)); w += gldns_str_print(s, slen, "ANSWER: %d, ", (int)GLDNS_ANCOUNT(*d)); w += gldns_str_print(s, slen, "AUTHORITY: %d, ", (int)GLDNS_NSCOUNT(*d)); w += gldns_str_print(s, slen, "ADDITIONAL: %d ", (int)GLDNS_ARCOUNT(*d)); *d += GLDNS_HEADER_SIZE; *dlen -= GLDNS_HEADER_SIZE; return w; } int gldns_wire2str_rdata_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen, uint16_t rrtype, uint8_t* pkt, size_t pktlen) { /* try to prettyprint, but if that fails, use unknown format */ uint8_t* origd = *d; char* origs = *s; size_t origdlen = *dlen, origslen = *slen; uint16_t r_cnt, r_max; gldns_rdf_type rdftype; int w = 0, n; const gldns_rr_descriptor *desc = gldns_rr_descript(rrtype); if(!desc) /* unknown format */ return gldns_wire2str_rdata_unknown_scan(d, dlen, s, slen); /* dlen equals the rdatalen for the rdata */ r_max = gldns_rr_descriptor_maximum(desc); for(r_cnt=0; r_cnt < r_max; r_cnt++) { if(*dlen == 0) { if(r_cnt < gldns_rr_descriptor_minimum(desc)) goto failed; break; /* nothing more to print */ } rdftype = gldns_rr_descriptor_field_type(desc, r_cnt); if(r_cnt != 0) w += gldns_str_print(s, slen, " "); n = gldns_wire2str_rdf_scan(d, dlen, s, slen, rdftype, pkt, pktlen); if(n == -1) { failed: /* failed, use unknown format */ *d = origd; *s = origs; *dlen = origdlen; *slen = origslen; return gldns_wire2str_rdata_unknown_scan(d, dlen, s, slen); } w += n; } return w; } int gldns_wire2str_rdata_unknown_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen) { int w = 0; /* print length */ w += gldns_str_print(s, slen, "\\# %u", (unsigned)*dlen); /* print rdlen in hex */ if(*dlen != 0) w += gldns_str_print(s, slen, " "); w += print_hex_buf(s, slen, *d, *dlen); (*d) += *dlen; (*dlen) = 0; return w; } /** print and escape one character for a domain dname */ static int dname_char_print(char** s, size_t* slen, uint8_t c) { if(c == '.' || c == ';' || c == '(' || c == ')' || c == '\\') return gldns_str_print(s, slen, "\\%c", c); else if(!(isascii((int)c) && isgraph((int)c))) return gldns_str_print(s, slen, "\\%03u", (unsigned)c); /* plain printout */ if(*slen) { **s = (char)c; (*s)++; (*slen)--; } return 1; } int gldns_wire2str_dname_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen, uint8_t* pkt, size_t pktlen) { int w = 0; /* spool labels onto the string, use compression if its there */ uint8_t* pos = *d; unsigned i, counter=0; const unsigned maxcompr = 1000; /* loop detection, max compr ptrs */ int in_buf = 1; if(*dlen == 0) return gldns_str_print(s, slen, "ErrorMissingDname"); if(*pos == 0) { (*d)++; (*dlen)--; return gldns_str_print(s, slen, "."); } while(*pos) { /* read label length */ uint8_t labellen = *pos++; if(in_buf) { (*d)++; (*dlen)--; } /* find out what sort of label we have */ if((labellen&0xc0) == 0xc0) { /* compressed */ uint16_t target = 0; if(in_buf && *dlen == 0) return w + gldns_str_print(s, slen, "ErrorPartialDname"); else if(!in_buf && pos+1 > pkt+pktlen) return w + gldns_str_print(s, slen, "ErrorPartialDname"); target = ((labellen&0x3f)<<8) | *pos; if(in_buf) { (*d)++; (*dlen)--; } /* move to target, if possible */ if(!pkt || target >= pktlen) return w + gldns_str_print(s, slen, "ErrorComprPtrOutOfBounds"); if(counter++ > maxcompr) return w + gldns_str_print(s, slen, "ErrorComprPtrLooped"); in_buf = 0; pos = pkt+target; continue; } else if((labellen&0xc0)) { /* notimpl label type */ w += gldns_str_print(s, slen, "ErrorLABELTYPE%xIsUnknown", (int)(labellen&0xc0)); return w; } /* spool label characters, end with '.' */ if(in_buf && *dlen < labellen) labellen = *dlen; else if(!in_buf && pos+labellen > pkt+pktlen) labellen = (uint8_t)(pkt + pktlen - pos); for(i=0; i<(unsigned)labellen; i++) { w += dname_char_print(s, slen, *pos++); } if(in_buf) { (*d) += labellen; (*dlen) -= labellen; if(*dlen == 0) break; } w += gldns_str_print(s, slen, "."); } /* skip over final root label */ if(in_buf && *dlen > 0) { (*d)++; (*dlen)--; } /* in case we printed no labels, terminate dname */ if(w == 0) w += gldns_str_print(s, slen, "."); return w; } int gldns_wire2str_opcode_print(char** s, size_t* slen, int opcode) { gldns_lookup_table *lt = gldns_lookup_by_id(gldns_opcodes, opcode); if (lt && lt->name) { return gldns_str_print(s, slen, "%s", lt->name); } return gldns_str_print(s, slen, "OPCODE%u", (unsigned)opcode); } int gldns_wire2str_rcode_print(char** s, size_t* slen, int rcode) { gldns_lookup_table *lt = gldns_lookup_by_id(gldns_rcodes, rcode); if (lt && lt->name) { return gldns_str_print(s, slen, "%s", lt->name); } return gldns_str_print(s, slen, "RCODE%u", (unsigned)rcode); } int gldns_wire2str_class_print(char** s, size_t* slen, uint16_t rrclass) { gldns_lookup_table *lt = gldns_lookup_by_id(gldns_rr_classes, (int)rrclass); if (lt && lt->name) { return gldns_str_print(s, slen, "%s", lt->name); } return gldns_str_print(s, slen, "CLASS%u", (unsigned)rrclass); } int gldns_wire2str_type_print(char** s, size_t* slen, uint16_t rrtype) { const gldns_rr_descriptor *descriptor = gldns_rr_descript(rrtype); if (descriptor && descriptor->_name) { return gldns_str_print(s, slen, "%s", descriptor->_name); } return gldns_str_print(s, slen, "TYPE%u", (unsigned)rrtype); } int gldns_wire2str_edns_option_code_print(char** s, size_t* slen, uint16_t opcode) { gldns_lookup_table *lt = gldns_lookup_by_id(gldns_edns_options, (int)opcode); if (lt && lt->name) { return gldns_str_print(s, slen, "%s", lt->name); } return gldns_str_print(s, slen, "OPT%u", (unsigned)opcode); } int gldns_wire2str_class_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen) { uint16_t c; if(*dlen == 0) return 0; if(*dlen < 2) return print_remainder_hex("Error malformed 0x", d, dlen, s, slen); c = gldns_read_uint16(*d); (*d)+=2; (*dlen)-=2; return gldns_wire2str_class_print(s, slen, c); } int gldns_wire2str_type_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen) { uint16_t t; if(*dlen == 0) return 0; if(*dlen < 2) return print_remainder_hex("Error malformed 0x", d, dlen, s, slen); t = gldns_read_uint16(*d); (*d)+=2; (*dlen)-=2; return gldns_wire2str_type_print(s, slen, t); } int gldns_wire2str_ttl_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen) { uint32_t ttl; if(*dlen == 0) return 0; if(*dlen < 4) return print_remainder_hex("Error malformed 0x", d, dlen, s, slen); ttl = gldns_read_uint32(*d); (*d)+=4; (*dlen)-=4; return gldns_str_print(s, slen, "%u", (unsigned)ttl); } int gldns_wire2str_rdf_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen, int rdftype, uint8_t* pkt, size_t pktlen) { if(*dlen == 0) return 0; switch(rdftype) { case GLDNS_RDF_TYPE_NONE: return 0; case GLDNS_RDF_TYPE_DNAME: return gldns_wire2str_dname_scan(d, dlen, s, slen, pkt, pktlen); case GLDNS_RDF_TYPE_INT8: return gldns_wire2str_int8_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_INT16: return gldns_wire2str_int16_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_INT32: return gldns_wire2str_int32_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_PERIOD: return gldns_wire2str_period_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_TSIGTIME: return gldns_wire2str_tsigtime_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_A: return gldns_wire2str_a_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_AAAA: return gldns_wire2str_aaaa_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_STR: return gldns_wire2str_str_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_APL: return gldns_wire2str_apl_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_B32_EXT: return gldns_wire2str_b32_ext_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_B64: return gldns_wire2str_b64_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_HEX: return gldns_wire2str_hex_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_NSEC: return gldns_wire2str_nsec_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_NSEC3_SALT: return gldns_wire2str_nsec3_salt_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_TYPE: return gldns_wire2str_type_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_CLASS: return gldns_wire2str_class_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_CERT_ALG: return gldns_wire2str_cert_alg_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_ALG: return gldns_wire2str_alg_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_UNKNOWN: return gldns_wire2str_unknown_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_TIME: return gldns_wire2str_time_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_LOC: return gldns_wire2str_loc_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_WKS: case GLDNS_RDF_TYPE_SERVICE: return gldns_wire2str_wks_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_NSAP: return gldns_wire2str_nsap_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_ATMA: return gldns_wire2str_atma_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_IPSECKEY: return gldns_wire2str_ipseckey_scan(d, dlen, s, slen, pkt, pktlen); case GLDNS_RDF_TYPE_HIP: return gldns_wire2str_hip_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_INT16_DATA: return gldns_wire2str_int16_data_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_NSEC3_NEXT_OWNER: return gldns_wire2str_b32_ext_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_ILNP64: return gldns_wire2str_ilnp64_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_EUI48: return gldns_wire2str_eui48_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_EUI64: return gldns_wire2str_eui64_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_TAG: return gldns_wire2str_tag_scan(d, dlen, s, slen); case GLDNS_RDF_TYPE_LONG_STR: return gldns_wire2str_long_str_scan(d, dlen, s, slen); } /* unknown rdf type */ return -1; } int gldns_wire2str_int8_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { int w; if(*dl < 1) return -1; w = gldns_str_print(s, sl, "%u", (unsigned)**d); (*d)++; (*dl)--; return w; } int gldns_wire2str_int16_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { int w; if(*dl < 2) return -1; w = gldns_str_print(s, sl, "%lu", (unsigned long)gldns_read_uint16(*d)); (*d)+=2; (*dl)-=2; return w; } int gldns_wire2str_int32_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { int w; if(*dl < 4) return -1; w = gldns_str_print(s, sl, "%lu", (unsigned long)gldns_read_uint32(*d)); (*d)+=4; (*dl)-=4; return w; } int gldns_wire2str_period_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { int w; if(*dl < 4) return -1; w = gldns_str_print(s, sl, "%u", (unsigned)gldns_read_uint32(*d)); (*d)+=4; (*dl)-=4; return w; } int gldns_wire2str_tsigtime_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { /* tsigtime is 48 bits network order unsigned integer */ int w; uint64_t tsigtime = 0; uint64_t d0, d1, d2, d3, d4, d5; if(*dl < 6) return -1; d0 = (*d)[0]; /* cast to uint64 for shift operations */ d1 = (*d)[1]; d2 = (*d)[2]; d3 = (*d)[3]; d4 = (*d)[4]; d5 = (*d)[5]; tsigtime = (d0<<40) | (d1<<32) | (d2<<24) | (d3<<16) | (d4<<8) | d5; #ifndef USE_WINSOCK w = gldns_str_print(s, sl, "%llu", (long long)tsigtime); #else w = gldns_str_print(s, sl, "%I64u", (long long)tsigtime); #endif (*d)+=6; (*dl)-=6; return w; } int gldns_wire2str_a_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { char buf[32]; int w; if(*dl < 4) return -1; if(!inet_ntop(AF_INET, *d, buf, (socklen_t)sizeof(buf))) return -1; w = gldns_str_print(s, sl, "%s", buf); (*d)+=4; (*dl)-=4; return w; } int gldns_wire2str_aaaa_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { #ifdef AF_INET6 char buf[64]; int w; if(*dl < 16) return -1; if(!inet_ntop(AF_INET6, *d, buf, (socklen_t)sizeof(buf))) return -1; w = gldns_str_print(s, sl, "%s", buf); (*d)+=16; (*dl)-=16; return w; #else return -1; #endif } /** printout escaped TYPE_STR character */ static int str_char_print(char** s, size_t* sl, uint8_t c) { if(isprint((int)c) || c == '\t') { if(c == '\"' || c == '\\') return gldns_str_print(s, sl, "\\%c", c); if(*sl) { **s = (char)c; (*s)++; (*sl)--; } return 1; } return gldns_str_print(s, sl, "\\%03u", (unsigned)c); } int gldns_wire2str_str_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { int w = 0; size_t i, len; if(*dl < 1) return -1; len = **d; if(*dl < 1+len) return -1; (*d)++; (*dl)--; w += gldns_str_print(s, sl, "\""); for(i=0; i 0) w += gldns_str_print(s, sl, "."); if(i < (int)adflength) w += gldns_str_print(s, sl, "%d", (*d)[4+i]); else w += gldns_str_print(s, sl, "0"); } } else if(family == GLDNS_APL_IP6) { /* check if prefix <128 ? */ /* address is variable length 0 - 16 */ for(i=0; i<16; i++) { if(i%2 == 0 && i>0) w += gldns_str_print(s, sl, ":"); if(i < (int)adflength) w += gldns_str_print(s, sl, "%02x", (*d)[4+i]); else w += gldns_str_print(s, sl, "00"); } } w += gldns_str_print(s, sl, "/%u", (unsigned)prefix); (*d) += 4+adflength; (*dl) -= 4+adflength; return w; } int gldns_wire2str_b32_ext_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { size_t datalen; size_t sz; if(*dl < 1) return -1; datalen = (*d)[0]; if(*dl < 1+datalen) return -1; sz = gldns_b32_ntop_calculate_size(datalen); if(*sl < sz+1) { (*d) += datalen+1; (*dl) -= (datalen+1); return (int)sz; /* out of space really, but would need buffer in order to truncate the output */ } gldns_b32_ntop_extended_hex((*d)+1, datalen, *s, *sl); (*d) += datalen+1; (*dl) -= (datalen+1); (*s) += sz; (*sl) -= sz; return (int)sz; } /** scan number of bytes from wire into b64 presentation format */ static int gldns_wire2str_b64_scan_num(uint8_t** d, size_t* dl, char** s, size_t* sl, size_t num) { /* b64_ntop_calculate size includes null at the end */ size_t sz = gldns_b64_ntop_calculate_size(num)-1; if(*sl < sz+1) { (*d) += num; (*dl) -= num; return (int)sz; /* out of space really, but would need buffer in order to truncate the output */ } gldns_b64_ntop(*d, num, *s, *sl); (*d) += num; (*dl) -= num; (*s) += sz; (*sl) -= sz; return (int)sz; } int gldns_wire2str_b64_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { return gldns_wire2str_b64_scan_num(d, dl, s, sl, *dl); } int gldns_wire2str_hex_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { return print_remainder_hex("", d, dl, s, sl); } int gldns_wire2str_nsec_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { uint8_t* p = *d; size_t pl = *dl; unsigned i, bit, window, block_len; uint16_t t; int w = 0; /* check for errors */ while(pl) { if(pl < 2) return -1; block_len = (unsigned)p[1]; if(pl < 2+block_len) return -1; p += block_len+2; pl -= block_len+2; } /* do it */ p = *d; pl = *dl; while(pl) { if(pl < 2) return -1; /* cannot happen */ window = (unsigned)p[0]; block_len = (unsigned)p[1]; if(pl < 2+block_len) return -1; /* cannot happen */ p += 2; for(i=0; i>bit))) { if(w) w += gldns_str_print(s, sl, " "); w += gldns_wire2str_type_print(s, sl, t+bit); } } } p += block_len; pl -= block_len+2; } (*d) += *dl; (*dl) = 0; return w; } int gldns_wire2str_nsec3_salt_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { size_t salt_len; int w; if(*dl < 1) return -1; salt_len = (size_t)(*d)[0]; if(*dl < 1+salt_len) return -1; (*d)++; (*dl)--; if(salt_len == 0) { return gldns_str_print(s, sl, "-"); } w = print_hex_buf(s, sl, *d, salt_len); (*dl)-=salt_len; (*d)+=salt_len; return w; } int gldns_wire2str_cert_alg_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { gldns_lookup_table *lt; int data, w; if(*dl < 2) return -1; data = (int)gldns_read_uint16(*d); lt = gldns_lookup_by_id(gldns_cert_algorithms, data); if(lt && lt->name) w = gldns_str_print(s, sl, "%s", lt->name); else w = gldns_str_print(s, sl, "%d", data); (*dl)-=2; (*d)+=2; return w; } int gldns_wire2str_alg_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { /* don't use algorithm mnemonics in the presentation format * this kind of got sneaked into the rfc's */ return gldns_wire2str_int8_scan(d, dl, s, sl); } int gldns_wire2str_unknown_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { return gldns_wire2str_rdata_unknown_scan(d, dl, s, sl); } int gldns_wire2str_time_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { /* create a YYYYMMDDHHMMSS string if possible */ struct tm tm; char date_buf[16]; uint32_t t; memset(&tm, 0, sizeof(tm)); if(*dl < 4) return -1; t = gldns_read_uint32(*d); date_buf[15]=0; if(gldns_serial_arithmitics_gmtime_r(t, time(NULL), &tm) && strftime(date_buf, 15, "%Y%m%d%H%M%S", &tm)) { (*d) += 4; (*dl) -= 4; return gldns_str_print(s, sl, "%s", date_buf); } return -1; } static int loc_cm_print(char** str, size_t* sl, uint8_t mantissa, uint8_t exponent) { int w = 0; uint8_t i; /* is it 0. ? */ if(exponent < 2) { if(exponent == 1) mantissa *= 10; return gldns_str_print(str, sl, "0.%02ld", (long)mantissa); } /* always */ w += gldns_str_print(str, sl, "%d", (int)mantissa); for(i=0; i equator) { northerness = 'N'; latitude = latitude - equator; } else { northerness = 'S'; latitude = equator - latitude; } h = latitude / (1000 * 60 * 60); latitude = latitude % (1000 * 60 * 60); m = latitude / (1000 * 60); latitude = latitude % (1000 * 60); s = (double) latitude / 1000.0; w += gldns_str_print(str, sl, "%02u %02u %06.3f %c ", h, m, s, northerness); if (longitude > equator) { easterness = 'E'; longitude = longitude - equator; } else { easterness = 'W'; longitude = equator - longitude; } h = longitude / (1000 * 60 * 60); longitude = longitude % (1000 * 60 * 60); m = longitude / (1000 * 60); longitude = longitude % (1000 * 60); s = (double) longitude / (1000.0); w += gldns_str_print(str, sl, "%02u %02u %06.3f %c ", h, m, s, easterness); s = ((double) altitude) / 100; s -= 100000; if(altitude%100 != 0) w += gldns_str_print(str, sl, "%.2f", s); else w += gldns_str_print(str, sl, "%.0f", s); w += gldns_str_print(str, sl, "m "); w += loc_cm_print(str, sl, (size & 0xf0) >> 4, size & 0x0f); w += gldns_str_print(str, sl, "m "); w += loc_cm_print(str, sl, (horizontal_precision & 0xf0) >> 4, horizontal_precision & 0x0f); w += gldns_str_print(str, sl, "m "); w += loc_cm_print(str, sl, (vertical_precision & 0xf0) >> 4, vertical_precision & 0x0f); w += gldns_str_print(str, sl, "m"); (*d)+=16; (*dl)-=16; return w; } int gldns_wire2str_wks_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { /* protocol, followed by bitmap of services */ const char* proto_name = NULL; struct protoent *protocol; struct servent *service; uint8_t protocol_nr; int bit, port, w = 0; size_t i; /* we cannot print with strings because they * are not portable, the presentation format may * not be able to be read in on another computer. */ int print_symbols = 0; /* protocol */ if(*dl < 1) return -1; protocol_nr = (*d)[0]; (*d)++; (*dl)--; protocol = getprotobynumber((int)protocol_nr); if(protocol && (protocol->p_name != NULL)) { w += gldns_str_print(s, sl, "%s", protocol->p_name); proto_name = protocol->p_name; } else { w += gldns_str_print(s, sl, "%u", (unsigned)protocol_nr); } for(i=0; i<*dl; i++) { if((*d)[i] == 0) continue; for(bit=0; bit<8; bit++) { if(!(((*d)[i])&(0x80>>bit))) continue; port = (int)i*8 + bit; if(!print_symbols) service = NULL; else service = getservbyport( (int)htons((uint16_t)port), proto_name); if(service && service->s_name) w += gldns_str_print(s, sl, " %s", service->s_name); else w += gldns_str_print(s, sl, " %u", (unsigned)port); } } #ifdef HAVE_ENDSERVENT endservent(); #endif #ifdef HAVE_ENDPROTOENT endprotoent(); #endif (*d) += *dl; (*dl) = 0; return w; } int gldns_wire2str_nsap_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { return print_remainder_hex("0x", d, dl, s, sl); } int gldns_wire2str_atma_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { return print_remainder_hex("", d, dl, s, sl); } /* internal scan routine that can modify arguments on failure */ static int gldns_wire2str_ipseckey_scan_internal(uint8_t** d, size_t* dl, char** s, size_t* sl, uint8_t* pkt, size_t pktlen) { /* http://www.ietf.org/internet-drafts/draft-ietf-ipseckey-rr-12.txt*/ uint8_t precedence, gateway_type, algorithm; int w = 0; if(*dl < 3) return -1; precedence = (*d)[0]; gateway_type = (*d)[1]; algorithm = (*d)[2]; if(gateway_type > 3) return -1; /* unknown */ (*d)+=3; (*dl)-=3; w += gldns_str_print(s, sl, "%d %d %d ", (int)precedence, (int)gateway_type, (int)algorithm); switch(gateway_type) { case 0: /* no gateway */ w += gldns_str_print(s, sl, "."); break; case 1: /* ip4 */ w += gldns_wire2str_a_scan(d, dl, s, sl); break; case 2: /* ip6 */ w += gldns_wire2str_aaaa_scan(d, dl, s, sl); break; case 3: /* dname */ w += gldns_wire2str_dname_scan(d, dl, s, sl, pkt, pktlen); break; default: /* unknown */ return -1; } if(*dl < 1) return -1; w += gldns_str_print(s, sl, " "); w += gldns_wire2str_b64_scan_num(d, dl, s, sl, *dl); return w; } int gldns_wire2str_ipseckey_scan(uint8_t** d, size_t* dl, char** s, size_t* sl, uint8_t* pkt, size_t pktlen) { uint8_t* od = *d; char* os = *s; size_t odl = *dl, osl = *sl; int w=gldns_wire2str_ipseckey_scan_internal(d, dl, s, sl, pkt, pktlen); if(w == -1) { *d = od; *s = os; *dl = odl; *sl = osl; return -1; } return w; } int gldns_wire2str_hip_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { int w; uint8_t algo, hitlen; uint16_t pklen; /* read lengths */ if(*dl < 4) return -1; hitlen = (*d)[0]; algo = (*d)[1]; pklen = gldns_read_uint16((*d)+2); if(*dl < (size_t)4 + (size_t)hitlen + (size_t)pklen) return -1; /* write: algo hit pubkey */ w = gldns_str_print(s, sl, "%u ", (unsigned)algo); w += print_hex_buf(s, sl, (*d)+4, hitlen); w += gldns_str_print(s, sl, " "); (*d)+=4+hitlen; (*dl)-= (4+hitlen); w += gldns_wire2str_b64_scan_num(d, dl, s, sl, pklen); return w; } int gldns_wire2str_int16_data_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { uint16_t n; if(*dl < 2) return -1; n = gldns_read_uint16(*d); if(*dl < 2+(size_t)n) return -1; (*d)+=2; (*dl)-=2; return gldns_wire2str_b64_scan_num(d, dl, s, sl, n); } int gldns_wire2str_nsec3_next_owner_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { return gldns_wire2str_b32_ext_scan(d, dl, s, sl); } int gldns_wire2str_ilnp64_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { int w; if(*dl < 8) return -1; w = gldns_str_print(s, sl, "%.4x:%.4x:%.4x:%.4x", gldns_read_uint16(*d), gldns_read_uint16((*d)+2), gldns_read_uint16((*d)+4), gldns_read_uint16((*d)+6)); (*d)+=8; (*dl)-=8; return w; } int gldns_wire2str_eui48_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { int w; if(*dl < 6) return -1; w = gldns_str_print(s, sl, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x", (*d)[0], (*d)[1], (*d)[2], (*d)[3], (*d)[4], (*d)[5]); (*d)+=6; (*dl)-=6; return w; } int gldns_wire2str_eui64_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { int w; if(*dl < 8) return -1; w = gldns_str_print(s, sl, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x-%.2x-%.2x", (*d)[0], (*d)[1], (*d)[2], (*d)[3], (*d)[4], (*d)[5], (*d)[6], (*d)[7]); (*d)+=8; (*dl)-=8; return w; } int gldns_wire2str_tag_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) { size_t i, n; int w = 0; if(*dl < 1) return -1; n = (size_t)((*d)[0]); if(*dl < 1+n) return -1; for(i=0; iname) w += gldns_str_print(s, sl, " %s", lt->name); else w += gldns_str_print(s, sl, " %d", (int)data[i]); } return w; } int gldns_wire2str_edns_dhu_print(char** s, size_t* sl, uint8_t* data, size_t len) { gldns_lookup_table *lt; size_t i; int w = 0; for(i=0; iname) w += gldns_str_print(s, sl, " %s", lt->name); else w += gldns_str_print(s, sl, " %d", (int)data[i]); } return w; } int gldns_wire2str_edns_n3u_print(char** s, size_t* sl, uint8_t* data, size_t len) { size_t i; int w = 0; for(i=0; i 4) { w += gldns_str_print(s, sl, "trailingdata:"); w += print_hex_buf(s, sl, data+4+4, len-4-4); w += gldns_str_print(s, sl, " "); len = 4+4; } memmove(ip4, data+4, len-4); if(!inet_ntop(AF_INET, ip4, buf, (socklen_t)sizeof(buf))) { w += gldns_str_print(s, sl, "ip4ntoperror "); w += print_hex_buf(s, sl, data+4+4, len-4-4); } else { w += gldns_str_print(s, sl, "%s", buf); } } else if(family == 2) { /* IP6 */ char buf[64]; uint8_t ip6[16]; memset(ip6, 0, sizeof(ip6)); if(len-4 > 16) { w += gldns_str_print(s, sl, "trailingdata:"); w += print_hex_buf(s, sl, data+4+16, len-4-16); w += gldns_str_print(s, sl, " "); len = 4+16; } memmove(ip6, data+4, len-4); #ifdef AF_INET6 if(!inet_ntop(AF_INET6, ip6, buf, (socklen_t)sizeof(buf))) { w += gldns_str_print(s, sl, "ip6ntoperror "); w += print_hex_buf(s, sl, data+4+4, len-4-4); } else { w += gldns_str_print(s, sl, "%s", buf); } #else w += print_hex_buf(s, sl, data+4+4, len-4-4); #endif } else { /* unknown */ w += gldns_str_print(s, sl, "family %d ", (int)family); w += print_hex_buf(s, sl, data, len); } w += gldns_str_print(s, sl, "/%d scope /%d", (int)source, (int)scope); return w; } int gldns_wire2str_edns_keepalive_print(char** s, size_t* sl, uint8_t* data, size_t len) { int w = 0; uint16_t timeout; if(!(len == 0 || len == 2)) { w += gldns_str_print(s, sl, "malformed keepalive "); w += print_hex_buf(s, sl, data, len); return w; } if(len == 0 ) { w += gldns_str_print(s, sl, "no timeout value (only valid for client option) "); } else { timeout = gldns_read_uint16(data); w += gldns_str_print(s, sl, "timeout value in units of 100ms %u", (int)timeout); } return w; } int gldns_wire2str_edns_option_print(char** s, size_t* sl, uint16_t option_code, uint8_t* optdata, size_t optlen) { int w = 0; w += gldns_wire2str_edns_option_code_print(s, sl, option_code); w += gldns_str_print(s, sl, ": "); switch(option_code) { case GLDNS_EDNS_LLQ: w += gldns_wire2str_edns_llq_print(s, sl, optdata, optlen); break; case GLDNS_EDNS_UL: w += gldns_wire2str_edns_ul_print(s, sl, optdata, optlen); break; case GLDNS_EDNS_NSID: w += gldns_wire2str_edns_nsid_print(s, sl, optdata, optlen); break; case GLDNS_EDNS_DAU: w += gldns_wire2str_edns_dau_print(s, sl, optdata, optlen); break; case GLDNS_EDNS_DHU: w += gldns_wire2str_edns_dhu_print(s, sl, optdata, optlen); break; case GLDNS_EDNS_N3U: w += gldns_wire2str_edns_n3u_print(s, sl, optdata, optlen); break; case GLDNS_EDNS_CLIENT_SUBNET: w += gldns_wire2str_edns_subnet_print(s, sl, optdata, optlen); break; case GLDNS_EDNS_KEEPALIVE: w += gldns_wire2str_edns_keepalive_print(s, sl, optdata, optlen); break; default: /* unknown option code */ w += print_hex_buf(s, sl, optdata, optlen); break; } return w; } /** print the edns options to string */ static int print_edns_opts(char** s, size_t* sl, uint8_t* rdata, size_t rdatalen) { uint16_t option_code, option_len; int w = 0; while(rdatalen > 0) { /* option name */ if(rdatalen < 4) { w += gldns_str_print(s, sl, " ; malformed: "); w += print_hex_buf(s, sl, rdata, rdatalen); return w; } option_code = gldns_read_uint16(rdata); option_len = gldns_read_uint16(rdata+2); rdata += 4; rdatalen -= 4; /* option value */ if(rdatalen < (size_t)option_len) { w += gldns_str_print(s, sl, " ; malformed "); w += gldns_wire2str_edns_option_code_print(s, sl, option_code); w += gldns_str_print(s, sl, ": "); w += print_hex_buf(s, sl, rdata, rdatalen); return w; } w += gldns_str_print(s, sl, " ; "); w += gldns_wire2str_edns_option_print(s, sl, option_code, rdata, option_len); rdata += option_len; rdatalen -= option_len; } return w; } int gldns_wire2str_edns_scan(uint8_t** data, size_t* data_len, char** str, size_t* str_len, uint8_t* pkt, size_t pktlen) { int w = 0; uint8_t ext_rcode, edns_version; uint16_t udpsize, edns_bits, rdatalen; w += gldns_str_print(str, str_len, "; EDNS:"); /* some input checks, domain name */ if(*data_len < 1+10) return w + print_remainder_hex("Error malformed 0x", data, data_len, str, str_len); if(*data[0] != 0) { return w + print_remainder_hex("Error nonrootdname 0x", data, data_len, str, str_len); } (*data)++; (*data_len)--; /* check type and read fixed contents */ if(gldns_read_uint16((*data)) != GLDNS_RR_TYPE_OPT) { return w + print_remainder_hex("Error nottypeOPT 0x", data, data_len, str, str_len); } udpsize = gldns_read_uint16((*data)+2); ext_rcode = (*data)[4]; edns_version = (*data)[5]; edns_bits = gldns_read_uint16((*data)+6); rdatalen = gldns_read_uint16((*data)+8); (*data)+=10; (*data_len)-=10; w += gldns_str_print(str, str_len, " version: %u;", (unsigned)edns_version); w += gldns_str_print(str, str_len, " flags:"); if((edns_bits & GLDNS_EDNS_MASK_DO_BIT)) w += gldns_str_print(str, str_len, " do"); /* the extended rcode is the value set, shifted four bits, * and or'd with the original rcode */ if(ext_rcode) { int rc = ((int)ext_rcode)<<4; if(pkt && pktlen >= GLDNS_HEADER_SIZE) rc |= GLDNS_RCODE_WIRE(pkt); w += gldns_str_print(str, str_len, " ; ext-rcode: %d", rc); } w += gldns_str_print(str, str_len, " ; udp: %u", (unsigned)udpsize); if(rdatalen) { if(*data_len < rdatalen) { w += gldns_str_print(str, str_len, " ; Error EDNS rdata too short; "); rdatalen = *data_len; } w += print_edns_opts(str, str_len, *data, rdatalen); (*data) += rdatalen; (*data_len) -= rdatalen; } w += gldns_str_print(str, str_len, "\n"); return w; } getdns-0.9.0/src/gldns/parseutil.h0000664000175100017510000001137112641212403014006 00000000000000/* * parseutil.h - parse utilities for string and wire conversion * * (c) NLnet Labs, 2004 * * See the file LICENSE for the license */ /** * \file * * Utility functions for parsing, base32(DNS variant) and base64 encoding * and decoding, Hex, Time units, Escape codes. */ #ifndef GLDNS_PARSEUTIL_H #define GLDNS_PARSEUTIL_H struct tm; /** * A general purpose lookup table * * Lookup tables are arrays of (id, name) pairs, * So you can for instance lookup the RCODE 3, which is "NXDOMAIN", * and vice versa. The lookup tables themselves are defined wherever needed, * for instance in host2str.c */ struct gldns_struct_lookup_table { int id; const char *name; }; typedef struct gldns_struct_lookup_table gldns_lookup_table; /** * Looks up the table entry by name, returns NULL if not found. * \param[in] table the lookup table to search in * \param[in] name what to search for * \return the item found */ gldns_lookup_table *gldns_lookup_by_name(gldns_lookup_table table[], const char *name); /** * Looks up the table entry by id, returns NULL if not found. * \param[in] table the lookup table to search in * \param[in] id what to search for * \return the item found */ gldns_lookup_table *gldns_lookup_by_id(gldns_lookup_table table[], int id); /** * Convert TM to seconds since epoch (midnight, January 1st, 1970). * Like timegm(3), which is not always available. * \param[in] tm a struct tm* with the date * \return the seconds since epoch */ time_t gldns_mktime_from_utc(const struct tm *tm); /** * The function interprets time as the number of seconds since epoch * with respect to now using serial arithmitics (rfc1982). * That number of seconds is then converted to broken-out time information. * This is especially usefull when converting the inception and expiration * fields of RRSIG records. * * \param[in] time number of seconds since epoch (midnight, January 1st, 1970) * to be intepreted as a serial arithmitics number relative to now. * \param[in] now number of seconds since epoch (midnight, January 1st, 1970) * to which the time value is compared to determine the final value. * \param[out] result the struct with the broken-out time information * \return result on success or NULL on error */ struct tm * gldns_serial_arithmitics_gmtime_r(int32_t time, time_t now, struct tm *result); /** * converts a ttl value (like 5d2h) to a long. * \param[in] nptr the start of the string * \param[out] endptr points to the last char in case of error * \return the convert duration value */ uint32_t gldns_str2period(const char *nptr, const char **endptr); /** * Returns the int value of the given (hex) digit * \param[in] ch the hex char to convert * \return the converted decimal value */ int gldns_hexdigit_to_int(char ch); /** * calculates the size needed to store the result of b64_ntop */ size_t gldns_b64_ntop_calculate_size(size_t srcsize); int gldns_b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize); /** * calculates the size needed to store the result of gldns_b64_pton */ size_t gldns_b64_pton_calculate_size(size_t srcsize); int gldns_b64_pton(char const *src, uint8_t *target, size_t targsize); /** * calculates the size needed to store the result of b32_ntop */ size_t gldns_b32_ntop_calculate_size(size_t src_data_length); size_t gldns_b32_ntop_calculate_size_no_padding(size_t src_data_length); int gldns_b32_ntop(const uint8_t* src_data, size_t src_data_length, char* target_text_buffer, size_t target_text_buffer_size); int gldns_b32_ntop_extended_hex(const uint8_t* src_data, size_t src_data_length, char* target_text_buffer, size_t target_text_buffer_size); /** * calculates the size needed to store the result of b32_pton */ size_t gldns_b32_pton_calculate_size(size_t src_text_length); int gldns_b32_pton(const char* src_text, size_t src_text_length, uint8_t* target_data_buffer, size_t target_data_buffer_size); int gldns_b32_pton_extended_hex(const char* src_text, size_t src_text_length, uint8_t* target_data_buffer, size_t target_data_buffer_size); /* * Checks whether the escaped value at **s is an octal value or * a 'normally' escaped character (and not eos) * * @param ch_p: the parsed character * @param str_p: the string. moved along for characters read. * The string pointer at *s is increased by either 0 (on error), 1 (on * normal escapes), or 3 (on octals) * * @return 0 on error */ int gldns_parse_escape(uint8_t *ch_p, const char** str_p); /** * Parse one character, with escape codes, * @param ch_p: the parsed character * @param str_p: the string. moved along for characters read. * @return 0 on error */ int gldns_parse_char(uint8_t *ch_p, const char** str_p); #endif /* GLDNS_PARSEUTIL_H */ getdns-0.9.0/src/gldns/keyraw.c0000664000175100017510000001735212641212403013300 00000000000000/* * keyraw.c - raw key operations and conversions * * (c) NLnet Labs, 2004-2008 * * See the file LICENSE for the license */ /** * \file * Implementation of raw DNSKEY functions (work on wire rdata). */ #include "config.h" #include "gldns/keyraw.h" #include "gldns/rrdef.h" #ifdef HAVE_SSL #include #include #include #include #include #ifdef HAVE_OPENSSL_ENGINE_H # include #endif #endif /* HAVE_SSL */ size_t gldns_rr_dnskey_key_size_raw(const unsigned char* keydata, const size_t len, int alg) { /* for DSA keys */ uint8_t t; /* for RSA keys */ uint16_t exp; uint16_t int16; switch ((gldns_algorithm)alg) { case GLDNS_DSA: case GLDNS_DSA_NSEC3: if (len > 0) { t = keydata[0]; return (64 + t*8)*8; } else { return 0; } break; case GLDNS_RSAMD5: case GLDNS_RSASHA1: case GLDNS_RSASHA1_NSEC3: #ifdef USE_SHA2 case GLDNS_RSASHA256: case GLDNS_RSASHA512: #endif if (len > 0) { if (keydata[0] == 0) { /* big exponent */ if (len > 3) { memmove(&int16, keydata + 1, 2); exp = ntohs(int16); return (len - exp - 3)*8; } else { return 0; } } else { exp = keydata[0]; return (len-exp-1)*8; } } else { return 0; } break; #ifdef USE_GOST case GLDNS_ECC_GOST: return 512; #endif #ifdef USE_ECDSA case GLDNS_ECDSAP256SHA256: return 256; case GLDNS_ECDSAP384SHA384: return 384; #endif default: return 0; } } uint16_t gldns_calc_keytag_raw(uint8_t* key, size_t keysize) { if(keysize < 4) { return 0; } /* look at the algorithm field, copied from 2535bis */ if (key[3] == GLDNS_RSAMD5) { uint16_t ac16 = 0; if (keysize > 4) { memmove(&ac16, key + keysize - 3, 2); } ac16 = ntohs(ac16); return (uint16_t) ac16; } else { size_t i; uint32_t ac32 = 0; for (i = 0; i < keysize; ++i) { ac32 += (i & 1) ? key[i] : key[i] << 8; } ac32 += (ac32 >> 16) & 0xFFFF; return (uint16_t) (ac32 & 0xFFFF); } } #ifdef HAVE_SSL #ifdef USE_GOST /** store GOST engine reference loaded into OpenSSL library */ ENGINE* gldns_gost_engine = NULL; int gldns_key_EVP_load_gost_id(void) { static int gost_id = 0; const EVP_PKEY_ASN1_METHOD* meth; ENGINE* e; if(gost_id) return gost_id; /* see if configuration loaded gost implementation from other engine*/ meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1); if(meth) { EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); return gost_id; } /* see if engine can be loaded already */ e = ENGINE_by_id("gost"); if(!e) { /* load it ourself, in case statically linked */ ENGINE_load_builtin_engines(); ENGINE_load_dynamic(); e = ENGINE_by_id("gost"); } if(!e) { /* no gost engine in openssl */ return 0; } if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) { ENGINE_finish(e); ENGINE_free(e); return 0; } meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1); if(!meth) { /* algo not found */ ENGINE_finish(e); ENGINE_free(e); return 0; } /* Note: do not ENGINE_finish and ENGINE_free the acquired engine * on some platforms this frees up the meth and unloads gost stuff */ gldns_gost_engine = e; EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); return gost_id; } void gldns_key_EVP_unload_gost(void) { if(gldns_gost_engine) { ENGINE_finish(gldns_gost_engine); ENGINE_free(gldns_gost_engine); gldns_gost_engine = NULL; } } #endif /* USE_GOST */ DSA * gldns_key_buf2dsa_raw(unsigned char* key, size_t len) { uint8_t T; uint16_t length; uint16_t offset; DSA *dsa; BIGNUM *Q; BIGNUM *P; BIGNUM *G; BIGNUM *Y; if(len == 0) return NULL; T = (uint8_t)key[0]; length = (64 + T * 8); offset = 1; if (T > 8) { return NULL; } if(len < (size_t)1 + SHA_DIGEST_LENGTH + 3*length) return NULL; Q = BN_bin2bn(key+offset, SHA_DIGEST_LENGTH, NULL); offset += SHA_DIGEST_LENGTH; P = BN_bin2bn(key+offset, (int)length, NULL); offset += length; G = BN_bin2bn(key+offset, (int)length, NULL); offset += length; Y = BN_bin2bn(key+offset, (int)length, NULL); offset += length; /* create the key and set its properties */ if(!Q || !P || !G || !Y || !(dsa = DSA_new())) { BN_free(Q); BN_free(P); BN_free(G); BN_free(Y); return NULL; } #ifndef S_SPLINT_S dsa->p = P; dsa->q = Q; dsa->g = G; dsa->pub_key = Y; #endif /* splint */ return dsa; } RSA * gldns_key_buf2rsa_raw(unsigned char* key, size_t len) { uint16_t offset; uint16_t exp; uint16_t int16; RSA *rsa; BIGNUM *modulus; BIGNUM *exponent; if (len == 0) return NULL; if (key[0] == 0) { if(len < 3) return NULL; memmove(&int16, key+1, 2); exp = ntohs(int16); offset = 3; } else { exp = key[0]; offset = 1; } /* key length at least one */ if(len < (size_t)offset + exp + 1) return NULL; /* Exponent */ exponent = BN_new(); if(!exponent) return NULL; (void) BN_bin2bn(key+offset, (int)exp, exponent); offset += exp; /* Modulus */ modulus = BN_new(); if(!modulus) { BN_free(exponent); return NULL; } /* length of the buffer must match the key length! */ (void) BN_bin2bn(key+offset, (int)(len - offset), modulus); rsa = RSA_new(); if(!rsa) { BN_free(exponent); BN_free(modulus); return NULL; } #ifndef S_SPLINT_S rsa->n = modulus; rsa->e = exponent; #endif /* splint */ return rsa; } #ifdef USE_GOST EVP_PKEY* gldns_gost2pkey_raw(unsigned char* key, size_t keylen) { /* prefix header for X509 encoding */ uint8_t asn[37] = { 0x30, 0x63, 0x30, 0x1c, 0x06, 0x06, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x13, 0x30, 0x12, 0x06, 0x07, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x23, 0x01, 0x06, 0x07, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x1e, 0x01, 0x03, 0x43, 0x00, 0x04, 0x40}; unsigned char encoded[37+64]; const unsigned char* pp; if(keylen != 64) { /* key wrong size */ return NULL; } /* create evp_key */ memmove(encoded, asn, 37); memmove(encoded+37, key, 64); pp = (unsigned char*)&encoded[0]; return d2i_PUBKEY(NULL, &pp, (int)sizeof(encoded)); } #endif /* USE_GOST */ #ifdef USE_ECDSA EVP_PKEY* gldns_ecdsa2pkey_raw(unsigned char* key, size_t keylen, uint8_t algo) { unsigned char buf[256+2]; /* sufficient for 2*384/8+1 */ const unsigned char* pp = buf; EVP_PKEY *evp_key; EC_KEY *ec; /* check length, which uncompressed must be 2 bignums */ if(algo == GLDNS_ECDSAP256SHA256) { if(keylen != 2*256/8) return NULL; ec = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); } else if(algo == GLDNS_ECDSAP384SHA384) { if(keylen != 2*384/8) return NULL; ec = EC_KEY_new_by_curve_name(NID_secp384r1); } else ec = NULL; if(!ec) return NULL; if(keylen+1 > sizeof(buf)) return NULL; /* sanity check */ /* prepend the 0x02 (from docs) (or actually 0x04 from implementation * of openssl) for uncompressed data */ buf[0] = POINT_CONVERSION_UNCOMPRESSED; memmove(buf+1, key, keylen); if(!o2i_ECPublicKey(&ec, &pp, (int)keylen+1)) { EC_KEY_free(ec); return NULL; } evp_key = EVP_PKEY_new(); if(!evp_key) { EC_KEY_free(ec); return NULL; } if (!EVP_PKEY_assign_EC_KEY(evp_key, ec)) { EVP_PKEY_free(evp_key); EC_KEY_free(ec); return NULL; } return evp_key; } #endif /* USE_ECDSA */ int gldns_digest_evp(unsigned char* data, unsigned int len, unsigned char* dest, const EVP_MD* md) { EVP_MD_CTX* ctx; ctx = EVP_MD_CTX_create(); if(!ctx) return 0; if(!EVP_DigestInit_ex(ctx, md, NULL) || !EVP_DigestUpdate(ctx, data, len) || !EVP_DigestFinal_ex(ctx, dest, NULL)) { EVP_MD_CTX_destroy(ctx); return 0; } EVP_MD_CTX_destroy(ctx); return 1; } #endif /* HAVE_SSL */ getdns-0.9.0/src/gldns/pkthdr.h0000664000175100017510000001176512641212403013301 00000000000000/* * pkthdr.h - packet header from wire conversion routines * * a Net::DNS like library for C * * (c) NLnet Labs, 2005-2006 * * See the file LICENSE for the license */ /** * \file * * Contains functions that translate dns data from the wire format (as sent * by servers and clients) to the internal structures for the packet header. */ #ifndef GLDNS_PKTHDR_H #define GLDNS_PKTHDR_H #ifdef __cplusplus extern "C" { #endif /* The length of the header */ #define GLDNS_HEADER_SIZE 12 /* First octet of flags */ #define GLDNS_RD_MASK 0x01U #define GLDNS_RD_SHIFT 0 #define GLDNS_RD_WIRE(wirebuf) (*(wirebuf+2) & GLDNS_RD_MASK) #define GLDNS_RD_SET(wirebuf) (*(wirebuf+2) |= GLDNS_RD_MASK) #define GLDNS_RD_CLR(wirebuf) (*(wirebuf+2) &= ~GLDNS_RD_MASK) #define GLDNS_TC_MASK 0x02U #define GLDNS_TC_SHIFT 1 #define GLDNS_TC_WIRE(wirebuf) (*(wirebuf+2) & GLDNS_TC_MASK) #define GLDNS_TC_SET(wirebuf) (*(wirebuf+2) |= GLDNS_TC_MASK) #define GLDNS_TC_CLR(wirebuf) (*(wirebuf+2) &= ~GLDNS_TC_MASK) #define GLDNS_AA_MASK 0x04U #define GLDNS_AA_SHIFT 2 #define GLDNS_AA_WIRE(wirebuf) (*(wirebuf+2) & GLDNS_AA_MASK) #define GLDNS_AA_SET(wirebuf) (*(wirebuf+2) |= GLDNS_AA_MASK) #define GLDNS_AA_CLR(wirebuf) (*(wirebuf+2) &= ~GLDNS_AA_MASK) #define GLDNS_OPCODE_MASK 0x78U #define GLDNS_OPCODE_SHIFT 3 #define GLDNS_OPCODE_WIRE(wirebuf) ((*(wirebuf+2) & GLDNS_OPCODE_MASK) >> GLDNS_OPCODE_SHIFT) #define GLDNS_OPCODE_SET(wirebuf, opcode) \ (*(wirebuf+2) = ((*(wirebuf+2)) & ~GLDNS_OPCODE_MASK) | ((opcode) << GLDNS_OPCODE_SHIFT)) #define GLDNS_QR_MASK 0x80U #define GLDNS_QR_SHIFT 7 #define GLDNS_QR_WIRE(wirebuf) (*(wirebuf+2) & GLDNS_QR_MASK) #define GLDNS_QR_SET(wirebuf) (*(wirebuf+2) |= GLDNS_QR_MASK) #define GLDNS_QR_CLR(wirebuf) (*(wirebuf+2) &= ~GLDNS_QR_MASK) /* Second octet of flags */ #define GLDNS_RCODE_MASK 0x0fU #define GLDNS_RCODE_SHIFT 0 #define GLDNS_RCODE_WIRE(wirebuf) (*(wirebuf+3) & GLDNS_RCODE_MASK) #define GLDNS_RCODE_SET(wirebuf, rcode) \ (*(wirebuf+3) = ((*(wirebuf+3)) & ~GLDNS_RCODE_MASK) | (rcode)) #define GLDNS_CD_MASK 0x10U #define GLDNS_CD_SHIFT 4 #define GLDNS_CD_WIRE(wirebuf) (*(wirebuf+3) & GLDNS_CD_MASK) #define GLDNS_CD_SET(wirebuf) (*(wirebuf+3) |= GLDNS_CD_MASK) #define GLDNS_CD_CLR(wirebuf) (*(wirebuf+3) &= ~GLDNS_CD_MASK) #define GLDNS_AD_MASK 0x20U #define GLDNS_AD_SHIFT 5 #define GLDNS_AD_WIRE(wirebuf) (*(wirebuf+3) & GLDNS_AD_MASK) #define GLDNS_AD_SET(wirebuf) (*(wirebuf+3) |= GLDNS_AD_MASK) #define GLDNS_AD_CLR(wirebuf) (*(wirebuf+3) &= ~GLDNS_AD_MASK) #define GLDNS_Z_MASK 0x40U #define GLDNS_Z_SHIFT 6 #define GLDNS_Z_WIRE(wirebuf) (*(wirebuf+3) & GLDNS_Z_MASK) #define GLDNS_Z_SET(wirebuf) (*(wirebuf+3) |= GLDNS_Z_MASK) #define GLDNS_Z_CLR(wirebuf) (*(wirebuf+3) &= ~GLDNS_Z_MASK) #define GLDNS_RA_MASK 0x80U #define GLDNS_RA_SHIFT 7 #define GLDNS_RA_WIRE(wirebuf) (*(wirebuf+3) & GLDNS_RA_MASK) #define GLDNS_RA_SET(wirebuf) (*(wirebuf+3) |= GLDNS_RA_MASK) #define GLDNS_RA_CLR(wirebuf) (*(wirebuf+3) &= ~GLDNS_RA_MASK) /* Query ID */ #define GLDNS_ID_WIRE(wirebuf) (gldns_read_uint16(wirebuf)) #define GLDNS_ID_SET(wirebuf, id) (gldns_write_uint16(wirebuf, id)) /* Counter of the question section */ #define GLDNS_QDCOUNT_OFF 4 /* #define QDCOUNT(wirebuf) (ntohs(*(uint16_t *)(wirebuf+QDCOUNT_OFF))) */ #define GLDNS_QDCOUNT(wirebuf) (gldns_read_uint16(wirebuf+GLDNS_QDCOUNT_OFF)) /* Counter of the answer section */ #define GLDNS_ANCOUNT_OFF 6 #define GLDNS_ANCOUNT(wirebuf) (gldns_read_uint16(wirebuf+GLDNS_ANCOUNT_OFF)) /* Counter of the authority section */ #define GLDNS_NSCOUNT_OFF 8 #define GLDNS_NSCOUNT(wirebuf) (gldns_read_uint16(wirebuf+GLDNS_NSCOUNT_OFF)) /* Counter of the additional section */ #define GLDNS_ARCOUNT_OFF 10 #define GLDNS_ARCOUNT(wirebuf) (gldns_read_uint16(wirebuf+GLDNS_ARCOUNT_OFF)) /** * The sections of a packet */ enum gldns_enum_pkt_section { GLDNS_SECTION_QUESTION = 0, GLDNS_SECTION_ANSWER = 1, GLDNS_SECTION_AUTHORITY = 2, GLDNS_SECTION_ADDITIONAL = 3, /** bogus section, if not interested */ GLDNS_SECTION_ANY = 4, /** used to get all non-question rrs from a packet */ GLDNS_SECTION_ANY_NOQUESTION = 5 }; typedef enum gldns_enum_pkt_section gldns_pkt_section; /* opcodes for pkt's */ enum gldns_enum_pkt_opcode { GLDNS_PACKET_QUERY = 0, GLDNS_PACKET_IQUERY = 1, GLDNS_PACKET_STATUS = 2, /* there is no 3?? DNS is weird */ GLDNS_PACKET_NOTIFY = 4, GLDNS_PACKET_UPDATE = 5 }; typedef enum gldns_enum_pkt_opcode gldns_pkt_opcode; /* rcodes for pkts */ enum gldns_enum_pkt_rcode { GLDNS_RCODE_NOERROR = 0, GLDNS_RCODE_FORMERR = 1, GLDNS_RCODE_SERVFAIL = 2, GLDNS_RCODE_NXDOMAIN = 3, GLDNS_RCODE_NOTIMPL = 4, GLDNS_RCODE_REFUSED = 5, GLDNS_RCODE_YXDOMAIN = 6, GLDNS_RCODE_YXRRSET = 7, GLDNS_RCODE_NXRRSET = 8, GLDNS_RCODE_NOTAUTH = 9, GLDNS_RCODE_NOTZONE = 10 }; typedef enum gldns_enum_pkt_rcode gldns_pkt_rcode; #ifdef __cplusplus } #endif #endif /* GLDNS_PKTHDR_H */ getdns-0.9.0/src/gldns/str2wire.c0000664000175100017510000015310212641212403013551 00000000000000/** * str2wire.c - read txt presentation of RRs * * (c) NLnet Labs, 2005-2006 * * See the file LICENSE for the license */ /** * \file * * Parses text to wireformat. */ #include "config.h" #include "gldns/str2wire.h" #include "gldns/wire2str.h" #include "gldns/gbuffer.h" #include "gldns/parse.h" #include "gldns/parseutil.h" #include #ifdef HAVE_TIME_H #include #endif #ifdef HAVE_NETDB_H #include #endif /** return an error */ #define RET_ERR(e, off) ((int)((e)|((off)< GLDNS_MAX_DOMAINLEN * 4) { return RET_ERR(GLDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, 0); } if (0 == len) { return RET_ERR(GLDNS_WIREPARSE_ERR_DOMAINNAME_UNDERFLOW, 0); } /* root label */ if (1 == len && *str == '.') { if(*olen < 1) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, 0); buf[0] = 0; *olen = 1; return GLDNS_WIREPARSE_ERR_OK; } /* get on with the rest */ /* s is on the current character in the string * pq points to where the labellength is going to go * label_len keeps track of the current label's length * q builds the dname inside the buf array */ len = 0; if(*olen < 1) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, 0); q = buf+1; pq = buf; label_len = 0; for (s = str; *s; s++, q++) { if (q >= buf + *olen) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, q-buf); if (q > buf + GLDNS_MAX_DOMAINLEN) return RET_ERR(GLDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, q-buf); switch (*s) { case '.': if (label_len > GLDNS_MAX_LABELLEN) { return RET_ERR(GLDNS_WIREPARSE_ERR_LABEL_OVERFLOW, q-buf); } if (label_len == 0) { return RET_ERR(GLDNS_WIREPARSE_ERR_EMPTY_LABEL, q-buf); } len += label_len + 1; *q = 0; *pq = label_len; label_len = 0; pq = q; break; case '\\': /* octet value or literal char */ s += 1; if (!gldns_parse_escape(q, &s)) { *q = 0; return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE, q-buf); } s -= 1; label_len++; break; default: *q = (uint8_t)*s; label_len++; } } /* add root label if last char was not '.' */ if(label_len != 0) { if(rel) *rel = 1; if (q >= buf + *olen) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, q-buf); if (q > buf + GLDNS_MAX_DOMAINLEN) { return RET_ERR(GLDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, q-buf); } if (label_len > GLDNS_MAX_LABELLEN) { return RET_ERR(GLDNS_WIREPARSE_ERR_LABEL_OVERFLOW, q-buf); } if (label_len == 0) { /* label_len 0 but not . at end? */ return RET_ERR(GLDNS_WIREPARSE_ERR_EMPTY_LABEL, q-buf); } len += label_len + 1; *pq = label_len; *q = 0; } len++; *olen = len; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_dname_buf(const char* str, uint8_t* buf, size_t* len) { return gldns_str2wire_dname_buf_rel(str, buf, len, NULL); } int gldns_str2wire_dname_buf_origin(const char* str, uint8_t* buf, size_t* len, uint8_t* origin, size_t origin_len) { size_t dlen = *len; int rel = 0; int s = gldns_str2wire_dname_buf_rel(str, buf, &dlen, &rel); if(s) return s; if(rel && origin && dlen > 0) { if(dlen + origin_len - 1 > GLDNS_MAX_DOMAINLEN) return RET_ERR(GLDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, GLDNS_MAX_DOMAINLEN); if(dlen + origin_len - 1 > *len) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, *len); memmove(buf+dlen-1, origin, origin_len); *len = dlen + origin_len - 1; } else *len = dlen; return GLDNS_WIREPARSE_ERR_OK; } uint8_t* gldns_str2wire_dname(const char* str, size_t* len) { uint8_t dname[GLDNS_MAX_DOMAINLEN+1]; *len = sizeof(dname); if(gldns_str2wire_dname_buf(str, dname, len) == 0) { uint8_t* r = (uint8_t*)malloc(*len); if(r) return memcpy(r, dname, *len); } *len = 0; return NULL; } /** read owner name */ static int rrinternal_get_owner(gldns_buffer* strbuf, uint8_t* rr, size_t* len, size_t* dname_len, uint8_t* origin, size_t origin_len, uint8_t* prev, size_t prev_len, char* token, size_t token_len) { /* split the rr in its parts -1 signals trouble */ if(gldns_bget_token(strbuf, token, "\t\n ", token_len) == -1) { return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX, gldns_buffer_position(strbuf)); } if(strcmp(token, "@") == 0) { uint8_t* tocopy; if (origin) { *dname_len = origin_len; tocopy = origin; } else if (prev) { *dname_len = prev_len; tocopy = prev; } else { /* default to root */ *dname_len = 1; tocopy = (uint8_t*)"\0"; } if(*len < *dname_len) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, gldns_buffer_position(strbuf)); memmove(rr, tocopy, *dname_len); } else if(strlen(token) == 0) { /* no ownername was given, try prev, if that fails * origin, else default to root */ uint8_t* tocopy; if(prev) { *dname_len = prev_len; tocopy = prev; } else if(origin) { *dname_len = origin_len; tocopy = origin; } else { *dname_len = 1; tocopy = (uint8_t*)"\0"; } if(*len < *dname_len) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, gldns_buffer_position(strbuf)); memmove(rr, tocopy, *dname_len); } else { size_t dlen = *len; int s = gldns_str2wire_dname_buf_origin(token, rr, &dlen, origin, origin_len); if(s) return RET_ERR_SHIFT(s, gldns_buffer_position(strbuf)-strlen(token)); *dname_len = dlen; } return GLDNS_WIREPARSE_ERR_OK; } /** read ttl */ static int rrinternal_get_ttl(gldns_buffer* strbuf, char* token, size_t token_len, int* not_there, uint32_t* ttl, uint32_t default_ttl) { const char* endptr; if(gldns_bget_token(strbuf, token, "\t\n ", token_len) == -1) { return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_TTL, gldns_buffer_position(strbuf)); } *ttl = (uint32_t) gldns_str2period(token, &endptr); if (strlen(token) > 0 && !isdigit((int)token[0])) { *not_there = 1; /* ah, it's not there or something */ if (default_ttl == 0) { *ttl = GLDNS_DEFAULT_TTL; } else { *ttl = default_ttl; } } return GLDNS_WIREPARSE_ERR_OK; } /** read class */ static int rrinternal_get_class(gldns_buffer* strbuf, char* token, size_t token_len, int* not_there, uint16_t* cl) { /* if 'not_there' then we got token from previous parse routine */ if(!*not_there) { /* parse new token for class */ if(gldns_bget_token(strbuf, token, "\t\n ", token_len) == -1) { return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_CLASS, gldns_buffer_position(strbuf)); } } else *not_there = 0; *cl = gldns_get_rr_class_by_name(token); /* class can be left out too, assume IN, current token must be type */ if(*cl == 0 && strcmp(token, "CLASS0") != 0) { *not_there = 1; *cl = GLDNS_RR_CLASS_IN; } return GLDNS_WIREPARSE_ERR_OK; } /** read type */ static int rrinternal_get_type(gldns_buffer* strbuf, char* token, size_t token_len, int* not_there, uint16_t* tp) { /* if 'not_there' then we got token from previous parse routine */ if(!*not_there) { /* parse new token for type */ if(gldns_bget_token(strbuf, token, "\t\n ", token_len) == -1) { return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_TYPE, gldns_buffer_position(strbuf)); } } *tp = gldns_get_rr_type_by_name(token); if(*tp == 0 && strcmp(token, "TYPE0") != 0) { return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_TYPE, gldns_buffer_position(strbuf)); } return GLDNS_WIREPARSE_ERR_OK; } /** put type, class, ttl into rr buffer */ static int rrinternal_write_typeclassttl(gldns_buffer* strbuf, uint8_t* rr, size_t len, size_t dname_len, uint16_t tp, uint16_t cl, uint32_t ttl, int question) { if(question) { /* question is : name, type, class */ if(dname_len + 4 > len) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, gldns_buffer_position(strbuf)); gldns_write_uint16(rr+dname_len, tp); gldns_write_uint16(rr+dname_len+2, cl); return GLDNS_WIREPARSE_ERR_OK; } /* type(2), class(2), ttl(4), rdatalen(2 (later)) = 10 */ if(dname_len + 10 > len) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, gldns_buffer_position(strbuf)); gldns_write_uint16(rr+dname_len, tp); gldns_write_uint16(rr+dname_len+2, cl); gldns_write_uint32(rr+dname_len+4, ttl); gldns_write_uint16(rr+dname_len+8, 0); /* rdatalen placeholder */ return GLDNS_WIREPARSE_ERR_OK; } /** find delimiters for type */ static const char* rrinternal_get_delims(gldns_rdf_type rdftype, uint16_t r_cnt, uint16_t r_max) { switch(rdftype) { case GLDNS_RDF_TYPE_B64 : case GLDNS_RDF_TYPE_HEX : /* These rdf types may con- */ case GLDNS_RDF_TYPE_LOC : /* tain whitespace, only if */ case GLDNS_RDF_TYPE_WKS : /* it is the last rd field. */ case GLDNS_RDF_TYPE_IPSECKEY : case GLDNS_RDF_TYPE_NSEC : if (r_cnt == r_max - 1) { return "\n\t"; } break; default : break; } return "\n\t "; } /* Syntactic sugar for gldns_rr_new_frm_str_internal */ static int gldns_rdf_type_maybe_quoted(gldns_rdf_type rdf_type) { return rdf_type == GLDNS_RDF_TYPE_STR || rdf_type == GLDNS_RDF_TYPE_LONG_STR; } /** see if rdata is quoted */ static int rrinternal_get_quoted(gldns_buffer* strbuf, const char** delimiters, gldns_rdf_type rdftype) { if(gldns_rdf_type_maybe_quoted(rdftype) && gldns_buffer_remaining(strbuf) > 0) { /* skip spaces */ while(gldns_buffer_remaining(strbuf) > 0 && *(gldns_buffer_current(strbuf)) == ' ') { gldns_buffer_skip(strbuf, 1); } if(gldns_buffer_remaining(strbuf) > 0 && *(gldns_buffer_current(strbuf)) == '\"') { *delimiters = "\"\0"; gldns_buffer_skip(strbuf, 1); return 1; } } return 0; } /** spool hex data into rdata */ static int rrinternal_spool_hex(char* token, uint8_t* rr, size_t rr_len, size_t rr_cur_len, size_t* cur_hex_data_size, size_t hex_data_size) { char* p = token; while(*p) { if(isspace(*p)) { p++; continue; } if(!isxdigit(*p)) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_RDATA, p-token); if(*cur_hex_data_size >= hex_data_size) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_RDATA, p-token); /* extra robust check */ if(rr_cur_len+(*cur_hex_data_size)/2 >= rr_len) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, p-token); /* see if 16s or 1s */ if( ((*cur_hex_data_size)&1) == 0) { rr[rr_cur_len+(*cur_hex_data_size)/2] = (uint8_t)gldns_hexdigit_to_int(*p)*16; } else { rr[rr_cur_len+(*cur_hex_data_size)/2] += (uint8_t)gldns_hexdigit_to_int(*p); } p++; (*cur_hex_data_size)++; } return GLDNS_WIREPARSE_ERR_OK; } /** read unknown rr type format */ static int rrinternal_parse_unknown(gldns_buffer* strbuf, char* token, size_t token_len, uint8_t* rr, size_t* rr_len, size_t* rr_cur_len, size_t pre_data_pos) { const char* delim = "\n\t "; size_t hex_data_size, cur_hex_data_size; /* go back to before \# * and skip it while setting delimiters better */ gldns_buffer_set_position(strbuf, pre_data_pos); if(gldns_bget_token(strbuf, token, delim, token_len) == -1) return GLDNS_WIREPARSE_ERR_GENERAL; /* should not fail */ /* read rdata octet length */ if(gldns_bget_token(strbuf, token, delim, token_len) == -1) { /* something goes very wrong here */ return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_RDATA, gldns_buffer_position(strbuf)); } hex_data_size = (size_t)atoi(token); if(hex_data_size > GLDNS_MAX_RDFLEN || *rr_cur_len + hex_data_size > *rr_len) { return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, gldns_buffer_position(strbuf)); } /* copy hex chars into hex str (2 chars per byte) */ hex_data_size *= 2; cur_hex_data_size = 0; while(cur_hex_data_size < hex_data_size) { int status; ssize_t c = gldns_bget_token(strbuf, token, delim, token_len); if((status = rrinternal_spool_hex(token, rr, *rr_len, *rr_cur_len, &cur_hex_data_size, hex_data_size)) != 0) return RET_ERR_SHIFT(status, gldns_buffer_position(strbuf)-strlen(token)); if(c == -1) { if(cur_hex_data_size != hex_data_size) return RET_ERR( GLDNS_WIREPARSE_ERR_SYNTAX_RDATA, gldns_buffer_position(strbuf)); break; } } *rr_cur_len += hex_data_size/2; return GLDNS_WIREPARSE_ERR_OK; } /** parse normal RR rdata element */ 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, uint8_t* origin, size_t origin_len) { size_t len; int status; switch(rdftype) { case GLDNS_RDF_TYPE_DNAME: /* check if the origin should be used or concatenated */ if(strcmp(token, "@") == 0) { uint8_t* tocopy; size_t copylen; if(origin) { copylen = origin_len; tocopy = origin; } else if(rr_type == GLDNS_RR_TYPE_SOA) { copylen = dname_len; tocopy = rr; /* copy rr owner name */ } else { copylen = 1; tocopy = (uint8_t*)"\0"; } if((*rr_cur_len) + copylen > rr_len) return RET_ERR( GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, gldns_buffer_position(strbuf)); memmove(rr+*rr_cur_len, tocopy, copylen); (*rr_cur_len) += copylen; } else { size_t dlen = rr_len - (*rr_cur_len); int s = gldns_str2wire_dname_buf_origin(token, rr+*rr_cur_len, &dlen, origin, origin_len); if(s) return RET_ERR_SHIFT(s, gldns_buffer_position(strbuf)-strlen(token)); (*rr_cur_len) += dlen; } return GLDNS_WIREPARSE_ERR_OK; case GLDNS_RDF_TYPE_HEX: case GLDNS_RDF_TYPE_B64: /* When this is the last rdata field, then the * rest should be read in (cause then these * rdf types may contain spaces). */ if(r_cnt == r_max - 1) { size_t tlen = strlen(token); (void)gldns_bget_token(strbuf, token+tlen, "\n", token_len - tlen); } break; default: break; } len = rr_len - (*rr_cur_len); if((status=gldns_str2wire_rdf_buf(token, rr+(*rr_cur_len), &len, rdftype)) != 0) return RET_ERR_SHIFT(status, gldns_buffer_position(strbuf)-strlen(token)); *rr_cur_len += len; return GLDNS_WIREPARSE_ERR_OK; } /** * Parse one rdf token. Takes care of quotes and parenthesis. */ static int gldns_parse_rdf_token(gldns_buffer* strbuf, char* token, size_t token_len, int* quoted, int* parens, size_t* pre_data_pos, const char* delimiters, gldns_rdf_type rdftype, size_t* token_strlen) { size_t slen; /* skip spaces */ while(gldns_buffer_remaining(strbuf) > 0 && !*quoted && *(gldns_buffer_current(strbuf)) == ' ') { gldns_buffer_skip(strbuf, 1); } *pre_data_pos = gldns_buffer_position(strbuf); if(gldns_bget_token_par(strbuf, token, (*quoted)?"\"":delimiters, token_len, parens, (*quoted)?NULL:" \t") == -1) { return 0; } slen = strlen(token); /* check if not quoted yet, and we have encountered quotes */ if(!*quoted && gldns_rdf_type_maybe_quoted(rdftype) && slen >= 2 && (token[0] == '"' || token[0] == '\'') && (token[slen-1] == '"' || token[slen-1] == '\'')) { /* move token two smaller (quotes) with endnull */ memmove(token, token+1, slen-2); token[slen-2] = 0; slen -= 2; *quoted = 1; } else if(!*quoted && gldns_rdf_type_maybe_quoted(rdftype) && slen >= 2 && (token[0] == '"' || token[0] == '\'')) { /* got the start quote (remove it) but read remainder * of quoted string as well into remainder of token */ memmove(token, token+1, slen-1); token[slen-1] = 0; slen -= 1; *quoted = 1; /* rewind buffer over skipped whitespace */ while(gldns_buffer_position(strbuf) > 0 && (gldns_buffer_current(strbuf)[-1] == ' ' || gldns_buffer_current(strbuf)[-1] == '\t')) { gldns_buffer_skip(strbuf, -1); } if(gldns_bget_token_par(strbuf, token+slen, "\"", token_len-slen, parens, NULL) == -1) { return 0; } slen = strlen(token); } *token_strlen = slen; return 1; } /** Add space and one more rdf token onto the existing token string. */ static int gldns_affix_token(gldns_buffer* strbuf, char* token, size_t* token_len, int* quoted, int* parens, size_t* pre_data_pos, const char* delimiters, gldns_rdf_type rdftype, size_t* token_strlen) { size_t addlen = *token_len - *token_strlen; size_t addstrlen = 0; /* add space */ if(addlen < 1) return 0; token[*token_strlen] = ' '; token[++(*token_strlen)] = 0; /* read another token */ addlen = *token_len - *token_strlen; if(!gldns_parse_rdf_token(strbuf, token+*token_strlen, addlen, quoted, parens, pre_data_pos, delimiters, rdftype, &addstrlen)) return 0; (*token_strlen) += addstrlen; return 1; } /** parse rdata from string into rr buffer(-remainder after dname). */ static int rrinternal_parse_rdata(gldns_buffer* strbuf, char* token, size_t token_len, uint8_t* rr, size_t* rr_len, size_t dname_len, uint16_t rr_type, uint8_t* origin, size_t origin_len) { const gldns_rr_descriptor *desc = gldns_rr_descript((uint16_t)rr_type); uint16_t r_cnt, r_min, r_max; size_t rr_cur_len = dname_len + 10, pre_data_pos, token_strlen; int was_unknown_rr_format = 0, parens = 0, status, quoted; const char* delimiters; gldns_rdf_type rdftype; /* a desc is always returned */ if(!desc) return GLDNS_WIREPARSE_ERR_GENERAL; r_max = gldns_rr_descriptor_maximum(desc); r_min = gldns_rr_descriptor_minimum(desc); /* robust check */ if(rr_cur_len > *rr_len) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, gldns_buffer_position(strbuf)); /* because number of fields can be variable, we can't rely on * _maximum() only */ for(r_cnt=0; r_cnt < r_max; r_cnt++) { rdftype = gldns_rr_descriptor_field_type(desc, r_cnt); delimiters = rrinternal_get_delims(rdftype, r_cnt, r_max); quoted = rrinternal_get_quoted(strbuf, &delimiters, rdftype); if(!gldns_parse_rdf_token(strbuf, token, token_len, "ed, &parens, &pre_data_pos, delimiters, rdftype, &token_strlen)) break; /* rfc3597 specifies that any type can be represented * with \# method, which can contain spaces... * it does specify size though... */ /* unknown RR data */ if(token_strlen>=2 && strncmp(token, "\\#", 2) == 0 && !quoted && (token_strlen == 2 || token[2]==' ')) { was_unknown_rr_format = 1; if((status=rrinternal_parse_unknown(strbuf, token, token_len, rr, rr_len, &rr_cur_len, pre_data_pos)) != 0) return status; } else if(token_strlen > 0 || quoted) { if(rdftype == GLDNS_RDF_TYPE_HIP) { /* affix the HIT and PK fields, with a space */ if(!gldns_affix_token(strbuf, token, &token_len, "ed, &parens, &pre_data_pos, delimiters, rdftype, &token_strlen)) break; if(!gldns_affix_token(strbuf, token, &token_len, "ed, &parens, &pre_data_pos, delimiters, rdftype, &token_strlen)) break; } /* normal RR */ if((status=rrinternal_parse_rdf(strbuf, token, token_len, rr, *rr_len, &rr_cur_len, rdftype, rr_type, r_cnt, r_max, dname_len, origin, origin_len)) != 0) { return status; } } } if(!was_unknown_rr_format && r_cnt+1 < r_min) { return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_MISSING_VALUE, gldns_buffer_position(strbuf)); } while(parens != 0) { /* read remainder, must be "" */ if(gldns_bget_token_par(strbuf, token, "\n", token_len, &parens, " \t") == -1) { if(parens != 0) return RET_ERR(GLDNS_WIREPARSE_ERR_PARENTHESIS, gldns_buffer_position(strbuf)); break; } if(strcmp(token, "") != 0) return RET_ERR(GLDNS_WIREPARSE_ERR_PARENTHESIS, gldns_buffer_position(strbuf)); } /* write rdata length */ gldns_write_uint16(rr+dname_len+8, rr_cur_len-dname_len-10); *rr_len = rr_cur_len; return GLDNS_WIREPARSE_ERR_OK; } /* * trailing spaces are allowed * leading spaces are not allowed * allow ttl to be optional * class is optional too * if ttl is missing, and default_ttl is 0, use DEF_TTL * allow ttl to be written as 1d3h * So the RR should look like. e.g. * miek.nl. 3600 IN MX 10 elektron.atoom.net * or * miek.nl. 1h IN MX 10 elektron.atoom.net * or * miek.nl. IN MX 10 elektron.atoom.net */ static int gldns_str2wire_rr_buf_internal(const char* str, uint8_t* rr, size_t* len, size_t* dname_len, uint32_t default_ttl, uint8_t* origin, size_t origin_len, uint8_t* prev, size_t prev_len, int question) { int status; int not_there = 0; char token[GLDNS_MAX_RDFLEN+1]; uint32_t ttl = 0; uint16_t tp = 0, cl = 0; size_t ddlen = 0; /* string in buffer */ gldns_buffer strbuf; gldns_buffer_init_frm_data(&strbuf, (uint8_t*)str, strlen(str)); if(!dname_len) dname_len = &ddlen; /* parse the owner */ if((status=rrinternal_get_owner(&strbuf, rr, len, dname_len, origin, origin_len, prev, prev_len, token, sizeof(token))) != 0) return status; /* parse the [ttl] [class] */ if((status=rrinternal_get_ttl(&strbuf, token, sizeof(token), ¬_there, &ttl, default_ttl)) != 0) return status; if((status=rrinternal_get_class(&strbuf, token, sizeof(token), ¬_there, &cl)) != 0) return status; if((status=rrinternal_get_type(&strbuf, token, sizeof(token), ¬_there, &tp)) != 0) return status; /* put ttl, class, type into the rr result */ if((status=rrinternal_write_typeclassttl(&strbuf, rr, *len, *dname_len, tp, cl, ttl, question)) != 0) return status; /* for a question-RR we are done, no rdata */ if(question) { *len = *dname_len + 4; return GLDNS_WIREPARSE_ERR_OK; } /* rdata */ if((status=rrinternal_parse_rdata(&strbuf, token, sizeof(token), rr, len, *dname_len, tp, origin, origin_len)) != 0) return status; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_rr_buf(const char* str, uint8_t* rr, size_t* len, size_t* dname_len, uint32_t default_ttl, uint8_t* origin, size_t origin_len, uint8_t* prev, size_t prev_len) { return gldns_str2wire_rr_buf_internal(str, rr, len, dname_len, default_ttl, origin, origin_len, prev, prev_len, 0); } int gldns_str2wire_rr_question_buf(const char* str, uint8_t* rr, size_t* len, size_t* dname_len, uint8_t* origin, size_t origin_len, uint8_t* prev, size_t prev_len) { return gldns_str2wire_rr_buf_internal(str, rr, len, dname_len, 0, origin, origin_len, prev, prev_len, 1); } uint16_t gldns_wirerr_get_type(uint8_t* rr, size_t len, size_t dname_len) { if(len < dname_len+2) return 0; return gldns_read_uint16(rr+dname_len); } uint16_t gldns_wirerr_get_class(uint8_t* rr, size_t len, size_t dname_len) { if(len < dname_len+4) return 0; return gldns_read_uint16(rr+dname_len+2); } uint32_t gldns_wirerr_get_ttl(uint8_t* rr, size_t len, size_t dname_len) { if(len < dname_len+8) return 0; return gldns_read_uint32(rr+dname_len+4); } uint16_t gldns_wirerr_get_rdatalen(uint8_t* rr, size_t len, size_t dname_len) { if(len < dname_len+10) return 0; return gldns_read_uint16(rr+dname_len+8); } uint8_t* gldns_wirerr_get_rdata(uint8_t* rr, size_t len, size_t dname_len) { if(len < dname_len+10) return NULL; return rr+dname_len+10; } uint8_t* gldns_wirerr_get_rdatawl(uint8_t* rr, size_t len, size_t dname_len) { if(len < dname_len+10) return NULL; return rr+dname_len+8; } const char* gldns_get_errorstr_parse(int e) { gldns_lookup_table *lt; lt = gldns_lookup_by_id(gldns_wireparse_errors, GLDNS_WIREPARSE_ERROR(e)); return lt?lt->name:"unknown error"; } int gldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len, struct gldns_file_parse_state* parse_state) { char line[GLDNS_RR_BUF_SIZE+1]; ssize_t size; /* read an entire line in from the file */ if((size = gldns_fget_token_l(in, line, GLDNS_PARSE_SKIP_SPACE, GLDNS_RR_BUF_SIZE, parse_state?&parse_state->lineno:NULL)) == -1) { /* if last line was empty, we are now at feof, which is not * always a parse error (happens when for instance last line * was a comment) */ return GLDNS_WIREPARSE_ERR_SYNTAX; } /* we can have the situation, where we've read ok, but still got * no bytes to play with, in this case size is 0 */ if(size == 0) { *len = 0; *dname_len = 0; return GLDNS_WIREPARSE_ERR_OK; } if(strncmp(line, "$ORIGIN", 7) == 0 && isspace(line[7])) { size_t off = 8; int s; *len = 0; *dname_len = 0; if(!parse_state) return GLDNS_WIREPARSE_ERR_OK; while(isspace(line[off])) off++; parse_state->origin_len = sizeof(parse_state->origin); s = gldns_str2wire_dname_buf(line+off, parse_state->origin, &parse_state->origin_len); if(s) parse_state->origin_len = 0; return s; } else if(strncmp(line, "$TTL", 4) == 0 && isspace(line[4])) { const char* end = NULL; size_t off = 5; *len = 0; *dname_len = 0; if(!parse_state) return GLDNS_WIREPARSE_ERR_OK; while(isspace(line[off])) off++; parse_state->default_ttl = gldns_str2period(line+off, &end); } else if (strncmp(line, "$INCLUDE", 8) == 0) { *len = 0; *dname_len = 0; return GLDNS_WIREPARSE_ERR_INCLUDE; } else { return gldns_str2wire_rr_buf(line, rr, len, dname_len, parse_state?parse_state->default_ttl:0, (parse_state&&parse_state->origin_len)? parse_state->origin:NULL, parse_state->origin_len, (parse_state&&parse_state->prev_rr_len)? parse_state->prev_rr:NULL, parse_state->prev_rr_len); } return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_rdf_buf(const char* str, uint8_t* rd, size_t* len, gldns_rdf_type rdftype) { switch (rdftype) { case GLDNS_RDF_TYPE_DNAME: return gldns_str2wire_dname_buf(str, rd, len); case GLDNS_RDF_TYPE_INT8: return gldns_str2wire_int8_buf(str, rd, len); case GLDNS_RDF_TYPE_INT16: return gldns_str2wire_int16_buf(str, rd, len); case GLDNS_RDF_TYPE_INT32: return gldns_str2wire_int32_buf(str, rd, len); case GLDNS_RDF_TYPE_A: return gldns_str2wire_a_buf(str, rd, len); case GLDNS_RDF_TYPE_AAAA: return gldns_str2wire_aaaa_buf(str, rd, len); case GLDNS_RDF_TYPE_STR: return gldns_str2wire_str_buf(str, rd, len); case GLDNS_RDF_TYPE_APL: return gldns_str2wire_apl_buf(str, rd, len); case GLDNS_RDF_TYPE_B64: return gldns_str2wire_b64_buf(str, rd, len); case GLDNS_RDF_TYPE_B32_EXT: return gldns_str2wire_b32_ext_buf(str, rd, len); case GLDNS_RDF_TYPE_HEX: return gldns_str2wire_hex_buf(str, rd, len); case GLDNS_RDF_TYPE_NSEC: return gldns_str2wire_nsec_buf(str, rd, len); case GLDNS_RDF_TYPE_TYPE: return gldns_str2wire_type_buf(str, rd, len); case GLDNS_RDF_TYPE_CLASS: return gldns_str2wire_class_buf(str, rd, len); case GLDNS_RDF_TYPE_CERT_ALG: return gldns_str2wire_cert_alg_buf(str, rd, len); case GLDNS_RDF_TYPE_ALG: return gldns_str2wire_alg_buf(str, rd, len); case GLDNS_RDF_TYPE_TIME: return gldns_str2wire_time_buf(str, rd, len); case GLDNS_RDF_TYPE_PERIOD: return gldns_str2wire_period_buf(str, rd, len); case GLDNS_RDF_TYPE_LOC: return gldns_str2wire_loc_buf(str, rd, len); case GLDNS_RDF_TYPE_WKS: return gldns_str2wire_wks_buf(str, rd, len); case GLDNS_RDF_TYPE_NSAP: return gldns_str2wire_nsap_buf(str, rd, len); case GLDNS_RDF_TYPE_ATMA: return gldns_str2wire_atma_buf(str, rd, len); case GLDNS_RDF_TYPE_IPSECKEY: return gldns_str2wire_ipseckey_buf(str, rd, len); case GLDNS_RDF_TYPE_NSEC3_SALT: return gldns_str2wire_nsec3_salt_buf(str, rd, len); case GLDNS_RDF_TYPE_NSEC3_NEXT_OWNER: return gldns_str2wire_b32_ext_buf(str, rd, len); case GLDNS_RDF_TYPE_ILNP64: return gldns_str2wire_ilnp64_buf(str, rd, len); case GLDNS_RDF_TYPE_EUI48: return gldns_str2wire_eui48_buf(str, rd, len); case GLDNS_RDF_TYPE_EUI64: return gldns_str2wire_eui64_buf(str, rd, len); case GLDNS_RDF_TYPE_TAG: return gldns_str2wire_tag_buf(str, rd, len); case GLDNS_RDF_TYPE_LONG_STR: return gldns_str2wire_long_str_buf(str, rd, len); case GLDNS_RDF_TYPE_HIP: return gldns_str2wire_hip_buf(str, rd, len); case GLDNS_RDF_TYPE_INT16_DATA: return gldns_str2wire_int16_data_buf(str, rd, len); case GLDNS_RDF_TYPE_UNKNOWN: case GLDNS_RDF_TYPE_SERVICE: return GLDNS_WIREPARSE_ERR_NOT_IMPL; case GLDNS_RDF_TYPE_NONE: default: break; } return GLDNS_WIREPARSE_ERR_GENERAL; } int gldns_str2wire_int8_buf(const char* str, uint8_t* rd, size_t* len) { char* end; uint8_t r = (uint8_t)strtol((char*)str, &end, 10); if(*end != 0) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_INT, end-(char*)str); if(*len < 1) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; rd[0] = r; *len = 1; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_int16_buf(const char* str, uint8_t* rd, size_t* len) { char* end; uint16_t r = (uint16_t)strtol((char*)str, &end, 10); if(*end != 0) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_INT, end-(char*)str); if(*len < 2) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; gldns_write_uint16(rd, r); *len = 2; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_int32_buf(const char* str, uint8_t* rd, size_t* len) { char* end; uint32_t r; errno = 0; /* must set to zero before call, note race condition on errno */ if(*str == '-') r = (uint32_t)strtol((char*)str, &end, 10); else r = (uint32_t)strtoul((char*)str, &end, 10); if(*end != 0) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_INT, end-(char*)str); if(errno == ERANGE) return GLDNS_WIREPARSE_ERR_SYNTAX_INTEGER_OVERFLOW; if(*len < 4) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; gldns_write_uint32(rd, r); *len = 4; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_a_buf(const char* str, uint8_t* rd, size_t* len) { struct in_addr address; if(inet_pton(AF_INET, (char*)str, &address) != 1) return GLDNS_WIREPARSE_ERR_SYNTAX_IP4; if(*len < sizeof(address)) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; memmove(rd, &address, sizeof(address)); *len = sizeof(address); return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_aaaa_buf(const char* str, uint8_t* rd, size_t* len) { #ifdef AF_INET6 uint8_t address[GLDNS_IP6ADDRLEN + 1]; if(inet_pton(AF_INET6, (char*)str, address) != 1) return GLDNS_WIREPARSE_ERR_SYNTAX_IP6; if(*len < GLDNS_IP6ADDRLEN) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; memmove(rd, address, GLDNS_IP6ADDRLEN); *len = GLDNS_IP6ADDRLEN; return GLDNS_WIREPARSE_ERR_OK; #else return GLDNS_WIREPARSE_ERR_NOT_IMPL; #endif } int gldns_str2wire_str_buf(const char* str, uint8_t* rd, size_t* len) { uint8_t ch = 0; size_t sl = 0; const char* s = str; /* skip length byte */ if(*len < 1) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; /* read characters */ while(gldns_parse_char(&ch, &s)) { if(sl >= 255) return RET_ERR(GLDNS_WIREPARSE_ERR_INVALID_STR, s-str); if(*len < sl+1) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, s-str); rd[++sl] = ch; } if(!s) return GLDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE; rd[0] = (uint8_t)sl; *len = sl+1; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_apl_buf(const char* str, uint8_t* rd, size_t* len) { const char *my_str = str; char my_ip_str[64]; size_t ip_str_len; uint16_t family; int negation; size_t adflength = 0; uint8_t data[16+4]; uint8_t prefix; size_t i; if(strlen(my_str) == 0) { /* empty APL element, no data, no string */ *len = 0; return GLDNS_WIREPARSE_ERR_OK; } /* [!]afi:address/prefix */ if (strlen(my_str) < 2 || strchr(my_str, ':') == NULL || strchr(my_str, '/') == NULL || strchr(my_str, ':') > strchr(my_str, '/')) { return GLDNS_WIREPARSE_ERR_INVALID_STR; } if (my_str[0] == '!') { negation = 1; my_str += 1; } else { negation = 0; } family = (uint16_t) atoi(my_str); my_str = strchr(my_str, ':') + 1; /* need ip addr and only ip addr for inet_pton */ ip_str_len = (size_t) (strchr(my_str, '/') - my_str); if(ip_str_len+1 > sizeof(my_ip_str)) return GLDNS_WIREPARSE_ERR_INVALID_STR; (void)strlcpy(my_ip_str, my_str, sizeof(my_ip_str)); my_ip_str[ip_str_len] = 0; if (family == 1) { /* ipv4 */ if(inet_pton(AF_INET, my_ip_str, data+4) == 0) return GLDNS_WIREPARSE_ERR_INVALID_STR; for (i = 0; i < 4; i++) { if (data[i+4] != 0) { adflength = i + 1; } } } else if (family == 2) { /* ipv6 */ if (inet_pton(AF_INET6, my_ip_str, data+4) == 0) return GLDNS_WIREPARSE_ERR_INVALID_STR; for (i = 0; i < 16; i++) { if (data[i+4] != 0) { adflength = i + 1; } } } else { /* unknown family */ return GLDNS_WIREPARSE_ERR_INVALID_STR; } my_str = strchr(my_str, '/') + 1; prefix = (uint8_t) atoi(my_str); gldns_write_uint16(data, family); data[2] = prefix; data[3] = (uint8_t)adflength; if (negation) { /* set bit 1 of byte 3 */ data[3] = data[3] | 0x80; } if(*len < 4+adflength) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; memmove(rd, data, 4+adflength); *len = 4+adflength; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_b64_buf(const char* str, uint8_t* rd, size_t* len) { size_t sz = gldns_b64_pton_calculate_size(strlen(str)); int n; if(*len < sz) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; n = gldns_b64_pton(str, rd, *len); if(n < 0) return GLDNS_WIREPARSE_ERR_SYNTAX_B64; *len = (size_t)n; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_b32_ext_buf(const char* str, uint8_t* rd, size_t* len) { size_t slen = strlen(str); size_t sz = gldns_b32_pton_calculate_size(slen); int n; if(*len < 1+sz) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; rd[0] = (uint8_t)sz; n = gldns_b32_pton_extended_hex(str, slen, rd+1, *len-1); if(n < 0) return GLDNS_WIREPARSE_ERR_SYNTAX_B32_EXT; *len = (size_t)n+1; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_hex_buf(const char* str, uint8_t* rd, size_t* len) { const char* s = str; size_t dlen = 0; /* number of hexdigits parsed */ while(*s) { if(isspace(*s)) { s++; continue; } if(!isxdigit(*s)) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str); if(*len < dlen/2 + 1) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, s-str); if((dlen&1)==0) rd[dlen/2] = (uint8_t)gldns_hexdigit_to_int(*s++) * 16; else rd[dlen/2] += (uint8_t)gldns_hexdigit_to_int(*s++); dlen++; } if((dlen&1)!=0) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str); *len = dlen/2; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_nsec_buf(const char* str, uint8_t* rd, size_t* len) { const char *delim = "\n\t "; char token[64]; /* for a type name */ size_t type_count = 0; int block; size_t used = 0; uint16_t maxtype = 0; uint8_t typebits[8192]; /* 65536 bits */ uint8_t window_in_use[256]; /* string in buffer */ gldns_buffer strbuf; gldns_buffer_init_frm_data(&strbuf, (uint8_t*)str, strlen(str)); /* parse the types */ memset(typebits, 0, sizeof(typebits)); memset(window_in_use, 0, sizeof(window_in_use)); while(gldns_buffer_remaining(&strbuf) > 0 && gldns_bget_token(&strbuf, token, delim, sizeof(token)) != -1) { uint16_t t = gldns_get_rr_type_by_name(token); if(token[0] == 0) continue; if(t == 0 && strcmp(token, "TYPE0") != 0) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_TYPE, gldns_buffer_position(&strbuf)); typebits[t/8] |= (0x80>>(t%8)); window_in_use[t/256] = 1; type_count++; if(t > maxtype) maxtype = t; } /* empty NSEC bitmap */ if(type_count == 0) { *len = 0; return GLDNS_WIREPARSE_ERR_OK; } /* encode windows {u8 windowblock, u8 bitmaplength, 0-32u8 bitmap}, * block is 0-255 upper octet of types, length if 0-32. */ for(block = 0; block <= (int)maxtype/256; block++) { int i, blocklen = 0; if(!window_in_use[block]) continue; for(i=0; i<32; i++) { if(typebits[block*32+i] != 0) blocklen = i+1; } if(blocklen == 0) continue; /* empty window should have been !in_use */ if(used+blocklen+2 > *len) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; rd[used+0] = (uint8_t)block; rd[used+1] = (uint8_t)blocklen; for(i=0; iid); } else { int s = gldns_str2wire_int16_buf(str, rd, len); if(s) return s; if(gldns_read_uint16(rd) == 0) return GLDNS_WIREPARSE_ERR_CERT_BAD_ALGORITHM; } *len = 2; return GLDNS_WIREPARSE_ERR_OK; } /* An alg field can either be specified as a 8 bits number * or by its symbolic name. Handle both */ int gldns_str2wire_alg_buf(const char* str, uint8_t* rd, size_t* len) { gldns_lookup_table *lt = gldns_lookup_by_name(gldns_algorithms, str); if(*len < 1) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; if(lt) { rd[0] = (uint8_t)lt->id; *len = 1; } else { /* try as-is (a number) */ return gldns_str2wire_int8_buf(str, rd, len); } return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len) { /* convert a time YYYYDDMMHHMMSS to wireformat */ struct tm tm; if(*len < 4) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; /* Try to scan the time... */ memset(&tm, 0, sizeof(tm)); if (strlen(str) == 14 && sscanf(str, "%4d%2d%2d%2d%2d%2d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) == 6) { tm.tm_year -= 1900; tm.tm_mon--; /* Check values */ if (tm.tm_year < 70) return GLDNS_WIREPARSE_ERR_SYNTAX_TIME; if (tm.tm_mon < 0 || tm.tm_mon > 11) return GLDNS_WIREPARSE_ERR_SYNTAX_TIME; if (tm.tm_mday < 1 || tm.tm_mday > 31) return GLDNS_WIREPARSE_ERR_SYNTAX_TIME; if (tm.tm_hour < 0 || tm.tm_hour > 23) return GLDNS_WIREPARSE_ERR_SYNTAX_TIME; if (tm.tm_min < 0 || tm.tm_min > 59) return GLDNS_WIREPARSE_ERR_SYNTAX_TIME; if (tm.tm_sec < 0 || tm.tm_sec > 59) return GLDNS_WIREPARSE_ERR_SYNTAX_TIME; gldns_write_uint32(rd, gldns_mktime_from_utc(&tm)); } else { /* handle it as 32 bits timestamp */ char *end; uint32_t l = (uint32_t)strtol((char*)str, &end, 10); if(*end != 0) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_TIME, end-(char*)str); gldns_write_uint32(rd, l); } *len = 4; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_period_buf(const char* str, uint8_t* rd, size_t* len) { const char* end; uint32_t p = gldns_str2period(str, &end); if(*end != 0) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_PERIOD, end-str); if(*len < 4) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; gldns_write_uint32(rd, p); *len = 4; return GLDNS_WIREPARSE_ERR_OK; } /** read "[.][mM]" into mantissa exponent format for LOC type */ static int loc_parse_cm(char* my_str, char** endstr, uint8_t* m, uint8_t* e) { uint32_t meters = 0, cm = 0, val; while (isblank(*my_str)) { my_str++; } meters = (uint32_t)strtol(my_str, &my_str, 10); if (*my_str == '.') { my_str++; cm = (uint32_t)strtol(my_str, &my_str, 10); } if (meters >= 1) { *e = 2; val = meters; } else { *e = 0; val = cm; } while(val >= 10) { (*e)++; val /= 10; } *m = (uint8_t)val; if (*e > 9) return 0; if (*my_str == 'm' || *my_str == 'M') { my_str++; } *endstr = my_str; return 1; } int gldns_str2wire_loc_buf(const char* str, uint8_t* rd, size_t* len) { uint32_t latitude = 0; uint32_t longitude = 0; uint32_t altitude = 0; uint32_t equator = (uint32_t)1<<31; /* 2**31 */ /* only support version 0 */ uint32_t h = 0; uint32_t m = 0; uint8_t size_b = 1, size_e = 2; uint8_t horiz_pre_b = 1, horiz_pre_e = 6; uint8_t vert_pre_b = 1, vert_pre_e = 3; double s = 0.0; int northerness; int easterness; char *my_str = (char *) str; if (isdigit((int) *my_str)) { h = (uint32_t) strtol(my_str, &my_str, 10); } else { return GLDNS_WIREPARSE_ERR_INVALID_STR; } while (isblank((int) *my_str)) { my_str++; } if (isdigit((int) *my_str)) { m = (uint32_t) strtol(my_str, &my_str, 10); } else if (*my_str == 'N' || *my_str == 'S') { goto north; } else { return GLDNS_WIREPARSE_ERR_INVALID_STR; } while (isblank((int) *my_str)) { my_str++; } if (isdigit((int) *my_str)) { s = strtod(my_str, &my_str); } /* skip blanks before norterness */ while (isblank((int) *my_str)) { my_str++; } north: if (*my_str == 'N') { northerness = 1; } else if (*my_str == 'S') { northerness = 0; } else { return GLDNS_WIREPARSE_ERR_INVALID_STR; } my_str++; /* store number */ s = 1000.0 * s; /* add a little to make floor in conversion a round */ s += 0.0005; latitude = (uint32_t) s; latitude += 1000 * 60 * m; latitude += 1000 * 60 * 60 * h; if (northerness) { latitude = equator + latitude; } else { latitude = equator - latitude; } while (isblank(*my_str)) { my_str++; } if (isdigit((int) *my_str)) { h = (uint32_t) strtol(my_str, &my_str, 10); } else { return GLDNS_WIREPARSE_ERR_INVALID_STR; } while (isblank((int) *my_str)) { my_str++; } if (isdigit((int) *my_str)) { m = (uint32_t) strtol(my_str, &my_str, 10); } else if (*my_str == 'E' || *my_str == 'W') { goto east; } else { return GLDNS_WIREPARSE_ERR_INVALID_STR; } while (isblank(*my_str)) { my_str++; } if (isdigit((int) *my_str)) { s = strtod(my_str, &my_str); } /* skip blanks before easterness */ while (isblank(*my_str)) { my_str++; } east: if (*my_str == 'E') { easterness = 1; } else if (*my_str == 'W') { easterness = 0; } else { return GLDNS_WIREPARSE_ERR_INVALID_STR; } my_str++; /* store number */ s *= 1000.0; /* add a little to make floor in conversion a round */ s += 0.0005; longitude = (uint32_t) s; longitude += 1000 * 60 * m; longitude += 1000 * 60 * 60 * h; if (easterness) { longitude += equator; } else { longitude = equator - longitude; } altitude = (uint32_t)(strtod(my_str, &my_str)*100.0 + 10000000.0 + 0.5); if (*my_str == 'm' || *my_str == 'M') { my_str++; } if (strlen(my_str) > 0) { if(!loc_parse_cm(my_str, &my_str, &size_b, &size_e)) return GLDNS_WIREPARSE_ERR_INVALID_STR; } if (strlen(my_str) > 0) { if(!loc_parse_cm(my_str, &my_str, &horiz_pre_b, &horiz_pre_e)) return GLDNS_WIREPARSE_ERR_INVALID_STR; } if (strlen(my_str) > 0) { if(!loc_parse_cm(my_str, &my_str, &vert_pre_b, &vert_pre_e)) return GLDNS_WIREPARSE_ERR_INVALID_STR; } if(*len < 16) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; rd[0] = 0; rd[1] = ((size_b << 4) & 0xf0) | (size_e & 0x0f); rd[2] = ((horiz_pre_b << 4) & 0xf0) | (horiz_pre_e & 0x0f); rd[3] = ((vert_pre_b << 4) & 0xf0) | (vert_pre_e & 0x0f); gldns_write_uint32(rd + 4, latitude); gldns_write_uint32(rd + 8, longitude); gldns_write_uint32(rd + 12, altitude); *len = 16; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_wks_buf(const char* str, uint8_t* rd, size_t* len) { int rd_len = 1; int have_proto = 0; char token[50], proto_str[50]; gldns_buffer strbuf; gldns_buffer_init_frm_data(&strbuf, (uint8_t*)str, strlen(str)); proto_str[0]=0; /* check we have one byte for proto */ if(*len < 1) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; while(gldns_bget_token(&strbuf, token, "\t\n ", sizeof(token)) > 0) { if(!have_proto) { struct protoent *p = getprotobyname(token); have_proto = 1; if(p) rd[0] = (uint8_t)p->p_proto; else rd[0] = (uint8_t)atoi(token); (void)strlcpy(proto_str, token, sizeof(proto_str)); } else { int serv_port; struct servent *serv = getservbyname(token, proto_str); if(serv) serv_port=(int)ntohs((uint16_t)serv->s_port); else { serv_port = atoi(token); if(serv_port == 0 && strcmp(token, "0") != 0) { #ifdef HAVE_ENDSERVENT endservent(); #endif #ifdef HAVE_ENDPROTOENT endprotoent(); #endif return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX, gldns_buffer_position(&strbuf)); } if(serv_port < 0 || serv_port > 65535) { #ifdef HAVE_ENDSERVENT endservent(); #endif #ifdef HAVE_ENDPROTOENT endprotoent(); #endif return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX, gldns_buffer_position(&strbuf)); } } if(rd_len < 1+serv_port/8+1) { /* bitmap is larger, init new bytes at 0 */ if(*len < 1+(size_t)serv_port/8+1) { #ifdef HAVE_ENDSERVENT endservent(); #endif #ifdef HAVE_ENDPROTOENT endprotoent(); #endif return RET_ERR( GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, gldns_buffer_position(&strbuf)); } memset(rd+rd_len, 0, 1+(size_t)serv_port/8+1-rd_len); rd_len = 1+serv_port/8+1; } rd[1+ serv_port/8] |= (1 << (7 - serv_port % 8)); } } *len = (size_t)rd_len; #ifdef HAVE_ENDSERVENT endservent(); #endif #ifdef HAVE_ENDPROTOENT endprotoent(); #endif return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_nsap_buf(const char* str, uint8_t* rd, size_t* len) { const char* s = str; size_t slen; size_t dlen = 0; /* number of hexdigits parsed */ /* just a hex string with optional dots? */ if (s[0] != '0' || s[1] != 'x') return GLDNS_WIREPARSE_ERR_INVALID_STR; s += 2; slen = strlen(s); if(slen > GLDNS_MAX_RDFLEN*2) return GLDNS_WIREPARSE_ERR_LABEL_OVERFLOW; while(*s) { if(isspace(*s) || *s == '.') { s++; continue; } if(!isxdigit(*s)) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str); if(*len < dlen/2 + 1) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, s-str); if((dlen&1)==0) rd[dlen/2] = (uint8_t)gldns_hexdigit_to_int(*s++) * 16; else rd[dlen/2] += gldns_hexdigit_to_int(*s++); dlen++; } if((dlen&1)!=0) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str); *len = dlen/2; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_atma_buf(const char* str, uint8_t* rd, size_t* len) { const char* s = str; size_t slen = strlen(str); size_t dlen = 0; /* number of hexdigits parsed */ /* just a hex string with optional dots? */ /* notimpl e.164 format */ if(slen > GLDNS_MAX_RDFLEN*2) return GLDNS_WIREPARSE_ERR_LABEL_OVERFLOW; while(*s) { if(isspace(*s) || *s == '.') { s++; continue; } if(!isxdigit(*s)) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str); if(*len < dlen/2 + 1) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, s-str); if((dlen&1)==0) rd[dlen/2] = (uint8_t)gldns_hexdigit_to_int(*s++) * 16; else rd[dlen/2] += gldns_hexdigit_to_int(*s++); dlen++; } if((dlen&1)!=0) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str); *len = dlen/2; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_ipseckey_buf(const char* str, uint8_t* rd, size_t* len) { size_t gwlen = 0, keylen = 0; int s; uint8_t gwtype; char token[512]; gldns_buffer strbuf; gldns_buffer_init_frm_data(&strbuf, (uint8_t*)str, strlen(str)); if(*len < 3) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; /* precedence */ if(gldns_bget_token(&strbuf, token, "\t\n ", sizeof(token)) <= 0) return RET_ERR(GLDNS_WIREPARSE_ERR_INVALID_STR, gldns_buffer_position(&strbuf)); rd[0] = (uint8_t)atoi(token); /* gateway_type */ if(gldns_bget_token(&strbuf, token, "\t\n ", sizeof(token)) <= 0) return RET_ERR(GLDNS_WIREPARSE_ERR_INVALID_STR, gldns_buffer_position(&strbuf)); rd[1] = (uint8_t)atoi(token); gwtype = rd[1]; /* algorithm */ if(gldns_bget_token(&strbuf, token, "\t\n ", sizeof(token)) <= 0) return RET_ERR(GLDNS_WIREPARSE_ERR_INVALID_STR, gldns_buffer_position(&strbuf)); rd[2] = (uint8_t)atoi(token); /* gateway */ if(gldns_bget_token(&strbuf, token, "\t\n ", sizeof(token)) <= 0) return RET_ERR(GLDNS_WIREPARSE_ERR_INVALID_STR, gldns_buffer_position(&strbuf)); if(gwtype == 0) { /* NOGATEWAY */ if(strcmp(token, ".") != 0) return RET_ERR(GLDNS_WIREPARSE_ERR_INVALID_STR, gldns_buffer_position(&strbuf)); gwlen = 0; } else if(gwtype == 1) { /* IP4 */ gwlen = *len - 3; s = gldns_str2wire_a_buf(token, rd+3, &gwlen); if(s) return RET_ERR_SHIFT(s, gldns_buffer_position(&strbuf)); } else if(gwtype == 2) { /* IP6 */ gwlen = *len - 3; s = gldns_str2wire_aaaa_buf(token, rd+3, &gwlen); if(s) return RET_ERR_SHIFT(s, gldns_buffer_position(&strbuf)); } else if(gwtype == 3) { /* DNAME */ gwlen = *len - 3; s = gldns_str2wire_dname_buf(token, rd+3, &gwlen); if(s) return RET_ERR_SHIFT(s, gldns_buffer_position(&strbuf)); } else { /* unknown gateway type */ return RET_ERR(GLDNS_WIREPARSE_ERR_INVALID_STR, gldns_buffer_position(&strbuf)); } /* double check for size */ if(*len < 3 + gwlen) return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, gldns_buffer_position(&strbuf)); /* publickey in remainder of strbuf */ keylen = *len - 3 - gwlen; s = gldns_str2wire_b64_buf((const char*)gldns_buffer_current(&strbuf), rd+3+gwlen, &keylen); if(s) return RET_ERR_SHIFT(s, gldns_buffer_position(&strbuf)); *len = 3 + gwlen + keylen; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_nsec3_salt_buf(const char* str, uint8_t* rd, size_t* len) { int i, salt_length_str = (int)strlen(str); if (salt_length_str == 1 && str[0] == '-') { salt_length_str = 0; } else if (salt_length_str % 2 != 0) { return GLDNS_WIREPARSE_ERR_SYNTAX_HEX; } if (salt_length_str > 512) return GLDNS_WIREPARSE_ERR_SYNTAX_HEX; if(*len < 1+(size_t)salt_length_str / 2) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; rd[0] = (uint8_t) (salt_length_str / 2); for (i = 0; i < salt_length_str; i += 2) { if (isxdigit((int)str[i]) && isxdigit((int)str[i+1])) { rd[1+i/2] = (uint8_t)(gldns_hexdigit_to_int(str[i])*16 + gldns_hexdigit_to_int(str[i+1])); } else { return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_HEX, i); } } *len = 1 + (size_t)rd[0]; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_ilnp64_buf(const char* str, uint8_t* rd, size_t* len) { unsigned int a, b, c, d; uint16_t shorts[4]; int l; if(*len < sizeof(shorts)) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; if (sscanf(str, "%4x:%4x:%4x:%4x%n", &a, &b, &c, &d, &l) != 4 || l != (int)strlen(str) || /* more data to read */ strpbrk(str, "+-") /* signed hexes */ ) return GLDNS_WIREPARSE_ERR_SYNTAX_ILNP64; shorts[0] = htons(a); shorts[1] = htons(b); shorts[2] = htons(c); shorts[3] = htons(d); memmove(rd, &shorts, sizeof(shorts)); *len = sizeof(shorts); return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_eui48_buf(const char* str, uint8_t* rd, size_t* len) { unsigned int a, b, c, d, e, f; int l; if(*len < 6) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; if (sscanf(str, "%2x-%2x-%2x-%2x-%2x-%2x%n", &a, &b, &c, &d, &e, &f, &l) != 6 || l != (int)strlen(str)) return GLDNS_WIREPARSE_ERR_SYNTAX_EUI48; rd[0] = a; rd[1] = b; rd[2] = c; rd[3] = d; rd[4] = e; rd[5] = f; *len = 6; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_eui64_buf(const char* str, uint8_t* rd, size_t* len) { unsigned int a, b, c, d, e, f, g, h; int l; if(*len < 8) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; if (sscanf(str, "%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x%n", &a, &b, &c, &d, &e, &f, &g, &h, &l) != 8 || l != (int)strlen(str)) return GLDNS_WIREPARSE_ERR_SYNTAX_EUI64; rd[0] = a; rd[1] = b; rd[2] = c; rd[3] = d; rd[4] = e; rd[5] = f; rd[6] = g; rd[7] = h; *len = 8; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_tag_buf(const char* str, uint8_t* rd, size_t* len) { size_t slen = strlen(str); const char* ptr; if (slen > 255) return GLDNS_WIREPARSE_ERR_SYNTAX_TAG; if(*len < slen+1) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; for (ptr = str; *ptr; ptr++) { if(!isalnum(*ptr)) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_TAG, ptr-str); } rd[0] = slen; memmove(rd+1, str, slen); *len = slen+1; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_long_str_buf(const char* str, uint8_t* rd, size_t* len) { uint8_t ch = 0; const char* pstr = str; size_t length = 0; /* Fill data with parsed bytes */ while (gldns_parse_char(&ch, &pstr)) { if(*len < length+1) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; rd[length++] = ch; } if(!pstr) return GLDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE; *len = length; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_hip_buf(const char* str, uint8_t* rd, size_t* len) { char* s, *end; int e; size_t hitlen, pklen = 0; /* presentation format: * pk-algo HIThex pubkeybase64 * wireformat: * hitlen[1byte] pkalgo[1byte] pubkeylen[2byte] [hit] [pubkey] */ if(*len < 4) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; /* read PK algorithm */ rd[1] = (uint8_t)strtol((char*)str, &s, 10); if(*s != ' ') return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_INT, s-(char*)str); s++; while(*s == ' ') s++; /* read HIT hex tag */ /* zero terminate the tag (replace later) */ end = strchr(s, ' '); if(!end) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX, s-(char*)str); *end = 0; hitlen = *len - 4; if((e = gldns_str2wire_hex_buf(s, rd+4, &hitlen)) != 0) { *end = ' '; return RET_ERR_SHIFT(e, s-(char*)str); } if(hitlen > 255) { *end = ' '; return RET_ERR(GLDNS_WIREPARSE_ERR_LABEL_OVERFLOW, s-(char*)str+255*2); } rd[0] = (uint8_t)hitlen; *end = ' '; s = end+1; /* read pubkey base64 sequence */ pklen = *len - 4 - hitlen; if((e = gldns_str2wire_b64_buf(s, rd+4+hitlen, &pklen)) != 0) 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); *len = 4 + hitlen + pklen; return GLDNS_WIREPARSE_ERR_OK; } int gldns_str2wire_int16_data_buf(const char* str, uint8_t* rd, size_t* len) { size_t sz = gldns_b64_pton_calculate_size(strlen(str)); int n; if(*len < sz+2) return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; if(sz > 65535) return GLDNS_WIREPARSE_ERR_LABEL_OVERFLOW; n = gldns_b64_pton(str, rd+2, (*len)-2); if(n < 0) return GLDNS_WIREPARSE_ERR_SYNTAX_B64; gldns_write_uint16(rd, (uint16_t)n); *len = (size_t)n; return GLDNS_WIREPARSE_ERR_OK; } getdns-0.9.0/src/general.h0000664000175100017510000000577412641212403012316 00000000000000/** * * \file general.h * @brief getdns_general and related support functions * * This is the meat of the API * Originally taken from the getdns API description pseudo implementation. * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _GETDNS_GENERAL_H_ #define _GETDNS_GENERAL_H_ #include "getdns/getdns.h" #include "types-internal.h" /* private inner helper used by sync and async */ void _getdns_call_user_callback(getdns_dns_req *, getdns_dict *); void _getdns_check_dns_req_complete(getdns_dns_req *dns_req); getdns_return_t _getdns_submit_netreq(getdns_network_req *netreq); getdns_return_t _getdns_general_loop(getdns_context *context, getdns_eventloop *loop, const char *name, uint16_t request_type, getdns_dict *extensions, void *userarg, getdns_dns_req **dnsreq, getdns_callback_t callbackfn, internal_cb_t internal_cb); getdns_return_t _getdns_address_loop(getdns_context *context, getdns_eventloop *loop, const char *name, getdns_dict *extensions, void *userarg, getdns_transaction_t *transaction_id, getdns_callback_t callbackfn); getdns_return_t _getdns_hostname_loop(getdns_context *context, getdns_eventloop *loop, getdns_dict *address, getdns_dict *extensions, void *userarg, getdns_transaction_t *transaction_id, getdns_callback_t callbackfn); getdns_return_t _getdns_service_loop(getdns_context *context, getdns_eventloop *loop, const char *name, getdns_dict *extensions, void *userarg, getdns_transaction_t *transaction_id, getdns_callback_t callbackfn); #endif getdns-0.9.0/src/const-info.h0000664000175100017510000000410312641212403012741 00000000000000/** * * /brief _getdns_consts table with values, names and descriptions of the * constants in getdns * * The _getdns_get_validation_chain function is called after an answer * has been fetched when the dnssec_return_validation_chain extension is set. * It fetches DNSKEYs, DSes and their signatures for all RRSIGs found in the * answer. */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef CONST_INFO_H_ #define CONST_INFO_H_ struct const_info { int code; const char *name; const char *text; }; struct const_info *_getdns_get_const_info(int value); #endif /* const-info.h */ getdns-0.9.0/src/libgetdns.symbols0000664000175100017510000000772712641212403014115 00000000000000getdns_address getdns_address_sync getdns_cancel_callback getdns_context_create getdns_context_create_with_extended_memory_functions getdns_context_create_with_memory_functions getdns_context_destroy getdns_context_detach_eventloop getdns_context_get_api_information getdns_context_get_append_name getdns_context_get_dns_root_servers getdns_context_get_dnssec_allowed_skew getdns_context_get_dnssec_trust_anchors getdns_context_get_dns_transport getdns_context_get_dns_transport_list getdns_context_get_edns_client_subnet_private getdns_context_get_edns_do_bit getdns_context_get_edns_extended_rcode getdns_context_get_edns_maximum_udp_payload_size getdns_context_get_edns_version getdns_context_get_follow_redirects getdns_context_get_idle_timeout getdns_context_get_limit_outstanding_queries getdns_context_get_namespaces getdns_context_get_num_pending_requests getdns_context_get_resolution_type getdns_context_get_suffix getdns_context_get_timeout getdns_context_get_tls_authentication getdns_context_get_tls_query_padding_blocksize getdns_context_get_update_callback getdns_context_get_upstream_recursive_servers getdns_context_process_async getdns_context_run getdns_context_set_append_name getdns_context_set_context_update_callback getdns_context_set_dns_root_servers getdns_context_set_dnssec_allowed_skew getdns_context_set_dnssec_trust_anchors getdns_context_set_dns_transport getdns_context_set_dns_transport_list getdns_context_set_edns_client_subnet_private getdns_context_set_edns_do_bit getdns_context_set_edns_extended_rcode getdns_context_set_edns_maximum_udp_payload_size getdns_context_set_edns_version getdns_context_set_eventloop getdns_context_set_extended_memory_functions getdns_context_set_follow_redirects getdns_context_set_idle_timeout getdns_context_set_limit_outstanding_queries getdns_context_set_memory_functions getdns_context_set_namespaces getdns_context_set_resolution_type getdns_context_set_return_dnssec_status getdns_context_set_suffix getdns_context_set_timeout getdns_context_set_tls_authentication getdns_context_set_tls_query_padding_blocksize getdns_context_set_update_callback getdns_context_set_upstream_recursive_servers getdns_context_set_use_threads getdns_convert_alabel_to_ulabel getdns_convert_dns_name_to_fqdn getdns_convert_fqdn_to_dns_name getdns_convert_ulabel_to_alabel getdns_dict_create getdns_dict_create_with_context getdns_dict_create_with_extended_memory_functions getdns_dict_create_with_memory_functions getdns_dict_destroy getdns_dict_get_bindata getdns_dict_get_data_type getdns_dict_get_dict getdns_dict_get_int getdns_dict_get_list getdns_dict_get_names getdns_dict_remove_name getdns_dict_set_bindata getdns_dict_set_dict getdns_dict_set_int getdns_dict_set_list getdns_dict_util_get_string getdns_dict_util_set_string getdns_display_ip_address getdns_fp2rr_list getdns_general getdns_general_sync getdns_get_api_version getdns_get_api_version_number getdns_get_errorstr_by_id getdns_get_version getdns_get_version_number getdns_hostname getdns_hostname_sync getdns_list_create getdns_list_create_with_context getdns_list_create_with_extended_memory_functions getdns_list_create_with_memory_functions getdns_list_destroy getdns_list_get_bindata getdns_list_get_data_type getdns_list_get_dict getdns_list_get_int getdns_list_get_length getdns_list_get_list getdns_list_set_bindata getdns_list_set_dict getdns_list_set_int getdns_list_set_list getdns_pretty_print_dict getdns_pretty_print_list getdns_pretty_snprint_dict getdns_pretty_snprint_list getdns_print_json_dict getdns_print_json_list getdns_pubkey_pin_create_from_string getdns_pubkey_pinset_sanity_check getdns_root_trust_anchor getdns_rr_dict2str getdns_rr_dict2str_buf getdns_rr_dict2str_scan getdns_rr_dict2wire getdns_rr_dict2wire_buf getdns_rr_dict2wire_scan getdns_service getdns_service_sync getdns_snprint_json_dict getdns_snprint_json_list getdns_str2rr_dict getdns_strerror getdns_validate_dnssec getdns_wire2rr_dict getdns_wire2rr_dict_buf getdns_wire2rr_dict_scan plain_mem_funcs_user_arg priv_getdns_context_mf getdns-0.9.0/src/rr-dict.c0000664000175100017510000013712312641212403012232 00000000000000/** * * /brief getdns support functions for DNS Resource Records * * This file contains the tables with the information needed by getdns about * individual RRs, such as their name and rdata fields and types. * This information is provided via the response dict. * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rr-dict.h" #include "gldns/gbuffer.h" #include "util-internal.h" #include "types-internal.h" #include "context.h" #include "dict.h" #define ALEN(a) (sizeof(a)/sizeof(a[0])) #define UNKNOWN_RDATA NULL static const uint8_t * apl_n_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { return rdf < pkt_end ? rdf + 1 : NULL; } static getdns_return_t apl_n_wire2dict(getdns_dict *dict, const uint8_t *rdf) { return getdns_dict_set_int(dict, "n", (*rdf >> 7)); } static getdns_return_t apl_n_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_int(list, (*rdf >> 7)); } static getdns_return_t apl_n_2wire(uint32_t value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { (void)rdata; /* unused parameter */ if (*rdf_len < 1) { *rdf_len = 1; return GETDNS_RETURN_NEED_MORE_SPACE; } *rdf_len = 1; *rdf = value ? 0x80 : 0x00; return GETDNS_RETURN_GOOD; } static getdns_return_t apl_n_dict2wire(const getdns_dict *dict, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; uint32_t value; if ((r = getdns_dict_get_int(dict, "n", &value))) return r; else return apl_n_2wire(value, rdata, rdf, rdf_len); } static getdns_return_t apl_n_list2wire(const getdns_list *list, size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; uint32_t value; if ((r = getdns_list_get_int(list, i, &value))) return r; else return apl_n_2wire(value, rdata, rdf, rdf_len); } static _getdns_rdf_special apl_n = { apl_n_rdf_end, apl_n_wire2dict, apl_n_wire2list, apl_n_dict2wire, apl_n_list2wire }; static const uint8_t * 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); return end <= pkt_end ? end : NULL; } static getdns_return_t apl_afdpart_wire2dict(getdns_dict *dict, const uint8_t *rdf) { return _getdns_dict_set_const_bindata( dict, "afdpart", (rdf[-1] & 0x7F), rdf); } static getdns_return_t apl_afdpart_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_const_bindata(list, (rdf[-1] & 0x7F), rdf); } static getdns_return_t apl_afdpart_2wire( const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { if (value->size > 0x7F) return GETDNS_RETURN_INVALID_PARAMETER; if (rdf - 1 < rdata) return GETDNS_RETURN_GENERIC_ERROR; if (*rdf_len < value->size) { *rdf_len = value->size; return GETDNS_RETURN_NEED_MORE_SPACE; } *rdf_len = value->size; /* Keeping first bit is safe because value->size <= 0x7F */ rdf[-1] |= value->size; (void) memcpy(rdf, value->data, value->size); return GETDNS_RETURN_GOOD; } static getdns_return_t apl_afdpart_dict2wire( const getdns_dict *dict, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; getdns_bindata *value; if ((r = getdns_dict_get_bindata(dict, "afdpart", &value))) return r; else return apl_afdpart_2wire(value, rdata, rdf, rdf_len); } static getdns_return_t apl_afdpart_list2wire(const getdns_list *list, size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; getdns_bindata *value; if ((r = getdns_list_get_bindata(list, i, &value))) return r; else return apl_afdpart_2wire(value, rdata, rdf, rdf_len); } static _getdns_rdf_special apl_afdpart = { apl_afdpart_rdf_end, apl_afdpart_wire2dict, apl_afdpart_wire2list, apl_afdpart_dict2wire, apl_afdpart_list2wire }; static const uint8_t * ipseckey_gateway_rdf_end( const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { const uint8_t *end; if (rdf - 5 < pkt) return NULL; switch (rdf[-2]) { case 0: end = rdf; break; case 1: end = rdf + 4; break; case 2: end = rdf + 16; break; case 3: for (end = rdf; end < pkt_end; end += *end + 1) if ((*end & 0xC0) == 0xC0) end += 2; else if (*end & 0xC0) return NULL; else if (!*end) { end += 1; break; } break; default: return NULL; } return end <= pkt_end ? end : NULL; } static getdns_return_t ipseckey_gateway_equip_const_bindata( const uint8_t *rdf, size_t *size, const uint8_t **data) { *data = rdf; switch (rdf[-2]) { case 0: *size = 0; break; case 1: *size = 4; break; case 2: *size = 16; break; case 3: while (*rdf) if ((*rdf & 0xC0) == 0xC0) rdf += 2; else if (*rdf & 0xC0) return GETDNS_RETURN_GENERIC_ERROR; else rdf += *rdf + 1; *size = rdf + 1 - *data; break; default: return GETDNS_RETURN_GENERIC_ERROR; } return GETDNS_RETURN_GOOD; } static getdns_return_t ipseckey_gateway_wire2dict(getdns_dict *dict, const uint8_t *rdf) { size_t size; const uint8_t *data; if (ipseckey_gateway_equip_const_bindata(rdf, &size, &data)) return GETDNS_RETURN_GENERIC_ERROR; else if (! size) return GETDNS_RETURN_GOOD; else return _getdns_dict_set_const_bindata(dict, "gateway", size, data); } static getdns_return_t ipseckey_gateway_wire2list(getdns_list *list, const uint8_t *rdf) { size_t size; const uint8_t *data; if (ipseckey_gateway_equip_const_bindata(rdf, &size, &data)) return GETDNS_RETURN_GENERIC_ERROR; else if (!size) return GETDNS_RETURN_GOOD; else return _getdns_list_append_const_bindata(list, size, data); } static getdns_return_t ipseckey_gateway_2wire( const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { if (rdf - 2 < rdata) return GETDNS_RETURN_GENERIC_ERROR; switch (rdf[-2]) { case 0: if (value && value->size > 0) return GETDNS_RETURN_INVALID_PARAMETER; break; case 1: if (!value || value->size != 4) return GETDNS_RETURN_INVALID_PARAMETER; if (*rdf_len < 4) { *rdf_len = 4; return GETDNS_RETURN_NEED_MORE_SPACE; } *rdf_len = 4; (void)memcpy(rdf, value->data, 4); return GETDNS_RETURN_GOOD; case 2: if (!value || value->size != 16) return GETDNS_RETURN_INVALID_PARAMETER; if (*rdf_len < 16) { *rdf_len = 16; return GETDNS_RETURN_NEED_MORE_SPACE; } *rdf_len = 16; (void)memcpy(rdf, value->data, 16); return GETDNS_RETURN_GOOD; case 3: if (!value || value->size == 0) return GETDNS_RETURN_INVALID_PARAMETER; /* Assume bindata is a valid dname; garbage in, garbage out */ if (*rdf_len < value->size) { *rdf_len = value->size; return GETDNS_RETURN_NEED_MORE_SPACE; } *rdf_len = value->size; (void)memcpy(rdf, value->data, value->size); return GETDNS_RETURN_GOOD; default: return GETDNS_RETURN_GENERIC_ERROR; } return GETDNS_RETURN_GOOD; } static getdns_return_t ipseckey_gateway_dict2wire( const getdns_dict *dict, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; getdns_bindata *value; if ((r = getdns_dict_get_bindata(dict, "gateway", &value))) return r; else return ipseckey_gateway_2wire(value, rdata, rdf, rdf_len); } static getdns_return_t ipseckey_gateway_list2wire(const getdns_list *list, size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; getdns_bindata *value; if ((r = getdns_list_get_bindata(list, i, &value))) return r; else return ipseckey_gateway_2wire(value, rdata, rdf, rdf_len); } static _getdns_rdf_special ipseckey_gateway = { ipseckey_gateway_rdf_end, ipseckey_gateway_wire2dict, ipseckey_gateway_wire2list, ipseckey_gateway_dict2wire, ipseckey_gateway_list2wire }; static const uint8_t * hip_pk_algorithm_rdf_end( const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { return rdf + 4 > pkt_end ? NULL : rdf + 4 + *rdf + gldns_read_uint16(rdf + 2) > pkt_end ? NULL : rdf + 1; } static getdns_return_t hip_pk_algorithm_wire2dict(getdns_dict *dict, const uint8_t *rdf) { return getdns_dict_set_int(dict, "pk_algorithm", rdf[1]); } static getdns_return_t hip_pk_algorithm_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_int(list, rdf[1]); } static getdns_return_t hip_pk_algorithm_2wire(uint32_t value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { if (rdata != rdf) return GETDNS_RETURN_GENERIC_ERROR; if (value > 0xFF) return GETDNS_RETURN_INVALID_PARAMETER; if (*rdf_len < 4) { *rdf_len = 4; return GETDNS_RETURN_NEED_MORE_SPACE; } *rdf_len = 4; rdata[1] = value; return GETDNS_RETURN_GOOD; } static getdns_return_t hip_pk_algorithm_dict2wire( const getdns_dict *dict,uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; uint32_t value; if ((r = getdns_dict_get_int(dict, "pk_algorithm", &value))) return r; else return hip_pk_algorithm_2wire(value, rdata, rdf, rdf_len); } static getdns_return_t hip_pk_algorithm_list2wire(const getdns_list *list, size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; uint32_t value; if ((r = getdns_list_get_int(list, i, &value))) return r; else return hip_pk_algorithm_2wire(value, rdata, rdf, rdf_len); } static _getdns_rdf_special hip_pk_algorithm = { hip_pk_algorithm_rdf_end, hip_pk_algorithm_wire2dict, hip_pk_algorithm_wire2list, hip_pk_algorithm_dict2wire, hip_pk_algorithm_list2wire }; static const uint8_t * hip_hit_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { return rdf + 3 > pkt_end ? NULL : rdf + 3 + rdf[-1] + gldns_read_uint16(rdf + 1) > pkt_end ? NULL : rdf + 1; } static getdns_return_t hip_hit_wire2dict(getdns_dict *dict, const uint8_t *rdf) { return _getdns_dict_set_const_bindata(dict, "hit", rdf[-1], rdf + 3); } static getdns_return_t hip_hit_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_const_bindata(list, rdf[-1], rdf + 3); } static getdns_return_t hip_hit_2wire( const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { if (rdata != rdf - 4) return GETDNS_RETURN_GENERIC_ERROR; if (value && value->size > 0xFF) return GETDNS_RETURN_INVALID_PARAMETER; if (!value || value->size == 0) { rdata[0] = 0; *rdf_len = 0; return GETDNS_RETURN_GOOD; } if (value->size > *rdf_len) { *rdf_len = value->size; return GETDNS_RETURN_NEED_MORE_SPACE; } *rdf_len = value->size; rdata[0] = value->size; (void)memcpy(rdf, value->data, value->size); return GETDNS_RETURN_GOOD; } static getdns_return_t hip_hit_dict2wire( const getdns_dict *dict, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; getdns_bindata *value; if ((r = getdns_dict_get_bindata(dict, "hit", &value))) return r; else return hip_hit_2wire(value, rdata, rdf, rdf_len); } static getdns_return_t hip_hit_list2wire(const getdns_list *list, size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; getdns_bindata *value; if ((r = getdns_list_get_bindata(list, i, &value))) return r; else return hip_hit_2wire(value, rdata, rdf, rdf_len); } static _getdns_rdf_special hip_hit = { hip_hit_rdf_end, hip_hit_wire2dict, hip_hit_wire2list, hip_hit_dict2wire, hip_hit_list2wire }; static const uint8_t * hip_public_key_rdf_end( const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { 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); } static getdns_return_t hip_public_key_wire2dict(getdns_dict *dict, const uint8_t *rdf) { return _getdns_dict_set_const_bindata( dict, "public_key", gldns_read_uint16(rdf), rdf + 2 + rdf[-2]); } static getdns_return_t hip_public_key_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_const_bindata( list, gldns_read_uint16(rdf), rdf + 2 + rdf[-2]); } static getdns_return_t hip_public_key_2wire( const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { if (rdata > rdf - 4 || rdata + 4 + rdata[0] != rdf) return GETDNS_RETURN_GENERIC_ERROR; if (value && value->size > 0xFFFF) return GETDNS_RETURN_INVALID_PARAMETER; if (!value || value->size == 0) { rdata[2] = rdata[3] = 0; *rdf_len = 0; return GETDNS_RETURN_GOOD; } if (value->size > *rdf_len) { *rdf_len = value->size; return GETDNS_RETURN_NEED_MORE_SPACE; } *rdf_len = value->size; gldns_write_uint16(rdata + 2, value->size); (void)memcpy(rdf, value->data, value->size); return GETDNS_RETURN_GOOD; } static getdns_return_t hip_public_key_dict2wire( const getdns_dict *dict, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; getdns_bindata *value; if ((r = getdns_dict_get_bindata(dict, "public_key", &value))) return r; else return hip_public_key_2wire(value, rdata, rdf, rdf_len); } static getdns_return_t hip_public_key_list2wire( const getdns_list *list, size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { getdns_return_t r; getdns_bindata *value; if ((r = getdns_list_get_bindata(list, i, &value))) return r; else return hip_public_key_2wire(value, rdata, rdf, rdf_len); } static _getdns_rdf_special hip_public_key = { hip_public_key_rdf_end, hip_public_key_wire2dict, hip_public_key_wire2list, hip_public_key_dict2wire, hip_public_key_list2wire }; static _getdns_rdata_def a_rdata[] = { { "ipv4_address" , GETDNS_RDF_A }}; static _getdns_rdata_def ns_rdata[] = { { "nsdname" , GETDNS_RDF_N_C }}; static _getdns_rdata_def md_rdata[] = { { "madname" , GETDNS_RDF_N_C }}; static _getdns_rdata_def cname_rdata[] = { { "cname" , GETDNS_RDF_N_C }}; 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 }}; static _getdns_rdata_def mg_rdata[] = { { "mgmname" , GETDNS_RDF_N_C }}; static _getdns_rdata_def mr_rdata[] = { { "newname" , GETDNS_RDF_N_C }}; static _getdns_rdata_def null_rdata[] = { { "anything" , GETDNS_RDF_X }}; static _getdns_rdata_def wks_rdata[] = { { "address" , GETDNS_RDF_A }, { "protocol" , GETDNS_RDF_I1 }, { "bitmap" , GETDNS_RDF_X }}; static _getdns_rdata_def ptr_rdata[] = { { "ptrdname" , GETDNS_RDF_N_C }}; static _getdns_rdata_def hinfo_rdata[] = { { "cpu" , GETDNS_RDF_S }, { "os" , GETDNS_RDF_S }}; static _getdns_rdata_def minfo_rdata[] = { { "rmailbx" , GETDNS_RDF_N_C }, { "emailbx" , GETDNS_RDF_N_C }}; static _getdns_rdata_def mx_rdata[] = { { "preference" , GETDNS_RDF_I2 }, { "exchange" , GETDNS_RDF_N_C }}; static _getdns_rdata_def txt_rdata[] = { { "txt_strings" , GETDNS_RDF_S_M }}; static _getdns_rdata_def rp_rdata[] = { { "mbox_dname" , GETDNS_RDF_N }, { "txt_dname" , GETDNS_RDF_N }}; static _getdns_rdata_def afsdb_rdata[] = { { "subtype" , GETDNS_RDF_I2 }, { "hostname" , GETDNS_RDF_N }}; static _getdns_rdata_def x25_rdata[] = { { "psdn_address" , GETDNS_RDF_S }}; static _getdns_rdata_def isdn_rdata[] = { { "isdn_address" , GETDNS_RDF_S }, { "sa" , GETDNS_RDF_S }}; static _getdns_rdata_def rt_rdata[] = { { "preference" , GETDNS_RDF_I2 }, { "intermediate_host" , GETDNS_RDF_N }}; static _getdns_rdata_def nsap_rdata[] = { { "nsap" , GETDNS_RDF_X }}; static _getdns_rdata_def sig_rdata[] = { { "sig_obsolete" , GETDNS_RDF_X }}; static _getdns_rdata_def key_rdata[] = { { "key_obsolete" , GETDNS_RDF_X }}; static _getdns_rdata_def px_rdata[] = { { "preference" , GETDNS_RDF_I2 }, { "map822" , GETDNS_RDF_N }, { "mapx400" , GETDNS_RDF_N }}; static _getdns_rdata_def gpos_rdata[] = { { "longitude" , GETDNS_RDF_S }, { "latitude" , GETDNS_RDF_S }, { "altitude" , GETDNS_RDF_S }}; static _getdns_rdata_def aaaa_rdata[] = { { "ipv6_address" , GETDNS_RDF_AAAA }}; static _getdns_rdata_def loc_rdata[] = { { "loc_obsolete" , GETDNS_RDF_X }}; static _getdns_rdata_def nxt_rdata[] = { { "nxt_obsolete" , GETDNS_RDF_X }}; static _getdns_rdata_def srv_rdata[] = { { "priority" , GETDNS_RDF_I2 }, { "weight" , GETDNS_RDF_I2 }, { "port" , GETDNS_RDF_I2 }, { "target" , GETDNS_RDF_N }}; static _getdns_rdata_def atma_rdata[] = { { "format" , GETDNS_RDF_X }}; 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 }}; static _getdns_rdata_def kx_rdata[] = { { "preference" , GETDNS_RDF_I2 }, { "exchanger" , GETDNS_RDF_N }}; 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 }}; static _getdns_rdata_def a6_rdata[] = { { "a6_obsolete" , GETDNS_RDF_X }}; static _getdns_rdata_def dname_rdata[] = { { "target" , GETDNS_RDF_N }}; static _getdns_rdata_def opt_rdata[] = { { "options" , GETDNS_RDF_R }, { "option_code" , GETDNS_RDF_I2 }, { "option_data" , GETDNS_RDF_X_S }}; static _getdns_rdata_def apl_rdata[] = { { "apitems" , GETDNS_RDF_R }, { "address_family" , GETDNS_RDF_I2 }, { "prefix" , GETDNS_RDF_I1 }, { "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 }}; static _getdns_rdata_def sshfp_rdata[] = { { "algorithm" , GETDNS_RDF_I1 }, { "fp_type" , GETDNS_RDF_I1 }, { "fingerprint" , GETDNS_RDF_X }}; static _getdns_rdata_def ipseckey_rdata[] = { { "algorithm" , GETDNS_RDF_I1 }, { "gateway_type" , GETDNS_RDF_I1 }, { "precedence" , GETDNS_RDF_I1 }, { "gateway" , GETDNS_RDF_SPECIAL, &ipseckey_gateway }, { "public_key" , GETDNS_RDF_B }}; 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 }}; static _getdns_rdata_def nsec_rdata[] = { { "next_domain_name" , GETDNS_RDF_N }, { "type_bit_maps" , GETDNS_RDF_X }}; static _getdns_rdata_def dnskey_rdata[] = { { "flags" , GETDNS_RDF_I2 }, { "protocol" , GETDNS_RDF_I1 }, { "algorithm" , GETDNS_RDF_I1 }, { "public_key" , GETDNS_RDF_B }}; static _getdns_rdata_def dhcid_rdata[] = { { "dhcid_opaque" , GETDNS_RDF_B }}; 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 }}; static _getdns_rdata_def nsec3param_rdata[] = { { "hash_algorithm" , GETDNS_RDF_I1 }, { "flags" , GETDNS_RDF_I1 }, { "iterations" , GETDNS_RDF_I2 }, { "salt" , GETDNS_RDF_X_C }}; 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 }}; 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 }}; static _getdns_rdata_def csync_rdata[] = { { "serial" , GETDNS_RDF_I4 }, { "flags" , GETDNS_RDF_I2 }, { "type_bit_maps" , GETDNS_RDF_X }}; static _getdns_rdata_def spf_rdata[] = { { "text" , GETDNS_RDF_S_M }}; static _getdns_rdata_def nid_rdata[] = { { "preference" , GETDNS_RDF_I2 }, { "node_id" , GETDNS_RDF_AA }}; static _getdns_rdata_def l32_rdata[] = { { "preference" , GETDNS_RDF_I2 }, { "locator32" , GETDNS_RDF_A }}; static _getdns_rdata_def l64_rdata[] = { { "preference" , GETDNS_RDF_I2 }, { "locator64" , GETDNS_RDF_AA }}; static _getdns_rdata_def lp_rdata[] = { { "preference" , GETDNS_RDF_I2 }, { "fqdn" , GETDNS_RDF_N }}; static _getdns_rdata_def eui48_rdata[] = { { "eui48_address" , GETDNS_RDF_X6 }}; static _getdns_rdata_def eui64_rdata[] = { { "eui64_address" , GETDNS_RDF_X8 }}; 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 }}; 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 }}; static _getdns_rdata_def uri_rdata[] = { { "priority" , GETDNS_RDF_I2 }, { "weight" , GETDNS_RDF_I2 }, { "target" , GETDNS_RDF_S_L }}; static _getdns_rdata_def caa_rdata[] = { { "flags" , GETDNS_RDF_I1 }, { "tag" , GETDNS_RDF_S }, { "value" , GETDNS_RDF_S_L }}; static _getdns_rdata_def dlv_rdata[] = { { "key_tag" , GETDNS_RDF_I2 }, { "algorithm" , GETDNS_RDF_I1 }, { "digest_type" , GETDNS_RDF_I1 }, { "digest" , GETDNS_RDF_X }}; static _getdns_rr_def _getdns_rr_defs[] = { { NULL, NULL, 0 }, { "A", a_rdata, ALEN( a_rdata) }, /* 1 - */ { "NS", ns_rdata, ALEN( ns_rdata) }, { "MD", md_rdata, ALEN( md_rdata) }, { "MF", md_rdata, ALEN( md_rdata) }, { "CNAME", cname_rdata, ALEN( cname_rdata) }, { "SOA", soa_rdata, ALEN( soa_rdata) }, { "MB", md_rdata, ALEN( md_rdata) }, { "MG", mg_rdata, ALEN( mg_rdata) }, { "MR", mr_rdata, ALEN( mr_rdata) }, { "NULL", null_rdata, ALEN( null_rdata) }, { "WKS", wks_rdata, ALEN( wks_rdata) }, { "PTR", ptr_rdata, ALEN( ptr_rdata) }, { "HINFO", hinfo_rdata, ALEN( hinfo_rdata) }, { "MINFO", minfo_rdata, ALEN( minfo_rdata) }, { "MX", mx_rdata, ALEN( mx_rdata) }, { "TXT", txt_rdata, ALEN( txt_rdata) }, { "RP", rp_rdata, ALEN( rp_rdata) }, { "AFSDB", afsdb_rdata, ALEN( afsdb_rdata) }, { "X25", x25_rdata, ALEN( x25_rdata) }, { "ISDN", isdn_rdata, ALEN( isdn_rdata) }, { "RT", rt_rdata, ALEN( rt_rdata) }, { "NSAP", nsap_rdata, ALEN( nsap_rdata) }, /* - 22 */ { NULL, NULL, 0 }, { "SIG", sig_rdata, ALEN( sig_rdata) }, /* 24 - */ { "KEY", key_rdata, ALEN( key_rdata) }, { "PX", px_rdata, ALEN( px_rdata) }, { "GPOS", gpos_rdata, ALEN( gpos_rdata) }, { "AAAA", aaaa_rdata, ALEN( aaaa_rdata) }, { "LOC", loc_rdata, ALEN( loc_rdata) }, { "NXT", nxt_rdata, ALEN( nxt_rdata) }, { "EID", UNKNOWN_RDATA, 0 }, { "NIMLOC", UNKNOWN_RDATA, 0 }, { "SRV", srv_rdata, ALEN( srv_rdata) }, { "ATMA", atma_rdata, ALEN( atma_rdata) }, { "NAPTR", naptr_rdata, ALEN( naptr_rdata) }, { "KX", kx_rdata, ALEN( kx_rdata) }, { "CERT", cert_rdata, ALEN( cert_rdata) }, { "A6", a6_rdata, ALEN( a6_rdata) }, { "DNAME", dname_rdata, ALEN( dname_rdata) }, { "SINK", UNKNOWN_RDATA, 0 }, { "OPT", opt_rdata, ALEN( opt_rdata) }, { "APL", apl_rdata, ALEN( apl_rdata) }, { "DS", ds_rdata, ALEN( ds_rdata) }, { "SSHFP", sshfp_rdata, ALEN( sshfp_rdata) }, { "IPSECKEY", ipseckey_rdata, ALEN( ipseckey_rdata) }, { "RRSIG", rrsig_rdata, ALEN( rrsig_rdata) }, { "NSEC", nsec_rdata, ALEN( nsec_rdata) }, { "DNSKEY", dnskey_rdata, ALEN( dnskey_rdata) }, { "DHCID", dhcid_rdata, ALEN( dhcid_rdata) }, { "NSEC3", nsec3_rdata, ALEN( nsec3_rdata) }, { "NSEC3PARAM", nsec3param_rdata, ALEN(nsec3param_rdata) }, { "TLSA", tlsa_rdata, ALEN( tlsa_rdata) }, /* - 52 */ { NULL, NULL, 0 }, { NULL, NULL, 0 }, { "HIP", hip_rdata, ALEN( hip_rdata) }, /* 55 - */ { "NINFO", UNKNOWN_RDATA, 0 }, { "RKEY", UNKNOWN_RDATA, 0 }, { "TALINK", UNKNOWN_RDATA, 0 }, { "CDS", ds_rdata, ALEN( ds_rdata) }, { "CDNSKEY", dnskey_rdata, ALEN( dnskey_rdata) }, { "OPENPGPKEY", UNKNOWN_RDATA, 0 }, /* 61 - */ { "CSYNC", csync_rdata, ALEN( csync_rdata) }, /* - 62 */ { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { "SPF", spf_rdata, ALEN( spf_rdata) }, /* 99 - */ { "UINFO", UNKNOWN_RDATA, 0 }, { "UID", UNKNOWN_RDATA, 0 }, { "GID", UNKNOWN_RDATA, 0 }, { "UNSPEC", UNKNOWN_RDATA, 0 }, { "NID", nid_rdata, ALEN( nid_rdata) }, { "L32", l32_rdata, ALEN( l32_rdata) }, { "L64", l64_rdata, ALEN( l64_rdata) }, { "LP", lp_rdata, ALEN( lp_rdata) }, { "EUI48", eui48_rdata, ALEN( eui48_rdata) }, { "EUI64", eui64_rdata, ALEN( eui64_rdata) }, /* - 109 */ { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { NULL, NULL, 0 }, { "TKEY", tkey_rdata, ALEN( tkey_rdata) }, /* 249 - */ { "TSIG", tsig_rdata, ALEN( tsig_rdata) }, /* - 250 */ { NULL, NULL, 0 }, { NULL, NULL, 0 }, { "MAILB", UNKNOWN_RDATA, 0 }, /* 253 - */ { "MAILA", UNKNOWN_RDATA, 0 }, /* - 254 */ { NULL, NULL, 0 }, { "URI", uri_rdata, ALEN( uri_rdata) }, /* 256 - */ { "CAA", caa_rdata, ALEN( caa_rdata) }, /* - 257 */ { "TA", UNKNOWN_RDATA, 0 }, /* 32768 */ { "DLV", dlv_rdata, ALEN( dlv_rdata) } /* 32769 */ }; const _getdns_rr_def * _getdns_rr_def_lookup(uint16_t rr_type) { if (rr_type <= 257) return &_getdns_rr_defs[rr_type]; else if (rr_type == 32768) return &_getdns_rr_defs[258]; else if (rr_type == 32769) return &_getdns_rr_defs[259]; return _getdns_rr_defs; } const char * _getdns_rr_type_name(int rr_type) { return _getdns_rr_def_lookup(rr_type)->name; } static void write_int_rdata(gldns_buffer *buf, _getdns_rdf_type type, uint32_t value) { size_t j; for (j = type & GETDNS_RDF_FIXEDSZ; j; j--) gldns_buffer_write_u8(buf, (uint8_t)(value >> (8 * (j - 1))) & 0xff); } static void write_bindata_rdata(gldns_buffer *buf, _getdns_rdf_type type, getdns_bindata *bindata) { if (type & GETDNS_RDF_LEN_VAL) write_int_rdata(buf, type >> 8, bindata->size); gldns_buffer_write(buf, bindata->data, bindata->size); } static getdns_return_t write_rdata_field(gldns_buffer *buf, uint8_t *rdata_start, const _getdns_rdata_def *rd_def, getdns_dict *rdata) { getdns_return_t r; getdns_list *list; uint32_t value; getdns_bindata *bindata; size_t i, rdf_len; if (rd_def->type & GETDNS_RDF_INTEGER) { if (!(rd_def->type & GETDNS_RDF_REPEAT)) { if ((r = getdns_dict_get_int( rdata, rd_def->name, &value))) return r; else write_int_rdata(buf, rd_def->type, value); } else if ((r = getdns_dict_get_list( rdata, rd_def->name, &list))) return r == GETDNS_RETURN_NO_SUCH_DICT_NAME ? GETDNS_RETURN_GOOD : r; else for ( i = 0 ; GETDNS_RETURN_GOOD == (r = getdns_list_get_int(list, i, &value)) ; i++) write_int_rdata(buf, rd_def->type, value); } else if (rd_def->type & GETDNS_RDF_BINDATA) { if (!(rd_def->type & GETDNS_RDF_REPEAT)) { if ((r = getdns_dict_get_bindata( rdata, rd_def->name, &bindata))) return r; else write_bindata_rdata(buf, rd_def->type, bindata); } else if ((r = getdns_dict_get_list( rdata, rd_def->name, &list))) return r == GETDNS_RETURN_NO_SUCH_DICT_NAME ? GETDNS_RETURN_GOOD : r; else for ( i = 0 ; GETDNS_RETURN_GOOD == (r = getdns_list_get_bindata(list, i, &bindata)) ; i++) write_bindata_rdata(buf, rd_def->type, bindata); } else if (!(rd_def->type & GETDNS_RDF_SPECIAL)) { /* Unknown rdata type */ return GETDNS_RETURN_GENERIC_ERROR; } else if (!(rd_def->type & GETDNS_RDF_REPEAT)) { rdf_len = gldns_buffer_remaining(buf); r = rd_def->special->dict2wire(rdata, rdata_start, gldns_buffer_current(buf), &rdf_len); if (r == GETDNS_RETURN_GOOD || r == GETDNS_RETURN_NEED_MORE_SPACE) gldns_buffer_skip(buf, rdf_len); if (r) return r; } else if ((r = getdns_dict_get_list(rdata, rd_def->name, &list))) { return r == GETDNS_RETURN_NO_SUCH_DICT_NAME ? GETDNS_RETURN_GOOD : r; } else for ( i = 0; r == GETDNS_RETURN_GOOD; i++ ) { rdf_len = gldns_buffer_remaining(buf); r = rd_def->special->list2wire(list, i, rdata_start, gldns_buffer_current(buf), &rdf_len); if (r == GETDNS_RETURN_GOOD || r == GETDNS_RETURN_NEED_MORE_SPACE) gldns_buffer_skip(buf, rdf_len); } return r != GETDNS_RETURN_NO_SUCH_LIST_ITEM ? r : GETDNS_RETURN_GOOD; } getdns_return_t _getdns_rr_dict2wire(const getdns_dict *rr_dict, gldns_buffer *buf) { getdns_return_t r = GETDNS_RETURN_GOOD; getdns_bindata *name; getdns_bindata *rdata_raw; getdns_dict *rdata; uint32_t rr_type; uint32_t rr_class = GETDNS_RRCLASS_IN; uint32_t rr_ttl = 0; const _getdns_rr_def *rr_def; const _getdns_rdata_def *rd_def, *rep_rd_def; int n_rdata_fields, rep_n_rdata_fields; size_t rdata_size_mark; uint8_t *rdata_start; getdns_list *list; size_t i; assert(rr_dict); assert(buf); if ((r = getdns_dict_get_bindata(rr_dict, "name", &name))) return r; gldns_buffer_write(buf, name->data, name->size); if ((r = getdns_dict_get_int(rr_dict, "type", &rr_type))) return r; gldns_buffer_write_u16(buf, (uint16_t)rr_type); (void) getdns_dict_get_int(rr_dict, "class", &rr_class); gldns_buffer_write_u16(buf, (uint16_t)rr_class); (void) getdns_dict_get_int(rr_dict, "ttl", &rr_ttl); gldns_buffer_write_u32(buf, rr_ttl); /* Does rdata contain compressed names? * Because rdata_raw is unusable then. */ rr_def = _getdns_rr_def_lookup(rr_type); for ( rd_def = rr_def->rdata , n_rdata_fields = rr_def->n_rdata_fields ; n_rdata_fields ; n_rdata_fields-- , rd_def++ ) { if (rd_def->type & GETDNS_RDF_COMPRESSED) break; } if ((r = getdns_dict_get_dict(rr_dict, "rdata", &rdata))) { if (r == GETDNS_RETURN_NO_SUCH_DICT_NAME) { gldns_buffer_write_u16(buf, 0); r = GETDNS_RETURN_GOOD; } } else if (n_rdata_fields == 0 && GETDNS_RETURN_GOOD == (r = getdns_dict_get_bindata(rdata, "rdata_raw", &rdata_raw))) { gldns_buffer_write_u16(buf, (uint16_t)rdata_raw->size); gldns_buffer_write(buf, rdata_raw->data, rdata_raw->size); } else if (n_rdata_fields || r == GETDNS_RETURN_NO_SUCH_DICT_NAME) { r = GETDNS_RETURN_GOOD; rdata_size_mark = gldns_buffer_position(buf); gldns_buffer_skip(buf, 2); rdata_start = gldns_buffer_current(buf); for ( rd_def = rr_def->rdata , n_rdata_fields = rr_def->n_rdata_fields ; n_rdata_fields ; n_rdata_fields-- , rd_def++ ) { if (rd_def->type == GETDNS_RDF_REPEAT) break; if ((r = write_rdata_field(buf, rdata_start, rd_def, rdata))) break; } if (n_rdata_fields == 0 || r) { /* pass */; } else if ((r = getdns_dict_get_list( rdata, rd_def->name, &list))) { /* pass */; } else for ( i = 0 ; r == GETDNS_RETURN_GOOD ; i++) { if ((r = getdns_list_get_dict(list, i, &rdata))) { if (r == GETDNS_RETURN_NO_SUCH_LIST_ITEM) r = GETDNS_RETURN_GOOD; break; } for ( rep_rd_def = rd_def + 1 , rep_n_rdata_fields = n_rdata_fields - 1 ; rep_n_rdata_fields ; rep_n_rdata_fields--, rep_rd_def++ ) { if ((r = write_rdata_field(buf, rdata_start, rep_rd_def, rdata))) break; } } gldns_buffer_write_u16_at(buf, rdata_size_mark, (uint16_t)(gldns_buffer_position(buf)-rdata_size_mark-2)); } return r; } getdns-0.9.0/src/list.c0000664000175100017510000004305212641212403011636 00000000000000/** * * /brief getdns list management functions * * This is the meat of the API * Originally taken from the getdns API description pseudo implementation. * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include "types-internal.h" #include "util-internal.h" #include "list.h" #include "dict.h" getdns_return_t _getdns_list_find(const getdns_list *list, const char *key, getdns_item **item) { const char *next; char *endptr; size_t index; getdns_item *i; if (*key == '/') { if (!(next = strchr(++key, '/'))) next = strchr(key, '\0'); } else next = strchr(key, '\0'); if (key[0] == '-' && next == key + 1) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; index = strtoul(key, &endptr, 10); if (!isdigit((int)*key) || endptr != next) /* Not a list index, so it was assumed */ return GETDNS_RETURN_WRONG_TYPE_REQUESTED; if (index >= list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; i = &list->items[index]; if (!*next) { *item = i; return GETDNS_RETURN_GOOD; } else switch (i->dtype) { case t_dict: return _getdns_dict_find(i->data.dict, next, item); case t_list: return _getdns_list_find(i->data.list, next, item); default : /* Trying to dereference a non list or dict */ return GETDNS_RETURN_NO_SUCH_LIST_ITEM; } } getdns_return_t _getdns_list_remove_name(getdns_list *list, const char *name) { const char *next, *key = name; char *endptr; size_t index; getdns_item *i; if (*key == '/') { if (!(next = strchr(++key, '/'))) next = strchr(key, '\0'); } else next = strchr(key, '\0'); if (key[0] == '-' && next == key + 1) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; index = strtoul(key, &endptr, 10); if (!isdigit((int)*key) || endptr != next) /* Not a list index, so it was assumed */ return GETDNS_RETURN_WRONG_TYPE_REQUESTED; if (index >= list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; i = &list->items[index]; if (!*next) { switch (i->dtype) { case t_dict : getdns_dict_destroy(i->data.dict); break; case t_list : getdns_list_destroy(i->data.list); break; case t_bindata: _getdns_bindata_destroy( &list->mf, i->data.bindata); default : break; } if (index < list->numinuse - 1) (void) memmove( i, &i[1], (list->numinuse - index) * sizeof(getdns_item)); list->numinuse -= 1; return GETDNS_RETURN_GOOD; } else switch (i->dtype) { case t_dict: return getdns_dict_remove_name(i->data.dict, next); case t_list: return _getdns_list_remove_name(i->data.list, next); default : /* Trying to dereference a non list or dict */ return GETDNS_RETURN_NO_SUCH_LIST_ITEM; } } getdns_return_t _getdns_list_find_and_add( getdns_list *list, const char *key, getdns_item **item) { const char *next; char *endptr; size_t index; getdns_item *newlist, *i; if (*key == '/') { if (!(next = strchr(++key, '/'))) next = strchr(key, '\0'); } else next = strchr(key, '\0'); if (key[0] == '-' && next == key + 1) index = list->numinuse; else { index = strtoul(key, &endptr, 10); if (!isdigit((int)*key) || endptr != next) /* Not a list index, so it was assumed */ return GETDNS_RETURN_WRONG_TYPE_REQUESTED; } if (index > list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; if (index == list->numinuse) { if (list->numalloc <= list->numinuse) { if (!(newlist = GETDNS_XREALLOC(list->mf, list->items, getdns_item, list->numalloc+GETDNS_LIST_BLOCKSZ))) return GETDNS_RETURN_MEMORY_ERROR; list->items = newlist; list->numalloc += GETDNS_LIST_BLOCKSZ; } list->numinuse++; i = &list->items[index]; if (!*next) { i->dtype = t_int; i->data.n = 55555333; *item = i; return GETDNS_RETURN_GOOD; } if ((next[1] == '0' || next[1] == '-') && (next[2] == '/' || next[2] == '\0')) { i->dtype = t_list; i->data.list = _getdns_list_create_with_mf(&list->mf); return _getdns_list_find_and_add( i->data.list, next, item); } i->dtype = t_dict; i->data.dict = _getdns_dict_create_with_mf(&list->mf); return _getdns_dict_find_and_add(i->data.dict, next, item); } i = &list->items[index]; if (!*next) { switch (i->dtype) { case t_dict : getdns_dict_destroy(i->data.dict); break; case t_list : getdns_list_destroy(i->data.list); break; case t_bindata: _getdns_bindata_destroy( &list->mf, i->data.bindata); break; default : break; } i->dtype = t_int; i->data.n = 33355555; *item = i; return GETDNS_RETURN_GOOD; } else switch (i->dtype) { case t_dict: return _getdns_dict_find_and_add(i->data.dict,next,item); case t_list: return _getdns_list_find_and_add(i->data.list,next,item); default : /* Trying to dereference a non list or dict */ return GETDNS_RETURN_WRONG_TYPE_REQUESTED; } } /*---------------------------------------- getdns_list_get_length */ getdns_return_t getdns_list_get_length(const struct getdns_list * list, size_t * answer) { if (!list || !answer) return GETDNS_RETURN_INVALID_PARAMETER; *answer = list->numinuse; return GETDNS_RETURN_GOOD;; } /* getdns_list_get_length */ /*---------------------------------------- getdns_list_get_data_type */ getdns_return_t getdns_list_get_data_type(const struct getdns_list * list, size_t index, getdns_data_type * answer) { if (!list || !answer) return GETDNS_RETURN_INVALID_PARAMETER; if (index >= list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; *answer = list->items[index].dtype; return GETDNS_RETURN_GOOD; } /* getdns_list_get_data_type */ /*---------------------------------------- getdns_list_get_dict */ getdns_return_t getdns_list_get_dict(const struct getdns_list * list, size_t index, struct getdns_dict ** answer) { if (!list || !answer) return GETDNS_RETURN_INVALID_PARAMETER; if (index >= list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; if (list->items[index].dtype != t_dict) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = list->items[index].data.dict; return GETDNS_RETURN_GOOD; } /* getdns_list_get_dict */ /*---------------------------------------- getdns_list_get_list */ getdns_return_t getdns_list_get_list(const struct getdns_list * list, size_t index, struct getdns_list ** answer) { if (!list || !answer) return GETDNS_RETURN_INVALID_PARAMETER; if (index >= list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; if (list->items[index].dtype != t_list) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = list->items[index].data.list; return GETDNS_RETURN_GOOD; } /* getdns_list_get_list */ /*---------------------------------------- getdns_list_get_bindata */ getdns_return_t getdns_list_get_bindata(const struct getdns_list * list, size_t index, struct getdns_bindata ** answer) { if (!list || !answer) return GETDNS_RETURN_INVALID_PARAMETER; if (index >= list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; if (list->items[index].dtype != t_bindata) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = list->items[index].data.bindata; return GETDNS_RETURN_GOOD; } /* getdns_list_get_bindata */ /*---------------------------------------- getdns_list_get_int */ getdns_return_t getdns_list_get_int(const struct getdns_list * list, size_t index, uint32_t * answer) { if (!list || !answer) return GETDNS_RETURN_INVALID_PARAMETER; if (index >= list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; if (list->items[index].dtype != t_int) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = list->items[index].data.n; return GETDNS_RETURN_GOOD; } /* getdns_list_get_int */ /*---------------------------------------- _getdns_list_copy */ getdns_return_t _getdns_list_copy(const struct getdns_list * srclist, struct getdns_list ** dstlist) { int i; getdns_return_t retval; if (!dstlist) return GETDNS_RETURN_INVALID_PARAMETER; if (!srclist) { *dstlist = NULL; return GETDNS_RETURN_GOOD; } *dstlist = getdns_list_create_with_extended_memory_functions( srclist->mf.mf_arg, srclist->mf.mf.ext.malloc, srclist->mf.mf.ext.realloc, srclist->mf.mf.ext.free ); if (!dstlist) return GETDNS_RETURN_GENERIC_ERROR; for (i = 0; i < srclist->numinuse; i++) { switch (srclist->items[i].dtype) { case t_int: retval = _getdns_list_append_int(*dstlist, srclist->items[i].data.n); break; case t_list: retval = _getdns_list_append_list(*dstlist, srclist->items[i].data.list); break; case t_bindata: retval = _getdns_list_append_bindata(*dstlist, srclist->items[i].data.bindata); break; case t_dict: retval = _getdns_list_append_dict(*dstlist, srclist->items[i].data.dict); break; } if (retval != GETDNS_RETURN_GOOD) { getdns_list_destroy(*dstlist); *dstlist = NULL; return retval; } } return GETDNS_RETURN_GOOD; } /* _getdns_list_copy */ struct getdns_list * getdns_list_create_with_extended_memory_functions( void *userarg, void *(*malloc)(void *userarg, size_t), void *(*realloc)(void *userarg, void *, size_t), void (*free)(void *userarg, void *)) { struct getdns_list *list; mf_union mf; if (!malloc || !realloc || !free) return NULL; mf.ext.malloc = malloc; list = userarg == MF_PLAIN ? (struct getdns_list *)(*mf.pln.malloc)( sizeof(struct getdns_list)) : (struct getdns_list *)(*mf.ext.malloc)(userarg, sizeof(struct getdns_list)); if (!list) return NULL; list->mf.mf_arg = userarg; list->mf.mf.ext.malloc = malloc; list->mf.mf.ext.realloc = realloc; list->mf.mf.ext.free = free; list->numinuse = 0; if (!(list->items = GETDNS_XMALLOC( list->mf, getdns_item, GETDNS_LIST_BLOCKSZ))) { GETDNS_FREE(list->mf, list); return NULL; } list->numalloc = GETDNS_LIST_BLOCKSZ; return list; } struct getdns_list * getdns_list_create_with_memory_functions(void *(*malloc)(size_t), void *(*realloc)(void *, size_t), void (*free)(void *)) { mf_union mf; mf.pln.malloc = malloc; mf.pln.realloc = realloc; mf.pln.free = free; return getdns_list_create_with_extended_memory_functions( MF_PLAIN, mf.ext.malloc, mf.ext.realloc, mf.ext.free); } /*-------------------------- getdns_list_create_with_context */ struct getdns_list * getdns_list_create_with_context(struct getdns_context *context) { if (context) return getdns_list_create_with_extended_memory_functions( context->mf.mf_arg, context->mf.mf.ext.malloc, context->mf.mf.ext.realloc, context->mf.mf.ext.free ); else return getdns_list_create_with_memory_functions(malloc, realloc, free); } /* getdns_list_create_with_context */ /*---------------------------------------- getdns_list_create */ struct getdns_list * getdns_list_create() { return getdns_list_create_with_context(NULL); } /* getdns_list_create */ static void _getdns_list_destroy_item(struct getdns_list *list, size_t index) { switch (list->items[index].dtype) { case t_dict: getdns_dict_destroy(list->items[index].data.dict); break; case t_list: getdns_list_destroy(list->items[index].data.list); break; case t_bindata: _getdns_bindata_destroy(&list->mf, list->items[index].data.bindata); break; default: break; } } /*---------------------------------------- getdns_list_destroy */ void getdns_list_destroy(struct getdns_list *list) { size_t i; if (!list) return; for (i = 0; i < list->numinuse; i++) _getdns_list_destroy_item(list, i); if (list->items) GETDNS_FREE(list->mf, list->items); GETDNS_FREE(list->mf, list); } /* getdns_list_destroy */ static getdns_return_t _getdns_list_request_index(getdns_list *list, size_t index) { getdns_item *newlist; assert(list); if (index > list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; if (index < list->numinuse) { _getdns_list_destroy_item(list, index); return GETDNS_RETURN_GOOD; } if (list->numalloc > list->numinuse) { list->numinuse++; return GETDNS_RETURN_GOOD; } if (!(newlist = GETDNS_XREALLOC(list->mf, list->items, getdns_item, list->numalloc + GETDNS_LIST_BLOCKSZ))) return GETDNS_RETURN_MEMORY_ERROR; list->numinuse++; list->items = newlist; list->numalloc += GETDNS_LIST_BLOCKSZ; return GETDNS_RETURN_GOOD; } /*---------------------------------------- getdns_list_set_dict */ getdns_return_t getdns_list_set_dict( getdns_list *list, size_t index, const getdns_dict *child_dict) { getdns_dict *newdict; getdns_return_t r; if (!list || !child_dict) return GETDNS_RETURN_INVALID_PARAMETER; if ((r = _getdns_dict_copy(child_dict, &newdict))) return r; if ((r = _getdns_list_request_index(list, index))) { getdns_dict_destroy(newdict); return r; } list->items[index].dtype = t_dict; list->items[index].data.dict = newdict; return GETDNS_RETURN_GOOD; } /* getdns_list_set_dict */ /*---------------------------------------- getdns_list_set_list */ getdns_return_t getdns_list_set_list( getdns_list *list, size_t index, const getdns_list *child_list) { getdns_list *newlist; getdns_return_t r; if (!list || !child_list) return GETDNS_RETURN_INVALID_PARAMETER; if ((r = _getdns_list_copy(child_list, &newlist))) return r; if ((r = _getdns_list_request_index(list, index))) { getdns_list_destroy(newlist); return r; } list->items[index].dtype = t_list; list->items[index].data.list = newlist; return GETDNS_RETURN_GOOD; } /* getdns_list_set_list */ /*---------------------------------------- getdns_list_set_bindata */ static getdns_return_t _getdns_list_set_const_bindata( getdns_list *list, size_t index, size_t size, const void *data) { getdns_bindata *newbindata; getdns_return_t r; if (!list) return GETDNS_RETURN_INVALID_PARAMETER; if (!(newbindata = _getdns_bindata_copy(&list->mf, size, data))) return GETDNS_RETURN_MEMORY_ERROR; if ((r = _getdns_list_request_index(list, index))) { _getdns_bindata_destroy(&list->mf, newbindata); return r; } list->items[index].dtype = t_bindata; list->items[index].data.bindata = newbindata; return GETDNS_RETURN_GOOD; } /* getdns_list_set_bindata */ getdns_return_t getdns_list_set_bindata( getdns_list *list, size_t index, const getdns_bindata *child_bindata) { return !child_bindata ? GETDNS_RETURN_INVALID_PARAMETER : _getdns_list_set_const_bindata( list, index, child_bindata->size, child_bindata->data); } /*----------------------------------------- getdns_list_set_string */ static getdns_return_t getdns_list_set_string(getdns_list *list, size_t index, const char *value) { return value ? _getdns_list_set_const_bindata(list, index, strlen(value), value) : GETDNS_RETURN_INVALID_PARAMETER; } /* getdns_list_set_string */ /*---------------------------------------- getdns_list_set_int */ getdns_return_t getdns_list_set_int(getdns_list * list, size_t index, uint32_t child_int) { getdns_return_t r; if (!list) return GETDNS_RETURN_INVALID_PARAMETER; if ((r = _getdns_list_request_index(list, index))) return r; list->items[index].dtype = t_int; list->items[index].data.n = child_int; return GETDNS_RETURN_GOOD; } /* getdns_list_set_int */ getdns_return_t _getdns_list_append_dict(getdns_list *list, const getdns_dict *child_dict) { if (!list) return GETDNS_RETURN_INVALID_PARAMETER; return getdns_list_set_dict(list, list->numinuse, child_dict); } getdns_return_t _getdns_list_append_list(getdns_list *list, const getdns_list *child_list) { if (!list) return GETDNS_RETURN_INVALID_PARAMETER; return getdns_list_set_list(list, list->numinuse, child_list); } getdns_return_t _getdns_list_append_bindata(getdns_list *list, const getdns_bindata *child_bindata) { if (!list) return GETDNS_RETURN_INVALID_PARAMETER; return getdns_list_set_bindata(list, list->numinuse, child_bindata); } getdns_return_t _getdns_list_append_const_bindata( getdns_list *list, size_t size, const void *data) { if (!list) return GETDNS_RETURN_INVALID_PARAMETER; return _getdns_list_set_const_bindata(list, list->numinuse, size, data); } getdns_return_t _getdns_list_append_string(getdns_list *list, const char *value) { if (!list) return GETDNS_RETURN_INVALID_PARAMETER; return getdns_list_set_string(list, list->numinuse, value); } getdns_return_t _getdns_list_append_int(getdns_list *list, uint32_t child_int) { if (!list) return GETDNS_RETURN_INVALID_PARAMETER; return getdns_list_set_int(list, list->numinuse, child_int); } /* getdns_list.c */ getdns-0.9.0/src/compat/0000775000175100017510000000000012641212403012056 500000000000000getdns-0.9.0/src/compat/getentropy_solaris.c0000664000175100017510000002451712641212403016107 00000000000000/* $OpenBSD: getentropy_solaris.c,v 1.3 2014/07/12 14:46:31 deraadt Exp $ */ /* * Copyright (c) 2014 Theo de Raadt * Copyright (c) 2014 Bob Beck * * 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SHA512_Init SHA512Init #define SHA512_Update SHA512Update #define SHA512_Final SHA512Final #include #include #include #define REPEAT 5 #define min(a, b) (((a) < (b)) ? (a) : (b)) #define HX(a, b) \ do { \ if ((a)) \ HD(errno); \ else \ HD(b); \ } while (0) #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) #define HF(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (void*))) int getentropy(void *buf, size_t len); #ifdef CAN_REFERENCE_MAIN extern int main(int, char *argv[]); #endif static int gotdata(char *buf, size_t len); static int getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck); static int getentropy_fallback(void *buf, size_t len); int getentropy(void *buf, size_t len) { int ret = -1; if (len > 256) { errno = EIO; return -1; } /* * Try to get entropy with /dev/urandom * * Solaris provides /dev/urandom as a symbolic link to * /devices/pseudo/random@0:urandom which is provided by * a devfs filesystem. Best practice is to use O_NOFOLLOW, * so we must try the unpublished name directly. * * This can fail if the process is inside a chroot which lacks * the devfs mount, or if file descriptors are exhausted. */ ret = getentropy_urandom(buf, len, "/devices/pseudo/random@0:urandom", 1); if (ret != -1) return (ret); /* * Unfortunately, chroot spaces on Solaris are sometimes setup * with direct device node of the well-known /dev/urandom name * (perhaps to avoid dragging all of devfs into the space). * * This can fail if the process is inside a chroot or if file * descriptors are exhausted. */ ret = getentropy_urandom(buf, len, "/dev/urandom", 0); if (ret != -1) return (ret); /* * Entropy collection via /dev/urandom has failed. * * No other API exists for collecting entropy, and we have * no failsafe way to get it on Solaris that is not sensitive * to resource exhaustion. * * We have very few options: * - Even syslog_r is unsafe to call at this low level, so * there is no way to alert the user or program. * - Cannot call abort() because some systems have unsafe * corefiles. * - Could raise(SIGKILL) resulting in silent program termination. * - Return EIO, to hint that arc4random's stir function * should raise(SIGKILL) * - Do the best under the circumstances.... * * This code path exists to bring light to the issue that Solaris * does not provide a failsafe API for entropy collection. * * We hope this demonstrates that Solaris should consider * providing a new failsafe API which works in a chroot or * when file descriptors are exhausted. */ #undef FAIL_INSTEAD_OF_TRYING_FALLBACK #ifdef FAIL_INSTEAD_OF_TRYING_FALLBACK raise(SIGKILL); #endif ret = getentropy_fallback(buf, len); if (ret != -1) return (ret); errno = EIO; return (ret); } /* * Basic sanity checking; wish we could do better. */ static int gotdata(char *buf, size_t len) { char any_set = 0; size_t i; for (i = 0; i < len; ++i) any_set |= buf[i]; if (any_set == 0) return -1; return 0; } static int getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck) { struct stat st; size_t i; int fd, flags; int save_errno = errno; start: flags = O_RDONLY; #ifdef O_NOFOLLOW flags |= O_NOFOLLOW; #endif #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif fd = open(path, flags, 0); if (fd == -1) { if (errno == EINTR) goto start; goto nodevrandom; } #ifndef O_CLOEXEC fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); #endif /* Lightly verify that the device node looks sane */ if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode) || (devfscheck && (strcmp(st.st_fstype, "devfs") != 0))) { close(fd); goto nodevrandom; } for (i = 0; i < len; ) { size_t wanted = len - i; ssize_t ret = read(fd, (char*)buf + i, wanted); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) continue; close(fd); goto nodevrandom; } i += ret; } close(fd); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } nodevrandom: errno = EIO; return -1; } static const int cl[] = { CLOCK_REALTIME, #ifdef CLOCK_MONOTONIC CLOCK_MONOTONIC, #endif #ifdef CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC_RAW, #endif #ifdef CLOCK_TAI CLOCK_TAI, #endif #ifdef CLOCK_VIRTUAL CLOCK_VIRTUAL, #endif #ifdef CLOCK_UPTIME CLOCK_UPTIME, #endif #ifdef CLOCK_PROCESS_CPUTIME_ID CLOCK_PROCESS_CPUTIME_ID, #endif #ifdef CLOCK_THREAD_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID, #endif }; static int getentropy_fallback(void *buf, size_t len) { uint8_t results[SHA512_DIGEST_LENGTH]; int save_errno = errno, e, pgs = getpagesize(), faster = 0, repeat; static int cnt; struct timespec ts; struct timeval tv; double loadavg[3]; struct rusage ru; sigset_t sigset; struct stat st; SHA512_CTX ctx; static pid_t lastpid; pid_t pid; size_t i, ii, m; char *p; pid = getpid(); if (lastpid == pid) { faster = 1; repeat = 2; } else { faster = 0; lastpid = pid; repeat = REPEAT; } for (i = 0; i < len; ) { int j; SHA512_Init(&ctx); for (j = 0; j < repeat; j++) { HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) HX(clock_gettime(cl[ii], &ts) == -1, ts); HX((pid = getpid()) == -1, pid); HX((pid = getsid(pid)) == -1, pid); HX((pid = getppid()) == -1, pid); HX((pid = getpgid(0)) == -1, pid); HX((e = getpriority(0, 0)) == -1, e); HX((getloadavg(loadavg, 3) == -1), loadavg); if (!faster) { ts.tv_sec = 0; ts.tv_nsec = 1; (void) nanosleep(&ts, NULL); } HX(sigpending(&sigset) == -1, sigset); HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, sigset); #ifdef CAN_REFERENCE_MAIN HF(main); /* an addr in program */ #endif HF(getentropy); /* an addr in this library */ HF(printf); /* an addr in libc */ p = (char *)&p; HD(p); /* an addr on stack */ p = (char *)&errno; HD(p); /* the addr of errno */ if (i == 0) { struct sockaddr_storage ss; struct statvfs stvfs; struct termios tios; socklen_t ssl; off_t off; /* * Prime-sized mappings encourage fragmentation; * thus exposing some address entropy. */ struct mm { size_t npg; void *p; } mm[] = { { 17, MAP_FAILED }, { 3, MAP_FAILED }, { 11, MAP_FAILED }, { 2, MAP_FAILED }, { 5, MAP_FAILED }, { 3, MAP_FAILED }, { 7, MAP_FAILED }, { 1, MAP_FAILED }, { 57, MAP_FAILED }, { 3, MAP_FAILED }, { 131, MAP_FAILED }, { 1, MAP_FAILED }, }; for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { HX(mm[m].p = mmap(NULL, mm[m].npg * pgs, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, (off_t)0), mm[m].p); if (mm[m].p != MAP_FAILED) { size_t mo; /* Touch some memory... */ p = mm[m].p; mo = cnt % (mm[m].npg * pgs - 1); p[mo] = 1; cnt += (int)((long)(mm[m].p) / pgs); } /* Check cnts and times... */ for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) { HX((e = clock_gettime(cl[ii], &ts)) == -1, ts); if (e != -1) cnt += (int)ts.tv_nsec; } HX((e = getrusage(RUSAGE_SELF, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { if (mm[m].p != MAP_FAILED) munmap(mm[m].p, mm[m].npg * pgs); mm[m].p = MAP_FAILED; } HX(stat(".", &st) == -1, st); HX(statvfs(".", &stvfs) == -1, stvfs); HX(stat("/", &st) == -1, st); HX(statvfs("/", &stvfs) == -1, stvfs); HX((e = fstat(0, &st)) == -1, st); if (e == -1) { if (S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { HX(fstatvfs(0, &stvfs) == -1, stvfs); HX((off = lseek(0, (off_t)0, SEEK_CUR)) < 0, off); } if (S_ISCHR(st.st_mode)) { HX(tcgetattr(0, &tios) == -1, tios); } else if (S_ISSOCK(st.st_mode)) { memset(&ss, 0, sizeof ss); ssl = sizeof(ss); HX(getpeername(0, (void *)&ss, &ssl) == -1, ss); } } HX((e = getrusage(RUSAGE_CHILDREN, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } else { /* Subsequent hashes absorb previous result */ HD(results); } HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } HD(cnt); } SHA512_Final(results, &ctx); memcpy((char*)buf + i, results, min(sizeof(results), len - i)); i += min(sizeof(results), len - i); } memset(results, 0, sizeof results); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } errno = EIO; return -1; } getdns-0.9.0/src/compat/sha512.c0000664000175100017510000003700212641212403013147 00000000000000/* * FILE: sha2.c * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ * * Copyright (c) 2000-2001, Aaron D. Gifford * All rights reserved. * * Modified by Jelte Jansen to fit in ldns, and not clash with any * system-defined SHA code. * Changes: * - Renamed (external) functions and constants to fit ldns style * - Removed _End and _Data functions * - Added ldns_shaX(data, len, digest) convenience functions * - Removed prototypes of _Transform functions and made those static * Modified by Wouter, and trimmed, to provide SHA512 for getentropy_fallback. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $ */ #include "config.h" #include /* memcpy()/memset() or bcopy()/bzero() */ #include /* assert() */ /* do we have sha512 header defs */ #ifndef SHA512_DIGEST_LENGTH #define SHA512_BLOCK_LENGTH 128 #define SHA512_DIGEST_LENGTH 64 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) typedef struct _SHA512_CTX { uint64_t state[8]; uint64_t bitcount[2]; uint8_t buffer[SHA512_BLOCK_LENGTH]; } SHA512_CTX; #endif /* do we have sha512 header defs */ void SHA512_Init(SHA512_CTX*); void SHA512_Update(SHA512_CTX*, void*, size_t); void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); unsigned char *SHA512(void *data, unsigned int data_len, unsigned char *digest); /*** SHA-256/384/512 Machine Architecture Definitions *****************/ /* * BYTE_ORDER NOTE: * * Please make sure that your system defines BYTE_ORDER. If your * architecture is little-endian, make sure it also defines * LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are * equivilent. * * If your system does not define the above, then you can do so by * hand like this: * * #define LITTLE_ENDIAN 1234 * #define BIG_ENDIAN 4321 * * And for little-endian machines, add: * * #define BYTE_ORDER LITTLE_ENDIAN * * Or for big-endian machines: * * #define BYTE_ORDER BIG_ENDIAN * * The FreeBSD machine this was written on defines BYTE_ORDER * appropriately by including (which in turn includes * where the appropriate definitions are actually * made). */ #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN #endif typedef uint8_t sha2_byte; /* Exactly 1 byte */ typedef uint32_t sha2_word32; /* Exactly 4 bytes */ #ifdef S_SPLINT_S typedef unsigned long long sha2_word64; /* lint 8 bytes */ #else typedef uint64_t sha2_word64; /* Exactly 8 bytes */ #endif /*** SHA-256/384/512 Various Length Definitions ***********************/ #define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16) /*** ENDIAN REVERSAL MACROS *******************************************/ #if BYTE_ORDER == LITTLE_ENDIAN #define REVERSE32(w,x) { \ sha2_word32 tmp = (w); \ tmp = (tmp >> 16) | (tmp << 16); \ (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \ } #ifndef S_SPLINT_S #define REVERSE64(w,x) { \ sha2_word64 tmp = (w); \ tmp = (tmp >> 32) | (tmp << 32); \ tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | \ ((tmp & 0x00ff00ff00ff00ffULL) << 8); \ (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \ ((tmp & 0x0000ffff0000ffffULL) << 16); \ } #else /* splint */ #define REVERSE64(w,x) /* splint */ #endif /* splint */ #endif /* BYTE_ORDER == LITTLE_ENDIAN */ /* * Macro for incrementally adding the unsigned 64-bit integer n to the * unsigned 128-bit integer (represented using a two-element array of * 64-bit words): */ #define ADDINC128(w,n) { \ (w)[0] += (sha2_word64)(n); \ if ((w)[0] < (n)) { \ (w)[1]++; \ } \ } #ifdef S_SPLINT_S #undef ADDINC128 #define ADDINC128(w,n) /* splint */ #endif /* * Macros for copying blocks of memory and for zeroing out ranges * of memory. Using these macros makes it easy to switch from * using memset()/memcpy() and using bzero()/bcopy(). * * Please define either SHA2_USE_MEMSET_MEMCPY or define * SHA2_USE_BZERO_BCOPY depending on which function set you * choose to use: */ #if !defined(SHA2_USE_MEMSET_MEMCPY) && !defined(SHA2_USE_BZERO_BCOPY) /* Default to memset()/memcpy() if no option is specified */ #define SHA2_USE_MEMSET_MEMCPY 1 #endif #if defined(SHA2_USE_MEMSET_MEMCPY) && defined(SHA2_USE_BZERO_BCOPY) /* Abort with an error if BOTH options are defined */ #error Define either SHA2_USE_MEMSET_MEMCPY or SHA2_USE_BZERO_BCOPY, not both! #endif #ifdef SHA2_USE_MEMSET_MEMCPY #define MEMSET_BZERO(p,l) memset((p), 0, (l)) #define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l)) #endif #ifdef SHA2_USE_BZERO_BCOPY #define MEMSET_BZERO(p,l) bzero((p), (l)) #define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l)) #endif /*** THE SIX LOGICAL FUNCTIONS ****************************************/ /* * Bit shifting and rotation (used by the six SHA-XYZ logical functions: * * NOTE: The naming of R and S appears backwards here (R is a SHIFT and * S is a ROTATION) because the SHA-256/384/512 description document * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this * same "backwards" definition. */ /* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ #define R(b,x) ((x) >> (b)) /* 64-bit Rotate-right (used in SHA-384 and SHA-512): */ #define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b)))) /* Two of six logical functions used in SHA-256, SHA-384, and SHA-512: */ #define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) #define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) /* Four of six logical functions used in SHA-384 and SHA-512: */ #define Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x))) #define Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x))) #define sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x))) #define sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x))) /*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ /* Hash constant words K for SHA-384 and SHA-512: */ static const sha2_word64 K512[80] = { 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL }; /* initial hash value H for SHA-512 */ static const sha2_word64 sha512_initial_hash_value[8] = { 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL, 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL }; typedef union _ldns_sha2_buffer_union { uint8_t* theChars; uint64_t* theLongs; } ldns_sha2_buffer_union; /*** SHA-512: *********************************************************/ void SHA512_Init(SHA512_CTX* context) { if (context == (SHA512_CTX*)0) { return; } MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH); MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH); context->bitcount[0] = context->bitcount[1] = 0; } static void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { sha2_word64 a, b, c, d, e, f, g, h, s0, s1; sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer; int j; /* initialize registers with the prev. intermediate value */ a = context->state[0]; b = context->state[1]; c = context->state[2]; d = context->state[3]; e = context->state[4]; f = context->state[5]; g = context->state[6]; h = context->state[7]; j = 0; do { #if BYTE_ORDER == LITTLE_ENDIAN /* Convert TO host byte order */ REVERSE64(*data++, W512[j]); /* Apply the SHA-512 compression function to update a..h */ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j]; #else /* BYTE_ORDER == LITTLE_ENDIAN */ /* Apply the SHA-512 compression function to update a..h with copy */ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++); #endif /* BYTE_ORDER == LITTLE_ENDIAN */ T2 = Sigma0_512(a) + Maj(a, b, c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; j++; } while (j < 16); do { /* Part of the message block expansion: */ s0 = W512[(j+1)&0x0f]; s0 = sigma0_512(s0); s1 = W512[(j+14)&0x0f]; s1 = sigma1_512(s1); /* Apply the SHA-512 compression function to update a..h */ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); T2 = Sigma0_512(a) + Maj(a, b, c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; j++; } while (j < 80); /* Compute the current intermediate hash value */ context->state[0] += a; context->state[1] += b; context->state[2] += c; context->state[3] += d; context->state[4] += e; context->state[5] += f; context->state[6] += g; context->state[7] += h; /* Clean up */ a = b = c = d = e = f = g = h = T1 = T2 = 0; } void SHA512_Update(SHA512_CTX* context, void *datain, size_t len) { size_t freespace, usedspace; const sha2_byte* data = (const sha2_byte*)datain; if (len == 0) { /* Calling with no data is valid - we do nothing */ return; } /* Sanity check: */ assert(context != (SHA512_CTX*)0 && data != (sha2_byte*)0); usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; if (usedspace > 0) { /* Calculate how much free space is available in the buffer */ freespace = SHA512_BLOCK_LENGTH - usedspace; if (len >= freespace) { /* Fill the buffer completely and process it */ MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace); ADDINC128(context->bitcount, freespace << 3); len -= freespace; data += freespace; SHA512_Transform(context, (sha2_word64*)context->buffer); } else { /* The buffer is not yet full */ MEMCPY_BCOPY(&context->buffer[usedspace], data, len); ADDINC128(context->bitcount, len << 3); /* Clean up: */ usedspace = freespace = 0; return; } } while (len >= SHA512_BLOCK_LENGTH) { /* Process as many complete blocks as we can */ SHA512_Transform(context, (sha2_word64*)data); ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3); len -= SHA512_BLOCK_LENGTH; data += SHA512_BLOCK_LENGTH; } if (len > 0) { /* There's left-overs, so save 'em */ MEMCPY_BCOPY(context->buffer, data, len); ADDINC128(context->bitcount, len << 3); } /* Clean up: */ usedspace = freespace = 0; } static void SHA512_Last(SHA512_CTX* context) { size_t usedspace; ldns_sha2_buffer_union cast_var; usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; #if BYTE_ORDER == LITTLE_ENDIAN /* Convert FROM host byte order */ REVERSE64(context->bitcount[0],context->bitcount[0]); REVERSE64(context->bitcount[1],context->bitcount[1]); #endif if (usedspace > 0) { /* Begin padding with a 1 bit: */ context->buffer[usedspace++] = 0x80; if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) { /* Set-up for the last transform: */ MEMSET_BZERO(&context->buffer[usedspace], SHA512_SHORT_BLOCK_LENGTH - usedspace); } else { if (usedspace < SHA512_BLOCK_LENGTH) { MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace); } /* Do second-to-last transform: */ SHA512_Transform(context, (sha2_word64*)context->buffer); /* And set-up for the last transform: */ MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2); } } else { /* Prepare for final transform: */ MEMSET_BZERO(context->buffer, SHA512_SHORT_BLOCK_LENGTH); /* Begin padding with a 1 bit: */ *context->buffer = 0x80; } /* Store the length of input data (in bits): */ cast_var.theChars = context->buffer; cast_var.theLongs[SHA512_SHORT_BLOCK_LENGTH / 8] = context->bitcount[1]; cast_var.theLongs[SHA512_SHORT_BLOCK_LENGTH / 8 + 1] = context->bitcount[0]; /* final transform: */ SHA512_Transform(context, (sha2_word64*)context->buffer); } void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { sha2_word64 *d = (sha2_word64*)digest; /* Sanity check: */ assert(context != (SHA512_CTX*)0); /* If no digest buffer is passed, we don't bother doing this: */ if (digest != (sha2_byte*)0) { SHA512_Last(context); /* Save the hash data for output: */ #if BYTE_ORDER == LITTLE_ENDIAN { /* Convert TO host byte order */ int j; for (j = 0; j < 8; j++) { REVERSE64(context->state[j],context->state[j]); *d++ = context->state[j]; } } #else MEMCPY_BCOPY(d, context->state, SHA512_DIGEST_LENGTH); #endif } /* Zero out state data */ MEMSET_BZERO(context, sizeof(SHA512_CTX)); } unsigned char * SHA512(void *data, unsigned int data_len, unsigned char *digest) { SHA512_CTX ctx; SHA512_Init(&ctx); SHA512_Update(&ctx, data, data_len); SHA512_Final(digest, &ctx); return digest; } getdns-0.9.0/src/compat/getentropy_osx.c0000664000175100017510000002505112641212403015236 00000000000000/* $OpenBSD: getentropy_osx.c,v 1.3 2014/07/12 14:48:00 deraadt Exp $ */ /* * Copyright (c) 2014 Theo de Raadt * Copyright (c) 2014 Bob Beck * * 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SHA512_Update(a, b, c) (CC_SHA512_Update((a), (b), (c))) #define SHA512_Init(xxx) (CC_SHA512_Init((xxx))) #define SHA512_Final(xxx, yyy) (CC_SHA512_Final((xxx), (yyy))) #define SHA512_CTX CC_SHA512_CTX #define SHA512_DIGEST_LENGTH CC_SHA512_DIGEST_LENGTH #define REPEAT 5 #define min(a, b) (((a) < (b)) ? (a) : (b)) #define HX(a, b) \ do { \ if ((a)) \ HD(errno); \ else \ HD(b); \ } while (0) #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) #define HF(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (void*))) int getentropy(void *buf, size_t len); #ifdef CAN_REFERENCE_MAIN extern int main(int, char *argv[]); #endif static int gotdata(char *buf, size_t len); static int getentropy_urandom(void *buf, size_t len); static int getentropy_fallback(void *buf, size_t len); int getentropy(void *buf, size_t len) { int ret = -1; if (len > 256) { errno = EIO; return -1; } /* * Try to get entropy with /dev/urandom * * This can fail if the process is inside a chroot or if file * descriptors are exhausted. */ ret = getentropy_urandom(buf, len); if (ret != -1) return (ret); /* * Entropy collection via /dev/urandom and sysctl have failed. * * No other API exists for collecting entropy, and we have * no failsafe way to get it on OSX that is not sensitive * to resource exhaustion. * * We have very few options: * - Even syslog_r is unsafe to call at this low level, so * there is no way to alert the user or program. * - Cannot call abort() because some systems have unsafe * corefiles. * - Could raise(SIGKILL) resulting in silent program termination. * - Return EIO, to hint that arc4random's stir function * should raise(SIGKILL) * - Do the best under the circumstances.... * * This code path exists to bring light to the issue that OSX * does not provide a failsafe API for entropy collection. * * We hope this demonstrates that OSX should consider * providing a new failsafe API which works in a chroot or * when file descriptors are exhausted. */ #undef FAIL_INSTEAD_OF_TRYING_FALLBACK #ifdef FAIL_INSTEAD_OF_TRYING_FALLBACK raise(SIGKILL); #endif ret = getentropy_fallback(buf, len); if (ret != -1) return (ret); errno = EIO; return (ret); } /* * Basic sanity checking; wish we could do better. */ static int gotdata(char *buf, size_t len) { char any_set = 0; size_t i; for (i = 0; i < len; ++i) any_set |= buf[i]; if (any_set == 0) return -1; return 0; } static int getentropy_urandom(void *buf, size_t len) { struct stat st; size_t i; int fd, flags; int save_errno = errno; start: flags = O_RDONLY; #ifdef O_NOFOLLOW flags |= O_NOFOLLOW; #endif #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif fd = open("/dev/urandom", flags, 0); if (fd == -1) { if (errno == EINTR) goto start; goto nodevrandom; } #ifndef O_CLOEXEC fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); #endif /* Lightly verify that the device node looks sane */ if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) { close(fd); goto nodevrandom; } for (i = 0; i < len; ) { size_t wanted = len - i; ssize_t ret = read(fd, (char*)buf + i, wanted); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) continue; close(fd); goto nodevrandom; } i += ret; } close(fd); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } nodevrandom: errno = EIO; return -1; } static int tcpmib[] = { CTL_NET, AF_INET, IPPROTO_TCP, TCPCTL_STATS }; static int udpmib[] = { CTL_NET, AF_INET, IPPROTO_UDP, UDPCTL_STATS }; static int ipmib[] = { CTL_NET, AF_INET, IPPROTO_IP, IPCTL_STATS }; static int kmib[] = { CTL_KERN, KERN_USRSTACK }; static int hwmib[] = { CTL_HW, HW_USERMEM }; static int getentropy_fallback(void *buf, size_t len) { uint8_t results[SHA512_DIGEST_LENGTH]; int save_errno = errno, e, pgs = getpagesize(), faster = 0, repeat; static int cnt; struct timespec ts; struct timeval tv; struct rusage ru; sigset_t sigset; struct stat st; SHA512_CTX ctx; static pid_t lastpid; pid_t pid; size_t i, ii, m; char *p; struct tcpstat tcpstat; struct udpstat udpstat; struct ipstat ipstat; u_int64_t mach_time; unsigned int idata; void *addr; pid = getpid(); if (lastpid == pid) { faster = 1; repeat = 2; } else { faster = 0; lastpid = pid; repeat = REPEAT; } for (i = 0; i < len; ) { int j; SHA512_Init(&ctx); for (j = 0; j < repeat; j++) { HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } mach_time = mach_absolute_time(); HD(mach_time); ii = sizeof(addr); HX(sysctl(kmib, sizeof(kmib) / sizeof(kmib[0]), &addr, &ii, NULL, 0) == -1, addr); ii = sizeof(idata); HX(sysctl(hwmib, sizeof(hwmib) / sizeof(hwmib[0]), &idata, &ii, NULL, 0) == -1, idata); ii = sizeof(tcpstat); HX(sysctl(tcpmib, sizeof(tcpmib) / sizeof(tcpmib[0]), &tcpstat, &ii, NULL, 0) == -1, tcpstat); ii = sizeof(udpstat); HX(sysctl(udpmib, sizeof(udpmib) / sizeof(udpmib[0]), &udpstat, &ii, NULL, 0) == -1, udpstat); ii = sizeof(ipstat); HX(sysctl(ipmib, sizeof(ipmib) / sizeof(ipmib[0]), &ipstat, &ii, NULL, 0) == -1, ipstat); HX((pid = getpid()) == -1, pid); HX((pid = getsid(pid)) == -1, pid); HX((pid = getppid()) == -1, pid); HX((pid = getpgid(0)) == -1, pid); HX((e = getpriority(0, 0)) == -1, e); if (!faster) { ts.tv_sec = 0; ts.tv_nsec = 1; (void) nanosleep(&ts, NULL); } HX(sigpending(&sigset) == -1, sigset); HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, sigset); #ifdef CAN_REFERENCE_MAIN HF(main); /* an addr in program */ #endif HF(getentropy); /* an addr in this library */ HF(printf); /* an addr in libc */ p = (char *)&p; HD(p); /* an addr on stack */ p = (char *)&errno; HD(p); /* the addr of errno */ if (i == 0) { struct sockaddr_storage ss; struct statvfs stvfs; struct termios tios; struct statfs stfs; socklen_t ssl; off_t off; /* * Prime-sized mappings encourage fragmentation; * thus exposing some address entropy. */ struct mm { size_t npg; void *p; } mm[] = { { 17, MAP_FAILED }, { 3, MAP_FAILED }, { 11, MAP_FAILED }, { 2, MAP_FAILED }, { 5, MAP_FAILED }, { 3, MAP_FAILED }, { 7, MAP_FAILED }, { 1, MAP_FAILED }, { 57, MAP_FAILED }, { 3, MAP_FAILED }, { 131, MAP_FAILED }, { 1, MAP_FAILED }, }; for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { HX(mm[m].p = mmap(NULL, mm[m].npg * pgs, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, (off_t)0), mm[m].p); if (mm[m].p != MAP_FAILED) { size_t mo; /* Touch some memory... */ p = mm[m].p; mo = cnt % (mm[m].npg * pgs - 1); p[mo] = 1; cnt += (int)((long)(mm[m].p) / pgs); } /* Check cnts and times... */ mach_time = mach_absolute_time(); HD(mach_time); cnt += (int)mach_time; HX((e = getrusage(RUSAGE_SELF, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { if (mm[m].p != MAP_FAILED) munmap(mm[m].p, mm[m].npg * pgs); mm[m].p = MAP_FAILED; } HX(stat(".", &st) == -1, st); HX(statvfs(".", &stvfs) == -1, stvfs); HX(statfs(".", &stfs) == -1, stfs); HX(stat("/", &st) == -1, st); HX(statvfs("/", &stvfs) == -1, stvfs); HX(statfs("/", &stfs) == -1, stfs); HX((e = fstat(0, &st)) == -1, st); if (e == -1) { if (S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { HX(fstatvfs(0, &stvfs) == -1, stvfs); HX(fstatfs(0, &stfs) == -1, stfs); HX((off = lseek(0, (off_t)0, SEEK_CUR)) < 0, off); } if (S_ISCHR(st.st_mode)) { HX(tcgetattr(0, &tios) == -1, tios); } else if (S_ISSOCK(st.st_mode)) { memset(&ss, 0, sizeof ss); ssl = sizeof(ss); HX(getpeername(0, (void *)&ss, &ssl) == -1, ss); } } HX((e = getrusage(RUSAGE_CHILDREN, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } else { /* Subsequent hashes absorb previous result */ HD(results); } HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } HD(cnt); } SHA512_Final(results, &ctx); memcpy((char*)buf + i, results, min(sizeof(results), len - i)); i += min(sizeof(results), len - i); } memset(results, 0, sizeof results); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } errno = EIO; return -1; } getdns-0.9.0/src/compat/getentropy_linux.c0000664000175100017510000003056512641212403015572 00000000000000/* $OpenBSD: getentropy_linux.c,v 1.20 2014/07/12 15:43:49 beck Exp $ */ /* * Copyright (c) 2014 Theo de Raadt * Copyright (c) 2014 Bob Beck * * 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" #ifndef GETDNS_ON_WINDOWS /* #define _POSIX_C_SOURCE 199309L #define _GNU_SOURCE 1 */ #include #include #include #include #include #ifdef HAVE_SYS_SYSCTL_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_GETAUXVAL #include #endif #include #define REPEAT 5 #define min(a, b) (((a) < (b)) ? (a) : (b)) #define HX(a, b) \ do { \ if ((a)) \ HD(errno); \ else \ HD(b); \ } while (0) #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) #define HF(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (void*))) int getentropy(void *buf, size_t len); #ifdef CAN_REFERENCE_MAIN extern int main(int, char *argv[]); #endif static int gotdata(char *buf, size_t len); #ifdef SYS_getrandom static int getentropy_getrandom(void *buf, size_t len); #endif static int getentropy_urandom(void *buf, size_t len); #ifdef SYS__sysctl static int getentropy_sysctl(void *buf, size_t len); #endif static int getentropy_fallback(void *buf, size_t len); int getentropy(void *buf, size_t len) { int ret = -1; if (len > 256) { errno = EIO; return -1; } #ifdef SYS_getrandom /* * Try descriptor-less getrandom() */ ret = getentropy_getrandom(buf, len); if (ret != -1) return (ret); if (errno != ENOSYS) return (-1); #endif /* * Try to get entropy with /dev/urandom * * This can fail if the process is inside a chroot or if file * descriptors are exhausted. */ ret = getentropy_urandom(buf, len); if (ret != -1) return (ret); #ifdef SYS__sysctl /* * Try to use sysctl CTL_KERN, KERN_RANDOM, RANDOM_UUID. * sysctl is a failsafe API, so it guarantees a result. This * should work inside a chroot, or when file descriptors are * exhuasted. * * However this can fail if the Linux kernel removes support * for sysctl. Starting in 2007, there have been efforts to * deprecate the sysctl API/ABI, and push callers towards use * of the chroot-unavailable fd-using /proc mechanism -- * essentially the same problems as /dev/urandom. * * Numerous setbacks have been encountered in their deprecation * schedule, so as of June 2014 the kernel ABI still exists on * most Linux architectures. The sysctl() stub in libc is missing * on some systems. There are also reports that some kernels * spew messages to the console. */ ret = getentropy_sysctl(buf, len); if (ret != -1) return (ret); #endif /* SYS__sysctl */ /* * Entropy collection via /dev/urandom and sysctl have failed. * * No other API exists for collecting entropy. See the large * comment block above. * * We have very few options: * - Even syslog_r is unsafe to call at this low level, so * there is no way to alert the user or program. * - Cannot call abort() because some systems have unsafe * corefiles. * - Could raise(SIGKILL) resulting in silent program termination. * - Return EIO, to hint that arc4random's stir function * should raise(SIGKILL) * - Do the best under the circumstances.... * * This code path exists to bring light to the issue that Linux * does not provide a failsafe API for entropy collection. * * We hope this demonstrates that Linux should either retain their * sysctl ABI, or consider providing a new failsafe API which * works in a chroot or when file descriptors are exhausted. */ #undef FAIL_INSTEAD_OF_TRYING_FALLBACK #ifdef FAIL_INSTEAD_OF_TRYING_FALLBACK raise(SIGKILL); #endif ret = getentropy_fallback(buf, len); if (ret != -1) return (ret); errno = EIO; return (ret); } /* * Basic sanity checking; wish we could do better. */ static int gotdata(char *buf, size_t len) { char any_set = 0; size_t i; for (i = 0; i < len; ++i) any_set |= buf[i]; if (any_set == 0) return -1; return 0; } #ifdef SYS_getrandom static int getentropy_getrandom(void *buf, size_t len) { int pre_errno = errno; int ret; if (len > 256) return (-1); do { ret = syscall(SYS_getrandom, buf, len, 0); } while (ret == -1 && errno == EINTR); if (ret != (int)len) return (-1); errno = pre_errno; return (0); } #endif static int getentropy_urandom(void *buf, size_t len) { struct stat st; size_t i; int fd, cnt, flags; int save_errno = errno; start: flags = O_RDONLY; #ifdef O_NOFOLLOW flags |= O_NOFOLLOW; #endif #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif fd = open("/dev/urandom", flags, 0); if (fd == -1) { if (errno == EINTR) goto start; goto nodevrandom; } #ifndef O_CLOEXEC fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); #endif /* Lightly verify that the device node looks sane */ if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) { close(fd); goto nodevrandom; } if (ioctl(fd, RNDGETENTCNT, &cnt) == -1) { close(fd); goto nodevrandom; } for (i = 0; i < len; ) { size_t wanted = len - i; ssize_t ret = read(fd, (char*)buf + i, wanted); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) continue; close(fd); goto nodevrandom; } i += ret; } close(fd); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } nodevrandom: errno = EIO; return -1; } #ifdef SYS__sysctl static int getentropy_sysctl(void *buf, size_t len) { static int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID }; size_t i; int save_errno = errno; for (i = 0; i < len; ) { size_t chunk = min(len - i, 16); /* SYS__sysctl because some systems already removed sysctl() */ struct __sysctl_args args = { .name = mib, .nlen = 3, .oldval = (char *)buf + i, .oldlenp = &chunk, }; if (syscall(SYS__sysctl, &args) != 0) goto sysctlfailed; i += chunk; } if (gotdata(buf, len) == 0) { errno = save_errno; return (0); /* satisfied */ } sysctlfailed: errno = EIO; return -1; } #endif /* SYS__sysctl */ static int cl[] = { CLOCK_REALTIME, #ifdef CLOCK_MONOTONIC CLOCK_MONOTONIC, #endif #ifdef CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC_RAW, #endif #ifdef CLOCK_TAI CLOCK_TAI, #endif #ifdef CLOCK_VIRTUAL CLOCK_VIRTUAL, #endif #ifdef CLOCK_UPTIME CLOCK_UPTIME, #endif #ifdef CLOCK_PROCESS_CPUTIME_ID CLOCK_PROCESS_CPUTIME_ID, #endif #ifdef CLOCK_THREAD_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID, #endif }; static int getentropy_fallback(void *buf, size_t len) { uint8_t results[SHA512_DIGEST_LENGTH]; int save_errno = errno, e, pgs = getpagesize(), faster = 0, repeat; static int cnt; struct timespec ts; struct timeval tv; struct rusage ru; sigset_t sigset; struct stat st; SHA512_CTX ctx; static pid_t lastpid; pid_t pid; size_t i, ii, m; char *p; pid = getpid(); if (lastpid == pid) { faster = 1; repeat = 2; } else { faster = 0; lastpid = pid; repeat = REPEAT; } for (i = 0; i < len; ) { int j; SHA512_Init(&ctx); for (j = 0; j < repeat; j++) { HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) HX(clock_gettime(cl[ii], &ts) == -1, ts); HX((pid = getpid()) == -1, pid); HX((pid = getsid(pid)) == -1, pid); HX((pid = getppid()) == -1, pid); HX((pid = getpgid(0)) == -1, pid); HX((e = getpriority(0, 0)) == -1, e); if (!faster) { ts.tv_sec = 0; ts.tv_nsec = 1; (void) nanosleep(&ts, NULL); } HX(sigpending(&sigset) == -1, sigset); HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, sigset); #ifdef CAN_REFERENCE_MAIN HF(main); /* an addr in program */ #endif HF(getentropy); /* an addr in this library */ HF(printf); /* an addr in libc */ p = (char *)&p; HD(p); /* an addr on stack */ p = (char *)&errno; HD(p); /* the addr of errno */ if (i == 0) { struct sockaddr_storage ss; struct statvfs stvfs; struct termios tios; struct statfs stfs; socklen_t ssl; off_t off; /* * Prime-sized mappings encourage fragmentation; * thus exposing some address entropy. */ struct mm { size_t npg; void *p; } mm[] = { { 17, MAP_FAILED }, { 3, MAP_FAILED }, { 11, MAP_FAILED }, { 2, MAP_FAILED }, { 5, MAP_FAILED }, { 3, MAP_FAILED }, { 7, MAP_FAILED }, { 1, MAP_FAILED }, { 57, MAP_FAILED }, { 3, MAP_FAILED }, { 131, MAP_FAILED }, { 1, MAP_FAILED }, }; for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { HX(mm[m].p = mmap(NULL, mm[m].npg * pgs, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, (off_t)0), mm[m].p); if (mm[m].p != MAP_FAILED) { size_t mo; /* Touch some memory... */ p = mm[m].p; mo = cnt % (mm[m].npg * pgs - 1); p[mo] = 1; cnt += (int)((long)(mm[m].p) / pgs); } /* Check cnts and times... */ for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) { HX((e = clock_gettime(cl[ii], &ts)) == -1, ts); if (e != -1) cnt += (int)ts.tv_nsec; } HX((e = getrusage(RUSAGE_SELF, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { if (mm[m].p != MAP_FAILED) munmap(mm[m].p, mm[m].npg * pgs); mm[m].p = MAP_FAILED; } HX(stat(".", &st) == -1, st); HX(statvfs(".", &stvfs) == -1, stvfs); HX(statfs(".", &stfs) == -1, stfs); HX(stat("/", &st) == -1, st); HX(statvfs("/", &stvfs) == -1, stvfs); HX(statfs("/", &stfs) == -1, stfs); HX((e = fstat(0, &st)) == -1, st); if (e == -1) { if (S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { HX(fstatvfs(0, &stvfs) == -1, stvfs); HX(fstatfs(0, &stfs) == -1, stfs); HX((off = lseek(0, (off_t)0, SEEK_CUR)) < 0, off); } if (S_ISCHR(st.st_mode)) { HX(tcgetattr(0, &tios) == -1, tios); } else if (S_ISSOCK(st.st_mode)) { memset(&ss, 0, sizeof ss); ssl = sizeof(ss); HX(getpeername(0, (void *)&ss, &ssl) == -1, ss); } } HX((e = getrusage(RUSAGE_CHILDREN, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } else { /* Subsequent hashes absorb previous result */ HD(results); } HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } HD(cnt); } #ifdef HAVE_GETAUXVAL # ifdef AT_RANDOM /* Not as random as you think but we take what we are given */ p = (char *) getauxval(AT_RANDOM); if (p) HR(p, 16); # endif # ifdef AT_SYSINFO_EHDR p = (char *) getauxval(AT_SYSINFO_EHDR); if (p) HR(p, pgs); # endif # ifdef AT_BASE p = (char *) getauxval(AT_BASE); if (p) HD(p); # endif #endif /* HAVE_GETAUXVAL */ SHA512_Final(results, &ctx); memcpy((char*)buf + i, results, min(sizeof(results), len - i)); i += min(sizeof(results), len - i); } memset(results, 0, sizeof results); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } errno = EIO; return -1; } #endif getdns-0.9.0/src/compat/inet_pton.c0000664000175100017510000001222512641212403014143 00000000000000/* $KAME: inet_pton.c,v 1.5 2001/08/20 02:32:40 itojun Exp $ */ /* Copyright (c) 1996 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include #include #include #include /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ static int inet_pton4 (const char *src, uint8_t *dst); static int inet_pton6 (const char *src, uint8_t *dst); /* * * The definitions we might miss. * */ #ifndef NS_INT16SZ #define NS_INT16SZ 2 #endif #ifndef NS_IN6ADDRSZ #define NS_IN6ADDRSZ 16 #endif #ifndef NS_INADDRSZ #define NS_INADDRSZ 4 #endif /* int * inet_pton(af, src, dst) * convert from presentation format (which usually means ASCII printable) * to network format (which is usually some kind of binary format). * return: * 1 if the address was valid for the specified address family * 0 if the address wasn't valid (`dst' is untouched in this case) * -1 if some other error occurred (`dst' is untouched in this case, too) * author: * Paul Vixie, 1996. */ int inet_pton(af, src, dst) int af; const char *src; void *dst; { switch (af) { case AF_INET: return (inet_pton4(src, dst)); case AF_INET6: return (inet_pton6(src, dst)); default: #ifdef EAFNOSUPPORT errno = EAFNOSUPPORT; #else errno = ENOSYS; #endif return (-1); } /* NOTREACHED */ } /* int * inet_pton4(src, dst) * like inet_aton() but without all the hexadecimal and shorthand. * return: * 1 if `src' is a valid dotted quad, else 0. * notice: * does not touch `dst' unless it's returning 1. * author: * Paul Vixie, 1996. */ static int inet_pton4(src, dst) const char *src; uint8_t *dst; { static const char digits[] = "0123456789"; int saw_digit, octets, ch; uint8_t tmp[NS_INADDRSZ], *tp; saw_digit = 0; octets = 0; *(tp = tmp) = 0; while ((ch = *src++) != '\0') { const char *pch; if ((pch = strchr(digits, ch)) != NULL) { uint32_t new = *tp * 10 + (pch - digits); if (new > 255) return (0); *tp = new; if (! saw_digit) { if (++octets > 4) return (0); saw_digit = 1; } } else if (ch == '.' && saw_digit) { if (octets == 4) return (0); *++tp = 0; saw_digit = 0; } else return (0); } if (octets < 4) return (0); memcpy(dst, tmp, NS_INADDRSZ); return (1); } /* int * inet_pton6(src, dst) * convert presentation level address to network order binary form. * return: * 1 if `src' is a valid [RFC1884 2.2] address, else 0. * notice: * (1) does not touch `dst' unless it's returning 1. * (2) :: in a full address is silently ignored. * credit: * inspired by Mark Andrews. * author: * Paul Vixie, 1996. */ static int inet_pton6(src, dst) const char *src; uint8_t *dst; { static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; uint8_t tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; const char *xdigits, *curtok; int ch, saw_xdigit; uint32_t val; memset((tp = tmp), '\0', NS_IN6ADDRSZ); endp = tp + NS_IN6ADDRSZ; colonp = NULL; /* Leading :: requires some special handling. */ if (*src == ':') if (*++src != ':') return (0); curtok = src; saw_xdigit = 0; val = 0; while ((ch = *src++) != '\0') { const char *pch; if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) pch = strchr((xdigits = xdigits_u), ch); if (pch != NULL) { val <<= 4; val |= (pch - xdigits); if (val > 0xffff) return (0); saw_xdigit = 1; continue; } if (ch == ':') { curtok = src; if (!saw_xdigit) { if (colonp) return (0); colonp = tp; continue; } if (tp + NS_INT16SZ > endp) return (0); *tp++ = (uint8_t) (val >> 8) & 0xff; *tp++ = (uint8_t) val & 0xff; saw_xdigit = 0; val = 0; continue; } if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0) { tp += NS_INADDRSZ; saw_xdigit = 0; break; /* '\0' was seen by inet_pton4(). */ } return (0); } if (saw_xdigit) { if (tp + NS_INT16SZ > endp) return (0); *tp++ = (uint8_t) (val >> 8) & 0xff; *tp++ = (uint8_t) val & 0xff; } if (colonp != NULL) { /* * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. */ const int n = tp - colonp; int i; for (i = 1; i <= n; i++) { endp[- i] = colonp[n - i]; colonp[n - i] = 0; } tp = endp; } if (tp != endp) return (0); memcpy(dst, tmp, NS_IN6ADDRSZ); return (1); } getdns-0.9.0/src/compat/arc4random_uniform.c0000664000175100017510000000344212641212403015736 00000000000000/* $OpenBSD: arc4random_uniform.c,v 1.1 2014/07/12 13:24:54 deraadt Exp $ */ /* * Copyright (c) 2008, Damien Miller * * 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 #include /* * Calculate a uniformly distributed random number less than upper_bound * avoiding "modulo bias". * * Uniformity is achieved by generating new random numbers until the one * returned is outside the range [0, 2**32 % upper_bound). This * guarantees the selected random number will be inside * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound) * after reduction modulo upper_bound. */ uint32_t arc4random_uniform(uint32_t upper_bound) { uint32_t r, min; if (upper_bound < 2) return 0; /* 2**32 % x == (2**32 - x) % x */ min = -upper_bound % upper_bound; /* * This could theoretically loop forever but each retry has * p > 0.5 (worst case, usually far better) of selecting a * number inside the range we need, so it should rarely need * to re-roll. */ for (;;) { r = arc4random(); if (r >= min) break; } return r % upper_bound; } getdns-0.9.0/src/compat/explicit_bzero.c0000664000175100017510000000066112641212403015167 00000000000000/* $OpenBSD: explicit_bzero.c,v 1.3 2014/06/21 02:34:26 matthew Exp $ */ /* * Public domain. * Written by Matthew Dempsky. */ #include "config.h" #include __attribute__((weak)) void __explicit_bzero_hook(void *ATTR_UNUSED(buf), size_t ATTR_UNUSED(len)) { } void explicit_bzero(void *buf, size_t len) { #ifdef UB_ON_WINDOWS SecureZeroMemory(buf, len); #endif memset(buf, 0, len); __explicit_bzero_hook(buf, len); } getdns-0.9.0/src/compat/getentropy_win.c0000664000175100017510000000302712641212403015221 00000000000000/* $OpenBSD$ */ /* * Copyright (c) 2014, Theo de Raadt * Copyright (c) 2014, Bob Beck * * 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 #include #include #include #include #include int getentropy(void *buf, size_t len); /* * On Windows, CryptGenRandom is supposed to be a well-seeded * cryptographically strong random number generator. */ int getentropy(void *buf, size_t len) { HCRYPTPROV provider; if (len > 256) { errno = EIO; return -1; } if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) == 0) goto fail; if (CryptGenRandom(provider, len, buf) == 0) { CryptReleaseContext(provider, 0); goto fail; } CryptReleaseContext(provider, 0); return (0); fail: errno = EIO; return (-1); } getdns-0.9.0/src/compat/arc4random.c0000664000175100017510000001337412641212403014204 00000000000000/* $OpenBSD: arc4random.c,v 1.41 2014/07/12 13:24:54 deraadt Exp $ */ /* * Copyright (c) 1996, David Mazieres * Copyright (c) 2008, Damien Miller * Copyright (c) 2013, Markus Friedl * * 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" /* * ChaCha based random number generator for OpenBSD. */ #include #include #include #include #include #include #include #include #include #include #ifndef GETDNS_ON_WINDOWS #include #else #include #include int getentropy(void *buf, size_t len); /* * On Windows, CryptGenRandom is supposed to be a well-seeded * cryptographically strong random number generator. */ int getentropy(void *buf, size_t len) { HCRYPTPROV provider; if (len > 256) { errno = EIO; return -1; } if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) == 0) goto fail; if (CryptGenRandom(provider, len, buf) == 0) { CryptReleaseContext(provider, 0); goto fail; } CryptReleaseContext(provider, 0); return (0); fail: errno = EIO; return (-1); } #endif #define KEYSTREAM_ONLY #include "chacha_private.h" #define arc4_min(a, b) ((a) < (b) ? (a) : (b)) #ifdef __GNUC__ #define inline __inline #else /* !__GNUC__ */ #define inline #endif /* !__GNUC__ */ #define KEYSZ 32 #define IVSZ 8 #define BLOCKSZ 64 #define RSBUFSZ (16*BLOCKSZ) /* Marked MAP_INHERIT_ZERO, so zero'd out in fork children. */ static struct { size_t rs_have; /* valid bytes at end of rs_buf */ size_t rs_count; /* bytes till reseed */ } *rs; /* Preserved in fork children. */ static struct { chacha_ctx rs_chacha; /* chacha context for random keystream */ u_char rs_buf[RSBUFSZ]; /* keystream blocks */ } *rsx; static inline void _rs_rekey(u_char *dat, size_t datlen); static inline void _rs_init(u_char *buf, size_t n) { if (n < KEYSZ + IVSZ) return; if (rs == NULL) { #ifndef GETDNS_ON_WINDOWS if ((rs = mmap(NULL, sizeof(*rs), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) abort(); #ifdef MAP_INHERIT_ZERO if (minherit(rs, sizeof(*rs), MAP_INHERIT_ZERO) == -1) abort(); #endif #else /* WINDOWS */ rs = malloc(sizeof(*rs)); if(!rs) abort(); #endif } if (rsx == NULL) { #ifndef GETDNS_ON_WINDOWS if ((rsx = mmap(NULL, sizeof(*rsx), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) abort(); #else /* WINDOWS */ rsx = malloc(sizeof(*rsx)); if(!rsx) abort(); #endif } chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8, 0); chacha_ivsetup(&rsx->rs_chacha, buf + KEYSZ); } static void _rs_stir(void) { u_char rnd[KEYSZ + IVSZ]; if (getentropy(rnd, sizeof rnd) == -1) { #ifdef SIGKILL raise(SIGKILL); #else exit(9); /* windows */ #endif } if (!rs) _rs_init(rnd, sizeof(rnd)); else _rs_rekey(rnd, sizeof(rnd)); explicit_bzero(rnd, sizeof(rnd)); /* discard source seed */ /* invalidate rs_buf */ rs->rs_have = 0; memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf)); rs->rs_count = 1600000; } static inline void _rs_stir_if_needed(size_t len) { #ifndef MAP_INHERIT_ZERO static pid_t _rs_pid = 0; pid_t pid = getpid(); /* If a system lacks MAP_INHERIT_ZERO, resort to getpid() */ if (_rs_pid == 0 || _rs_pid != pid) { _rs_pid = pid; if (rs) rs->rs_count = 0; } #endif if (!rs || rs->rs_count <= len) _rs_stir(); if (rs->rs_count <= len) rs->rs_count = 0; else rs->rs_count -= len; } static inline void _rs_rekey(u_char *dat, size_t datlen) { #ifndef KEYSTREAM_ONLY memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf)); #endif /* fill rs_buf with the keystream */ chacha_encrypt_bytes(&rsx->rs_chacha, rsx->rs_buf, rsx->rs_buf, sizeof(rsx->rs_buf)); /* mix in optional user provided data */ if (dat) { size_t i, m; m = arc4_min(datlen, KEYSZ + IVSZ); for (i = 0; i < m; i++) rsx->rs_buf[i] ^= dat[i]; } /* immediately reinit for backtracking resistance */ _rs_init(rsx->rs_buf, KEYSZ + IVSZ); memset(rsx->rs_buf, 0, KEYSZ + IVSZ); rs->rs_have = sizeof(rsx->rs_buf) - KEYSZ - IVSZ; } static inline void _rs_random_buf(void *_buf, size_t n) { u_char *buf = (u_char *)_buf; u_char *keystream; size_t m; _rs_stir_if_needed(n); while (n > 0) { if (rs->rs_have > 0) { m = arc4_min(n, rs->rs_have); keystream = rsx->rs_buf + sizeof(rsx->rs_buf) - rs->rs_have; memcpy(buf, keystream, m); memset(keystream, 0, m); buf += m; n -= m; rs->rs_have -= m; } if (rs->rs_have == 0) _rs_rekey(NULL, 0); } } static inline void _rs_random_u32(uint32_t *val) { u_char *keystream; _rs_stir_if_needed(sizeof(*val)); if (rs->rs_have < sizeof(*val)) _rs_rekey(NULL, 0); keystream = rsx->rs_buf + sizeof(rsx->rs_buf) - rs->rs_have; memcpy(val, keystream, sizeof(*val)); memset(keystream, 0, sizeof(*val)); rs->rs_have -= sizeof(*val); } uint32_t arc4random(void) { uint32_t val; _ARC4_LOCK(); _rs_random_u32(&val); _ARC4_UNLOCK(); return val; } void arc4random_buf(void *buf, size_t n) { _ARC4_LOCK(); _rs_random_buf(buf, n); _ARC4_UNLOCK(); } getdns-0.9.0/src/compat/strlcpy.c0000664000175100017510000000320512641212403013642 00000000000000/* from openssh 4.3p2 compat/strlcpy.c */ /* * Copyright (c) 1998 Todd C. Miller * * 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. */ /* OPENBSD ORIGINAL: lib/libc/string/strlcpy.c */ #include #ifndef HAVE_STRLCPY #include #include /* * Copy src to string dst of size siz. At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. */ size_t strlcpy(char *dst, const char *src, size_t siz) { char *d = dst; const char *s = src; size_t n = siz; /* Copy as many bytes as will fit */ if (n != 0 && --n != 0) { do { if ((*d++ = *s++) == 0) break; } while (--n != 0); } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0) { if (siz != 0) *d = '\0'; /* NUL-terminate dst */ while (*s++) ; } return(s - src - 1); /* count does not include NUL */ } #endif /* !HAVE_STRLCPY */ getdns-0.9.0/src/compat/chacha_private.h0000664000175100017510000001243212641212403015112 00000000000000/* chacha-merged.c version 20080118 D. J. Bernstein Public domain. */ /* $OpenBSD: chacha_private.h,v 1.2 2013/10/04 07:02:27 djm Exp $ */ typedef unsigned char u8; typedef unsigned int u32; typedef struct { u32 input[16]; /* could be compressed */ } chacha_ctx; #define U8C(v) (v##U) #define U32C(v) (v##U) #define U8V(v) ((u8)(v) & U8C(0xFF)) #define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF)) #define ROTL32(v, n) \ (U32V((v) << (n)) | ((v) >> (32 - (n)))) #define U8TO32_LITTLE(p) \ (((u32)((p)[0]) ) | \ ((u32)((p)[1]) << 8) | \ ((u32)((p)[2]) << 16) | \ ((u32)((p)[3]) << 24)) #define U32TO8_LITTLE(p, v) \ do { \ (p)[0] = U8V((v) ); \ (p)[1] = U8V((v) >> 8); \ (p)[2] = U8V((v) >> 16); \ (p)[3] = U8V((v) >> 24); \ } while (0) #define ROTATE(v,c) (ROTL32(v,c)) #define XOR(v,w) ((v) ^ (w)) #define PLUS(v,w) (U32V((v) + (w))) #define PLUSONE(v) (PLUS((v),1)) #define QUARTERROUND(a,b,c,d) \ a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \ c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \ a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); static const char sigma[16] = "expand 32-byte k"; static const char tau[16] = "expand 16-byte k"; static void chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits,u32 ATTR_UNUSED(ivbits)) { const char *constants; x->input[4] = U8TO32_LITTLE(k + 0); x->input[5] = U8TO32_LITTLE(k + 4); x->input[6] = U8TO32_LITTLE(k + 8); x->input[7] = U8TO32_LITTLE(k + 12); if (kbits == 256) { /* recommended */ k += 16; constants = sigma; } else { /* kbits == 128 */ constants = tau; } x->input[8] = U8TO32_LITTLE(k + 0); x->input[9] = U8TO32_LITTLE(k + 4); x->input[10] = U8TO32_LITTLE(k + 8); x->input[11] = U8TO32_LITTLE(k + 12); x->input[0] = U8TO32_LITTLE(constants + 0); x->input[1] = U8TO32_LITTLE(constants + 4); x->input[2] = U8TO32_LITTLE(constants + 8); x->input[3] = U8TO32_LITTLE(constants + 12); } static void chacha_ivsetup(chacha_ctx *x,const u8 *iv) { x->input[12] = 0; x->input[13] = 0; x->input[14] = U8TO32_LITTLE(iv + 0); x->input[15] = U8TO32_LITTLE(iv + 4); } static void chacha_encrypt_bytes(chacha_ctx *x,const u8 *m,u8 *c,u32 bytes) { u32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15; u8 *ctarget = NULL; u8 tmp[64]; u_int i; if (!bytes) return; j0 = x->input[0]; j1 = x->input[1]; j2 = x->input[2]; j3 = x->input[3]; j4 = x->input[4]; j5 = x->input[5]; j6 = x->input[6]; j7 = x->input[7]; j8 = x->input[8]; j9 = x->input[9]; j10 = x->input[10]; j11 = x->input[11]; j12 = x->input[12]; j13 = x->input[13]; j14 = x->input[14]; j15 = x->input[15]; for (;;) { if (bytes < 64) { for (i = 0;i < bytes;++i) tmp[i] = m[i]; m = tmp; ctarget = c; c = tmp; } x0 = j0; x1 = j1; x2 = j2; x3 = j3; x4 = j4; x5 = j5; x6 = j6; x7 = j7; x8 = j8; x9 = j9; x10 = j10; x11 = j11; x12 = j12; x13 = j13; x14 = j14; x15 = j15; for (i = 20;i > 0;i -= 2) { QUARTERROUND( x0, x4, x8,x12) QUARTERROUND( x1, x5, x9,x13) QUARTERROUND( x2, x6,x10,x14) QUARTERROUND( x3, x7,x11,x15) QUARTERROUND( x0, x5,x10,x15) QUARTERROUND( x1, x6,x11,x12) QUARTERROUND( x2, x7, x8,x13) QUARTERROUND( x3, x4, x9,x14) } x0 = PLUS(x0,j0); x1 = PLUS(x1,j1); x2 = PLUS(x2,j2); x3 = PLUS(x3,j3); x4 = PLUS(x4,j4); x5 = PLUS(x5,j5); x6 = PLUS(x6,j6); x7 = PLUS(x7,j7); x8 = PLUS(x8,j8); x9 = PLUS(x9,j9); x10 = PLUS(x10,j10); x11 = PLUS(x11,j11); x12 = PLUS(x12,j12); x13 = PLUS(x13,j13); x14 = PLUS(x14,j14); x15 = PLUS(x15,j15); #ifndef KEYSTREAM_ONLY x0 = XOR(x0,U8TO32_LITTLE(m + 0)); x1 = XOR(x1,U8TO32_LITTLE(m + 4)); x2 = XOR(x2,U8TO32_LITTLE(m + 8)); x3 = XOR(x3,U8TO32_LITTLE(m + 12)); x4 = XOR(x4,U8TO32_LITTLE(m + 16)); x5 = XOR(x5,U8TO32_LITTLE(m + 20)); x6 = XOR(x6,U8TO32_LITTLE(m + 24)); x7 = XOR(x7,U8TO32_LITTLE(m + 28)); x8 = XOR(x8,U8TO32_LITTLE(m + 32)); x9 = XOR(x9,U8TO32_LITTLE(m + 36)); x10 = XOR(x10,U8TO32_LITTLE(m + 40)); x11 = XOR(x11,U8TO32_LITTLE(m + 44)); x12 = XOR(x12,U8TO32_LITTLE(m + 48)); x13 = XOR(x13,U8TO32_LITTLE(m + 52)); x14 = XOR(x14,U8TO32_LITTLE(m + 56)); x15 = XOR(x15,U8TO32_LITTLE(m + 60)); #endif j12 = PLUSONE(j12); if (!j12) { j13 = PLUSONE(j13); /* stopping at 2^70 bytes per nonce is user's responsibility */ } U32TO8_LITTLE(c + 0,x0); U32TO8_LITTLE(c + 4,x1); U32TO8_LITTLE(c + 8,x2); U32TO8_LITTLE(c + 12,x3); U32TO8_LITTLE(c + 16,x4); U32TO8_LITTLE(c + 20,x5); U32TO8_LITTLE(c + 24,x6); U32TO8_LITTLE(c + 28,x7); U32TO8_LITTLE(c + 32,x8); U32TO8_LITTLE(c + 36,x9); U32TO8_LITTLE(c + 40,x10); U32TO8_LITTLE(c + 44,x11); U32TO8_LITTLE(c + 48,x12); U32TO8_LITTLE(c + 52,x13); U32TO8_LITTLE(c + 56,x14); U32TO8_LITTLE(c + 60,x15); if (bytes <= 64) { if (bytes < 64) { for (i = 0;i < bytes;++i) ctarget[i] = c[i]; } x->input[12] = j12; x->input[13] = j13; return; } bytes -= 64; c += 64; #ifndef KEYSTREAM_ONLY m += 64; #endif } } getdns-0.9.0/src/compat/inet_ntop.c0000664000175100017510000001275312641212403014151 00000000000000/* From openssh 4.3p2 compat/inet_ntop.c */ /* Copyright (c) 1996 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* OPENBSD ORIGINAL: lib/libc/net/inet_ntop.c */ #include #ifndef HAVE_INET_NTOP #include #include #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #include #include #include #ifndef IN6ADDRSZ #define IN6ADDRSZ 16 /* IPv6 T_AAAA */ #endif #ifndef INT16SZ #define INT16SZ 2 /* for systems without 16-bit ints */ #endif /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ static const char *inet_ntop4(const u_char *src, char *dst, size_t size); static const char *inet_ntop6(const u_char *src, char *dst, size_t size); /* char * * inet_ntop(af, src, dst, size) * convert a network format address to presentation format. * return: * pointer to presentation format address (`dst'), or NULL (see errno). * author: * Paul Vixie, 1996. */ const char * inet_ntop(int af, const void *src, char *dst, size_t size) { switch (af) { case AF_INET: return (inet_ntop4(src, dst, size)); case AF_INET6: return (inet_ntop6(src, dst, size)); default: #ifdef EAFNOSUPPORT errno = EAFNOSUPPORT; #else errno = ENOSYS; #endif return (NULL); } /* NOTREACHED */ } /* const char * * inet_ntop4(src, dst, size) * format an IPv4 address, more or less like inet_ntoa() * return: * `dst' (as a const) * notes: * (1) uses no statics * (2) takes a u_char* not an in_addr as input * author: * Paul Vixie, 1996. */ static const char * inet_ntop4(const u_char *src, char *dst, size_t size) { static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; int l; l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]); if (l <= 0 || l >= (int)size) { errno = ENOSPC; return (NULL); } strlcpy(dst, tmp, size); return (dst); } /* const char * * inet_ntop6(src, dst, size) * convert IPv6 binary address into presentation (printable) format * author: * Paul Vixie, 1996. */ static const char * inet_ntop6(const u_char *src, char *dst, size_t size) { /* * Note that int32_t and int16_t need only be "at least" large enough * to contain a value of the specified size. On some systems, like * Crays, there is no such thing as an integer variable with 16 bits. * Keep this in mind if you think this function should have been coded * to use pointer overlays. All the world's not a VAX. */ char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"]; char *tp, *ep; struct { int base, len; } best, cur; u_int words[IN6ADDRSZ / INT16SZ]; int i; int advance; /* * Preprocess: * Copy the input (bytewise) array into a wordwise array. * Find the longest run of 0x00's in src[] for :: shorthanding. */ memset(words, '\0', sizeof words); for (i = 0; i < IN6ADDRSZ; i++) words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); best.base = -1; best.len = 0; cur.base = -1; cur.len = 0; for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) { if (words[i] == 0) { if (cur.base == -1) cur.base = i, cur.len = 1; else cur.len++; } else { if (cur.base != -1) { if (best.base == -1 || cur.len > best.len) best = cur; cur.base = -1; } } } if (cur.base != -1) { if (best.base == -1 || cur.len > best.len) best = cur; } if (best.base != -1 && best.len < 2) best.base = -1; /* * Format the result. */ tp = tmp; ep = tmp + sizeof(tmp); for (i = 0; i < (IN6ADDRSZ / INT16SZ) && tp < ep; i++) { /* Are we inside the best run of 0x00's? */ if (best.base != -1 && i >= best.base && i < (best.base + best.len)) { if (i == best.base) { if (tp + 1 >= ep) return (NULL); *tp++ = ':'; } continue; } /* Are we following an initial run of 0x00s or any real hex? */ if (i != 0) { if (tp + 1 >= ep) return (NULL); *tp++ = ':'; } /* Is this address an encapsulated IPv4? */ if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { if (!inet_ntop4(src+12, tp, (size_t)(ep - tp))) return (NULL); tp += strlen(tp); break; } advance = snprintf(tp, ep - tp, "%x", words[i]); if (advance <= 0 || advance >= ep - tp) return (NULL); tp += advance; } /* Was it a trailing run of 0x00's? */ if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) { if (tp + 1 >= ep) return (NULL); *tp++ = ':'; } if (tp + 1 >= ep) return (NULL); *tp++ = '\0'; /* * Check for overflow, copy, and we're done. */ if ((size_t)(tp - tmp) > size) { errno = ENOSPC; return (NULL); } strlcpy(dst, tmp, size); return (dst); } #endif /* !HAVE_INET_NTOP */ getdns-0.9.0/src/compat/arc4_lock.c0000664000175100017510000000331512641212403014005 00000000000000/* arc4_lock.c - global lock for arc4random * * Copyright (c) 2014, NLnet Labs. All rights reserved. * * This software is open source. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #define LOCKRET(func) func void _ARC4_LOCK(void) { } void _ARC4_UNLOCK(void) { } getdns-0.9.0/src/dict.c0000664000175100017510000010215412641212403011605 00000000000000/** * * getdns dict management functions, note that the internal storage is * accomplished via an _getdns_rbtree_t * * Interfaces originally taken from the getdns API description pseudo implementation. * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include "config.h" #ifndef USE_WINSOCK #include #include #include #include #endif #include "types-internal.h" #include "util-internal.h" #include "dict.h" #include "list.h" #include "rr-dict.h" #include "const-info.h" #include "gldns/gbuffer.h" #include "gldns/wire2str.h" static char *_json_ptr_first(const struct mem_funcs *mf, const char *jptr, char *first, size_t first_sz) { const char *next_ref, *k; char *j; if (*jptr != '/') return (char *)jptr; jptr++; if (!(next_ref = strchr(jptr, '/'))) next_ref = strchr(jptr, '\0'); if (next_ref - jptr > first_sz) first = GETDNS_XMALLOC(*mf, char, next_ref - jptr + 1); for (j = first, k = jptr; k < next_ref; j++, k++) *j = k[0] == '~' && k[1] == '1' ? (k++, '/') : *k; *j = '\0'; for (j = first, k = first; *k; j++, k++) *j = k[0] == '~' && k[1] == '0' ? (k++, '~') : *k; *j = '\0'; return first; } static struct getdns_dict_item * _find_dict_item(const getdns_dict *dict, const char *jptr) { char first_spc[1024], *first; struct getdns_dict_item *d; first = _json_ptr_first(&dict->mf, jptr, first_spc, sizeof(first_spc)); d = (struct getdns_dict_item *) _getdns_rbtree_search( (_getdns_rbtree_t *)&(dict->root), first); if (first && first != jptr && first != first_spc) GETDNS_FREE(dict->mf, first); return d; } static struct getdns_dict_item * _delete_dict_item(const getdns_dict *dict, const char *jptr) { char first_spc[1024], *first; struct getdns_dict_item *d; first = _json_ptr_first(&dict->mf, jptr, first_spc, sizeof(first_spc)); d = (struct getdns_dict_item *) _getdns_rbtree_delete( (_getdns_rbtree_t *)&(dict->root), first); if (first && first != jptr && first != first_spc) GETDNS_FREE(dict->mf, first); return d; } static char * _json_ptr_keydup(const struct mem_funcs *mf, const char *jptr) { char *first = _json_ptr_first(mf, jptr, NULL, 0); if (first == jptr || first == jptr + 1) { size_t sz = strlen(jptr) + 1; if ((first = GETDNS_XMALLOC(*mf, char, sz))) memcpy(first, jptr, sz); } return first; } getdns_return_t _getdns_dict_find(const getdns_dict *dict, const char *key, getdns_item **item) { const char *next; struct getdns_dict_item *d; if (!(d = _find_dict_item(dict, key))) return GETDNS_RETURN_NO_SUCH_DICT_NAME; if (*key != '/' || !(next = strchr(key + 1, '/'))) { *item = &d->i; return GETDNS_RETURN_GOOD; } else switch (d->i.dtype) { /* Key was nested reference */ case t_dict: return _getdns_dict_find(d->i.data.dict, next, item); case t_list: return _getdns_list_find(d->i.data.list, next, item); default : /* Trying to dereference a non list or dict */ return GETDNS_RETURN_WRONG_TYPE_REQUESTED; } } /*---------------------------------------- getdns_dict_item_free */ /** * private function used to release storage associated with a dictionary item * @param node all memory in this structure and its children will be freed * @param arg is a dict who's custom memory function will be used * to free the items * @return void */ static void getdns_dict_item_free(_getdns_rbnode_t *node, void *arg) { struct getdns_dict_item *d = (struct getdns_dict_item *)node; struct getdns_dict *dict = (struct getdns_dict *)arg; assert(node); assert(arg); switch (d->i.dtype) { case t_dict : getdns_dict_destroy(d->i.data.dict); break; case t_list : getdns_list_destroy(d->i.data.list); break; case t_bindata: _getdns_bindata_destroy(&dict->mf, d->i.data.bindata); default : break; } if (node->key) GETDNS_FREE(dict->mf, (void *)node->key); GETDNS_FREE(dict->mf, node); } /* getdns_dict_item_free */ getdns_return_t getdns_dict_remove_name(getdns_dict *dict, const char *name) { const char *next; struct getdns_dict_item *d; if (!dict || !name) return GETDNS_RETURN_INVALID_PARAMETER; if (!(d = _find_dict_item(dict, name))) return GETDNS_RETURN_NO_SUCH_DICT_NAME; if (*name != '/' || !(next = strchr(name + 1, '/'))) { d = _delete_dict_item(dict, name); getdns_dict_item_free(&d->node, dict); return GETDNS_RETURN_GOOD; } else switch (d->i.dtype) { case t_dict: return getdns_dict_remove_name(d->i.data.dict, next); case t_list: return _getdns_list_remove_name(d->i.data.list, next); default : /* Trying to dereference a non list or dict */ return GETDNS_RETURN_WRONG_TYPE_REQUESTED; } } getdns_return_t _getdns_dict_find_and_add( getdns_dict *dict, const char *key, getdns_item **item) { const char *next; struct getdns_dict_item *d; if (!(d = _find_dict_item(dict, key))) { /* add a node */ d = GETDNS_MALLOC(dict->mf, struct getdns_dict_item); d->node.key = _json_ptr_keydup(&dict->mf, key); _getdns_rbtree_insert(&(dict->root), (_getdns_rbnode_t *) d); if (*key != '/' || !(next = strchr(key + 1, '/'))) { (void) memset(&d->i.data, 0, sizeof(d->i.data)); d->i.dtype = t_int; d->i.data.n = 55555333; *item = &d->i; return GETDNS_RETURN_GOOD; } if ((next[1] == '0' || next[1] == '-') && (next[2] == '/' || next[2] == '\0')) { d->i.dtype = t_list; d->i.data.list =_getdns_list_create_with_mf(&dict->mf); return _getdns_list_find_and_add( d->i.data.list, next, item); } d->i.dtype = t_dict; d->i.data.dict = _getdns_dict_create_with_mf(&dict->mf); return _getdns_dict_find_and_add(d->i.data.dict, next, item); } if (*key != '/' || !(next = strchr(key + 1, '/'))) { switch (d->i.dtype) { case t_dict : getdns_dict_destroy(d->i.data.dict); break; case t_list : getdns_list_destroy(d->i.data.list); break; case t_bindata: _getdns_bindata_destroy( &dict->mf, d->i.data.bindata); break; default : break; } d->i.dtype = t_int; d->i.data.n = 33355555; *item = &d->i; return GETDNS_RETURN_GOOD; } else switch (d->i.dtype) { /* Key was nested reference */ case t_dict:return _getdns_dict_find_and_add(d->i.data.dict,next,item); case t_list:return _getdns_list_find_and_add(d->i.data.list,next,item); default :/* Trying to dereference a non list or dict */ return GETDNS_RETURN_WRONG_TYPE_REQUESTED; } } /* getdns_dict_find_and_add */ /*---------------------------------------- getdns_dict_get_names */ getdns_return_t getdns_dict_get_names(const getdns_dict *dict, getdns_list **answer) { struct getdns_dict_item *item; if (!dict || !answer) return GETDNS_RETURN_INVALID_PARAMETER; *answer = getdns_list_create_with_extended_memory_functions( dict->mf.mf_arg, dict->mf.mf.ext.malloc, dict->mf.mf.ext.realloc, dict->mf.mf.ext.free); if (!*answer) return GETDNS_RETURN_NO_SUCH_DICT_NAME; RBTREE_FOR(item, struct getdns_dict_item *, (_getdns_rbtree_t *)&(dict->root)) { _getdns_list_append_const_bindata(*answer, strlen(item->node.key) + 1, item->node.key); } return GETDNS_RETURN_GOOD; } /* getdns_dict_get_names */ /*---------------------------------------- getdns_dict_get_data_type */ getdns_return_t getdns_dict_get_data_type( const getdns_dict *dict, const char *name, getdns_data_type *answer) { getdns_return_t r; getdns_item *item; if (!dict || !name || !answer) return GETDNS_RETURN_INVALID_PARAMETER; if ((r = _getdns_dict_find(dict, name, &item))) return r; *answer = item->dtype; return GETDNS_RETURN_GOOD; } /* getdns_dict_get_data_type */ /*---------------------------------------- getdns_dict_get_dict */ getdns_return_t getdns_dict_get_dict( const getdns_dict *dict, const char *name, getdns_dict **answer) { getdns_return_t r; getdns_item *item; if (!dict || !name || !answer) return GETDNS_RETURN_INVALID_PARAMETER; if ((r = _getdns_dict_find(dict, name, &item))) return r; if (item->dtype != t_dict) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = item->data.dict; return GETDNS_RETURN_GOOD; } /* getdns_dict_get_dict */ /*---------------------------------------- getdns_dict_get_list */ getdns_return_t getdns_dict_get_list( const getdns_dict *dict, const char *name, getdns_list **answer) { getdns_return_t r; getdns_item *item; if (!dict || !name || !answer) return GETDNS_RETURN_INVALID_PARAMETER; if ((r = _getdns_dict_find(dict, name, &item))) return r; if (item->dtype != t_list) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = item->data.list; return GETDNS_RETURN_GOOD; } /* getdns_dict_get_list */ /*---------------------------------------- getdns_dict_get_bindata */ getdns_return_t getdns_dict_get_bindata( const getdns_dict *dict, const char *name, getdns_bindata **answer) { getdns_return_t r; getdns_item *item; if (!dict || !name || !answer) return GETDNS_RETURN_INVALID_PARAMETER; if ((r = _getdns_dict_find(dict, name, &item))) return GETDNS_RETURN_NO_SUCH_DICT_NAME; if (item->dtype != t_bindata) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = item->data.bindata; return GETDNS_RETURN_GOOD; } /* getdns_dict_get_bindata */ /*---------------------------------------- getdns_dict_get_int */ getdns_return_t getdns_dict_get_int( const getdns_dict *dict, const char *name, uint32_t *answer) { getdns_return_t r; getdns_item *item; if (!dict || !name || !answer) return GETDNS_RETURN_INVALID_PARAMETER; if ((r = _getdns_dict_find(dict, name, &item))) return r; if (item->dtype != t_int) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = item->data.n; return GETDNS_RETURN_GOOD; } /* getdns_dict_get_int */ struct getdns_dict * getdns_dict_create_with_extended_memory_functions( void *userarg, void *(*malloc)(void *userarg, size_t), void *(*realloc)(void *userarg, void *, size_t), void (*free)(void *userarg, void *)) { struct getdns_dict *dict; mf_union mf; if (!malloc || !realloc || !free) return NULL; mf.ext.malloc = malloc; dict = userarg == MF_PLAIN ? (struct getdns_dict*)(*mf.pln.malloc)( sizeof(struct getdns_dict)) : (struct getdns_dict*)(*mf.ext.malloc)(userarg, sizeof(struct getdns_dict)); if (!dict) return NULL; dict->mf.mf_arg = userarg; dict->mf.mf.ext.malloc = malloc; dict->mf.mf.ext.realloc = realloc; dict->mf.mf.ext.free = free; _getdns_rbtree_init(&(dict->root), (int (*)(const void *, const void *)) strcmp); return dict; } struct getdns_dict * getdns_dict_create_with_memory_functions(void *(*malloc)(size_t), void *(*realloc)(void *, size_t), void (*free)(void *)) { mf_union mf; mf.pln.malloc = malloc; mf.pln.realloc = realloc; mf.pln.free = free; return getdns_dict_create_with_extended_memory_functions( MF_PLAIN, mf.ext.malloc, mf.ext.realloc, mf.ext.free); } /*-------------------------- getdns_dict_create_with_context */ struct getdns_dict * getdns_dict_create_with_context(struct getdns_context *context) { if (context) return getdns_dict_create_with_extended_memory_functions( context->mf.mf_arg, context->mf.mf.ext.malloc, context->mf.mf.ext.realloc, context->mf.mf.ext.free); else return getdns_dict_create_with_memory_functions(&malloc, &realloc, &free); } /* getdns_dict_create_with_context */ /*---------------------------------------- getdns_dict_create */ struct getdns_dict * getdns_dict_create() { return getdns_dict_create_with_context(NULL); } /* getdns_dict_create */ /*---------------------------------------- _getdns_dict_copy */ /** * private function used to make a copy of a dict structure, * the caller is responsible * for freeing storage allocated to returned value * @param srcdict the dictionary structure to copy * @param dstdict the copy destination * @return the address of the copy of the dictionary structure on success * @return NULL on error (out of memory, invalid srcdict) */ getdns_return_t _getdns_dict_copy(const struct getdns_dict * srcdict, struct getdns_dict ** dstdict) { struct getdns_dict_item *item; char *key; getdns_return_t retval; if (!dstdict) return GETDNS_RETURN_INVALID_PARAMETER; if (!srcdict) { *dstdict = NULL; return GETDNS_RETURN_GOOD; } *dstdict = getdns_dict_create_with_extended_memory_functions( srcdict->mf.mf_arg, srcdict->mf.mf.ext.malloc, srcdict->mf.mf.ext.realloc, srcdict->mf.mf.ext.free); if (!*dstdict) return GETDNS_RETURN_GENERIC_ERROR; retval = GETDNS_RETURN_GOOD; RBTREE_FOR(item, struct getdns_dict_item *, (struct _getdns_rbtree_t *)&(srcdict->root)) { key = (char *) item->node.key; switch (item->i.dtype) { case t_bindata: retval = getdns_dict_set_bindata(*dstdict, key, item->i.data.bindata); break; case t_dict: retval = getdns_dict_set_dict(*dstdict, key, item->i.data.dict); break; case t_int: retval = getdns_dict_set_int(*dstdict, key, item->i.data.n); break; case t_list: retval = getdns_dict_set_list(*dstdict, key, item->i.data.list); break; } if (retval != GETDNS_RETURN_GOOD) { getdns_dict_destroy(*dstdict);; *dstdict = NULL; return retval; } } return GETDNS_RETURN_GOOD; } /* _getdns_dict_copy */ /*---------------------------------------- getdns_dict_destroy */ void getdns_dict_destroy(struct getdns_dict *dict) { if (!dict) return; _getdns_traverse_postorder(&(dict->root), getdns_dict_item_free, dict); GETDNS_FREE(dict->mf, dict); } /* getdns_dict_destroy */ /*---------------------------------------- getdns_dict_set_dict */ getdns_return_t getdns_dict_set_dict( getdns_dict *dict, const char *name, const getdns_dict *child_dict) { getdns_item *item; getdns_dict *newdict; getdns_return_t r; if (!dict || !name || !child_dict) return GETDNS_RETURN_INVALID_PARAMETER; if ((r = _getdns_dict_copy(child_dict, &newdict))) return r; if ((r = _getdns_dict_find_and_add(dict, name, &item))) { getdns_dict_destroy(newdict); return r; } item->dtype = t_dict; item->data.dict = newdict; return GETDNS_RETURN_GOOD; } /* getdns_dict_set_dict */ /*---------------------------------------- getdns_dict_set_list */ getdns_return_t getdns_dict_set_list( getdns_dict *dict, const char *name, const getdns_list *child_list) { getdns_item *item; getdns_list *newlist; getdns_return_t r; if (!dict || !name || !child_list) return GETDNS_RETURN_INVALID_PARAMETER; if ((r = _getdns_list_copy(child_list, &newlist))) return r; if ((r = _getdns_dict_find_and_add(dict, name, &item))) { getdns_list_destroy(newlist); return r; } item->dtype = t_list; item->data.list = newlist; return GETDNS_RETURN_GOOD; } /* getdns_dict_set_list */ /*---------------------------------------- getdns_dict_set_bindata */ getdns_return_t _getdns_dict_set_const_bindata( getdns_dict *dict, const char *name, size_t size, const void *data) { getdns_item *item; getdns_bindata *newbindata; getdns_return_t r; if (!dict || !name) return GETDNS_RETURN_INVALID_PARAMETER; if (!(newbindata = _getdns_bindata_copy(&dict->mf, size, data))) return GETDNS_RETURN_MEMORY_ERROR; if ((r = _getdns_dict_find_and_add(dict, name, &item))) { _getdns_bindata_destroy(&dict->mf, newbindata); return r; } item->dtype = t_bindata; item->data.bindata = newbindata; return GETDNS_RETURN_GOOD; } /* getdns_dict_set_bindata */ getdns_return_t getdns_dict_set_bindata( getdns_dict *dict, const char *name, const getdns_bindata *child_bindata) { return !child_bindata ? GETDNS_RETURN_INVALID_PARAMETER : _getdns_dict_set_const_bindata( dict, name, child_bindata->size, child_bindata->data); } /*---------------------------------------- getdns_dict_set_bindata */ getdns_return_t getdns_dict_util_set_string(getdns_dict *dict, char *name, const char *value) { return value ? _getdns_dict_set_const_bindata(dict, name, strlen(value), value) : GETDNS_RETURN_INVALID_PARAMETER; } /* getdns_dict_util_set_dict */ /*---------------------------------------- getdns_dict_set_int */ getdns_return_t getdns_dict_set_int(getdns_dict *dict, const char *name, uint32_t child_uint32) { getdns_item *item; getdns_return_t r; if (!dict || !name) return GETDNS_RETURN_INVALID_PARAMETER; if ((r = _getdns_dict_find_and_add(dict, name, &item))) return r; item->dtype = t_int; item->data.n = child_uint32; return GETDNS_RETURN_GOOD; } /* getdns_dict_set_int */ /*---------------------------------------- getdns_pp_dict */ /** * private function to help with indenting. * @param indent number of spaces to return * @return a character string containing min(80, indent) spaces */ static const char * getdns_indent(size_t indent) { static const char *spaces = " " " "; return spaces + 80 - (indent < 80 ? indent : 0); } /* getdns_indent */ int _getdns_bindata_is_dname(getdns_bindata *bindata) { size_t i = 0, n_labels = 0; while (i < bindata->size && bindata->data[i]) { if (bindata->data[i] & 0xC0) /* Compression pointer! */ return 0; i += ((size_t)bindata->data[i]) + 1; n_labels++; } if (i < bindata->size && !bindata->data[i]) { n_labels++; i++; } return i == bindata->size && n_labels > 1 && bindata->data[bindata->size - 1] == 0; } /*---------------------------------------- getdns_pp_bindata */ /** * private function to pretty print bindata to a gldns_buffer * @param buf buffer to write to * @param indent number of spaces to append after newline * @param bindata the bindata to print * @return on success the number of written characters * if an output error is encountered, a negative value */ static int getdns_pp_bindata(gldns_buffer *buf, size_t indent, getdns_bindata *bindata, int rdata_raw, int json) { size_t i, p = gldns_buffer_position(buf); uint8_t *dptr; char spc[1024]; if (!json && gldns_buffer_printf(buf, " size && isprint(bindata->data[i])) i++; if (bindata->size > 0 && i == bindata->size) { /* all printable? */ if (json) (void)snprintf(spc, sizeof(spc), "\"%%.%ds\"", (int)i); else (void)snprintf(spc, sizeof(spc), "of \"%%.%ds\"%s>", (int)(i > 32 ? 32 : i), (i > 32 ? "..." : "")); if (gldns_buffer_printf(buf, spc, bindata->data) < 0) return -1; } else if (bindata->size > 1 && /* null terminated printable */ i == bindata->size - 1 && bindata->data[i] == 0) { if (gldns_buffer_printf( buf, (json ? "\"%s\"" : "of \"%s\">"), bindata->data) < 0) return -1; } else if (bindata->size == 1 && *bindata->data == 0) { if (gldns_buffer_printf(buf, json ? "\".\"" : "for .>") < 0) return -1; } else if (_getdns_bindata_is_dname(bindata)) { (void)gldns_wire2str_dname_buf( bindata->data, bindata->size, spc, sizeof(spc)); if (gldns_buffer_printf( buf, (json ? "\"%s\"" : "of \"%s\">"), spc) < 0) return -1; } else if (json) { if (gldns_buffer_printf(buf, "[") < 0) return -1; for (dptr = bindata->data; dptr < bindata->data + bindata->size; dptr++) { if (dptr > bindata->data) { if (gldns_buffer_printf(buf, ",") < 0) return -1; } if (gldns_buffer_printf(buf, "%d", (int)*dptr) < 0) return -1; } if (gldns_buffer_printf(buf, "]") < 0) return -1; } else { if (gldns_buffer_printf(buf, "of 0x") < 0) return -1; for (dptr = bindata->data; dptr < bindata->data + bindata->size; dptr++) { if (dptr - bindata->data >= 16) { if (gldns_buffer_printf(buf, "...") < 0) return -1; break; } if (gldns_buffer_printf(buf, "%.2x", *dptr) < 0) return -1; } if (gldns_buffer_printf(buf, ">") < 0) return -1; } return gldns_buffer_position(buf) - p; } /* getdns_pp_bindata */ static int getdns_pp_dict(gldns_buffer * buf, size_t indent, const getdns_dict *dict, int json); static const char *unknown_str_l[] = {" ", " null", "null"}; /*---------------------------------------- getdns_pp_list */ /** * private function to pretty print list to a gldns_buffer * @param buf buffer to write to * @param indent number of spaces to append after newline * @param list the to list print * @param for_literals The list is a list of literals. * Show the literal instead of the value. * @return on success the number of written characters * if an output error is encountered, a negative value */ static int getdns_pp_list(gldns_buffer *buf, size_t indent, const getdns_list *list, int for_literals, int json) { size_t i, length, p = gldns_buffer_position(buf); getdns_data_type dtype; struct getdns_dict *dict_item; struct getdns_list *list_item; struct getdns_bindata *bindata_item; uint32_t int_item; const char *strval; if (list == NULL) return 0; if (gldns_buffer_printf(buf, "[") < 0) return -1; if (getdns_list_get_length(list, &length) != GETDNS_RETURN_GOOD) return -1; indent += 2; for (i = 0; i < length; i++) { if (i && gldns_buffer_printf(buf, ",") < 0) return -1; if (json < 2 && gldns_buffer_printf(buf, "\n%s", getdns_indent(indent)) < 0) return -1; if (getdns_list_get_data_type(list, i, &dtype) != GETDNS_RETURN_GOOD) return -1; switch (dtype) { case t_int: if (getdns_list_get_int(list, i, &int_item)) return -1; if (!json && for_literals && (strval = _getdns_get_const_info(int_item)->name)) { if (gldns_buffer_printf(buf, "%s", strval) < 0) return -1; } else if (0 > gldns_buffer_printf(buf, "%d", (int)int_item)) return -1; break; case t_bindata: if (getdns_list_get_bindata(list, i, &bindata_item) != GETDNS_RETURN_GOOD) return -1; if (getdns_pp_bindata( buf, indent, bindata_item, 0, json) < 0) return -1; break; case t_list: if (getdns_list_get_list(list, i, &list_item) != GETDNS_RETURN_GOOD) return -1; if (getdns_pp_list( buf, indent, list_item, 0, json) < 0) return -1; break; case t_dict: if (getdns_list_get_dict(list, i, &dict_item) != GETDNS_RETURN_GOOD) return -1; if (getdns_pp_dict(buf, indent, dict_item, json) < 0) return -1; break; default: if (gldns_buffer_printf( buf, "%s", unknown_str_l[json]) < 0) return -1; } } indent -= 2; if (json < 2 && i && gldns_buffer_printf( buf, "\n%s", getdns_indent(indent)) < 0) return -1; if (gldns_buffer_printf(buf, "]") < 0) return -1; return gldns_buffer_position(buf) - p; } /* getdns_pp_list */ static int _getdns_print_class(gldns_buffer *buf, uint32_t klass) { switch (klass) { case GETDNS_RRCLASS_IN: (void) gldns_buffer_printf(buf, " GETDNS_RRCLASS_IN"); return 1; case GETDNS_RRCLASS_CH: (void) gldns_buffer_printf(buf, " GETDNS_RRCLASS_CH"); return 1; case GETDNS_RRCLASS_HS: (void) gldns_buffer_printf(buf, " GETDNS_RRCLASS_HS"); return 1; case GETDNS_RRCLASS_NONE: (void) gldns_buffer_printf(buf, " GETDNS_RRCLASS_NONE"); return 1; case GETDNS_RRCLASS_ANY: (void) gldns_buffer_printf(buf, " GETDNS_RRCLASS_ANY"); return 1; } return 0; } static int _getdns_print_opcode(gldns_buffer *buf, uint32_t opcode) { switch (opcode) { case GETDNS_OPCODE_QUERY: (void) gldns_buffer_printf(buf, " GETDNS_OPCODE_QUERY"); return 1; case GETDNS_OPCODE_IQUERY: (void) gldns_buffer_printf(buf, " GETDNS_OPCODE_IQUERY"); return 1; case GETDNS_OPCODE_STATUS: (void) gldns_buffer_printf(buf, " GETDNS_OPCODE_STATUS"); return 1; case GETDNS_OPCODE_NOTIFY: (void) gldns_buffer_printf(buf, " GETDNS_OPCODE_NOTIFY"); return 1; case GETDNS_OPCODE_UPDATE: (void) gldns_buffer_printf(buf, " GETDNS_OPCODE_UPDATE"); return 1; } return 0; } static int _getdns_print_rcode(gldns_buffer *buf, uint32_t rcode) { static const char *rcodes[] = { " GETDNS_RCODE_NOERROR" , " GETDNS_RCODE_FORMERR" , " GETDNS_RCODE_SERVFAIL", " GETDNS_RCODE_NXDOMAIN", " GETDNS_RCODE_NOTIMP" , " GETDNS_RCODE_REFUSED" , " GETDNS_RCODE_YXDOMAIN", " GETDNS_RCODE_YXRRSET" , " GETDNS_RCODE_NXRRSET" , " GETDNS_RCODE_NOTAUTH" , " GETDNS_RCODE_NOTZONE" , " GETDNS_RCODE_BADSIG" , " GETDNS_RCODE_BADKEY" , " GETDNS_RCODE_BADTIME" , " GETDNS_RCODE_BADMODE" , " GETDNS_RCODE_BADNAME" , " GETDNS_RCODE_BADALG" , " GETDNS_RCODE_BADTRUNC" }; if (rcode <= 10) (void) gldns_buffer_printf(buf, "%s", rcodes[rcode]); else if (rcode >= 16 && rcode <= 22) (void) gldns_buffer_printf(buf, "%s", rcodes[rcode-6]); else return 0; return 1; } /*---------------------------------------- getdns_pp_dict */ /** * private function to pretty print dict to a gldns_buffer * @param buf buffer to write to * @param indent number of spaces to append after newline * @param dict the dict to print * @return on success the number of written characters * if an output error is encountered, a negative value */ static int getdns_pp_dict(gldns_buffer * buf, size_t indent, const getdns_dict *dict, int json) { size_t i, length, p = gldns_buffer_position(buf); struct getdns_dict_item *item; const char *strval; char abuf[80]; if (dict == NULL) return 0; if (gldns_buffer_printf(buf, "{") < 0) return -1; i = 0; indent += 2; RBTREE_FOR(item, struct getdns_dict_item *, (_getdns_rbtree_t *)&(dict->root)) { if (i && gldns_buffer_printf(buf, ",") < 0) return -1; if (json < 2 && gldns_buffer_printf( buf, "\n%s", getdns_indent(indent)) < 0) return -1; if (gldns_buffer_printf( buf, "\"%s\":",(const char *)item->node.key) < 0) return -1; switch (item->i.dtype) { case t_int: if (!json && (strcmp(item->node.key, "type") == 0 || strcmp(item->node.key, "type_covered") == 0 || strcmp(item->node.key, "query_type") == 0 || strcmp(item->node.key, "qtype") == 0) && (strval = _getdns_rr_type_name(item->i.data.n))) { if (gldns_buffer_printf( buf, " GETDNS_RRTYPE_%s", strval) < 0) return -1; break; } if (!json && (strcmp(item->node.key, "answer_type") == 0 || strcmp(item->node.key, "dnssec_status") == 0 || strcmp(item->node.key, "tsig_status") == 0 || strcmp(item->node.key, "status") == 0 || strcmp(item->node.key, "append_name") == 0 || strcmp(item->node.key, "follow_redirects") == 0 || strcmp(item->node.key, "transport") == 0 || strcmp(item->node.key, "resolution_type") == 0 || strcmp(item->node.key, "tls_authentication") == 0 ) && (strval = _getdns_get_const_info(item->i.data.n)->name)) { if (gldns_buffer_printf(buf, " %s", strval) < 0) return -1; break; } if (!json && (strcmp(item->node.key, "class") == 0 || strcmp(item->node.key, "qclass") == 0) && _getdns_print_class(buf, item->i.data.n)) break; if (!json && strcmp(item->node.key, "opcode") == 0 && _getdns_print_opcode(buf, item->i.data.n)) break; if (!json && strcmp(item->node.key, "rcode") == 0 && _getdns_print_rcode(buf, item->i.data.n)) break; if (gldns_buffer_printf( buf,(json < 2 ? " %d" : "%d"), item->i.data.n) < 0) return -1; break; case t_bindata: if ((strcmp(item->node.key, "address_data") == 0 || strcmp(item->node.key, "ipv4_address") == 0 || strcmp(item->node.key, "ipv6_address") == 0 ) && (item->i.data.bindata->size == 4 || item->i.data.bindata->size == 16 )) { if (gldns_buffer_printf(buf, (json ? "\"%s\"" : " "), inet_ntop(( item->i.data.bindata->size == 4 ? AF_INET : AF_INET6) , item->i.data.bindata->data , abuf , 40 )) < 0) return -1; } else if (getdns_pp_bindata( buf, indent, item->i.data.bindata, (strcmp(item->node.key, "rdata_raw") == 0), json) < 0) return -1; break; case t_list: /* Don't put empty lists on a new line */ if (getdns_list_get_length(item->i.data.list, &length) != GETDNS_RETURN_GOOD) return -1; if (length == 0) { if (gldns_buffer_printf( buf, (json < 2 ? " []" : "[]")) < 0) return -1; break; } if (json < 2 && gldns_buffer_printf(buf, "\n%s", getdns_indent(indent)) < 0) return -1; if (getdns_pp_list(buf, indent, item->i.data.list, (strcmp(item->node.key, "namespaces") == 0 || strcmp(item->node.key, "dns_transport_list") == 0 || strcmp(item->node.key, "bad_dns") == 0), json) < 0) return -1; break; case t_dict: if (json < 2 && gldns_buffer_printf(buf, "\n%s", getdns_indent(indent)) < 0) return -1; if (getdns_pp_dict( buf, indent, item->i.data.dict, json) < 0) return -1; break; default: if (gldns_buffer_printf( buf, "%s", unknown_str_l[json]) < 0) return -1; } i++; } indent -= 2; if (json < 2 && i && gldns_buffer_printf( buf, "\n%s", getdns_indent(indent)) < 0) return -1; if (gldns_buffer_printf(buf, "}") < 0) return -1; return gldns_buffer_position(buf) - p; } /* getdns_pp_dict */ /*---------------------------------------- getdns_pretty_print_dict */ /** * Return a character string containing a "human readable" representation * of dict. * @param dict the dict to pretty print * @return the "human readable" representation of dict * or NULL on error */ char * getdns_pretty_print_dict(const struct getdns_dict *dict) { gldns_buffer *buf; char *ret; if (!dict) return NULL; buf = gldns_buffer_new(8192); if (!buf) return NULL; if (getdns_pp_dict(buf, 0, dict, 0) < 0) { gldns_buffer_free(buf); return NULL; } ret = (char *) gldns_buffer_export(buf); gldns_buffer_free(buf); return ret; } /* getdns_pretty_print_dict */ int getdns_pretty_snprint_dict(char *str, size_t size, const getdns_dict *dict) { gldns_buffer buf; if (!dict) return -1; gldns_buffer_init_frm_data(&buf, str, size); return getdns_pp_dict(&buf, 0, dict, 0) < 0 ? -1 : gldns_buffer_position(&buf); } char * getdns_pretty_print_list(const getdns_list *list) { gldns_buffer *buf; char *ret; if (!list) return NULL; buf = gldns_buffer_new(4096); if (!buf) return NULL; if (getdns_pp_list(buf, 0, list, 0, 0) < 0) { gldns_buffer_free(buf); return NULL; } ret = (char *) gldns_buffer_export(buf); gldns_buffer_free(buf); return ret; } int getdns_pretty_snprint_list(char *str, size_t size, const getdns_list *list) { gldns_buffer buf; if (!list) return -1; gldns_buffer_init_frm_data(&buf, str, size); return getdns_pp_list(&buf, 0, list, 0, 0) < 0 ? -1 : gldns_buffer_position(&buf); } char * getdns_print_json_dict(const getdns_dict *dict, int pretty) { gldns_buffer *buf; char *ret; if (!dict) return NULL; buf = gldns_buffer_new(8192); if (!buf) return NULL; if (getdns_pp_dict(buf, 0, dict, pretty ? 1 : 2) < 0) { gldns_buffer_free(buf); return NULL; } ret = (char *) gldns_buffer_export(buf); gldns_buffer_free(buf); return ret; } /* getdns_print_json_dict */ int getdns_snprint_json_dict( char *str, size_t size, const getdns_dict *dict, int pretty) { gldns_buffer buf; if (!dict) return -1; gldns_buffer_init_frm_data(&buf, str, size); return getdns_pp_dict(&buf, 0, dict, pretty ? 1 : 2) < 0 ? -1 : gldns_buffer_position(&buf); } char * getdns_print_json_list(const getdns_list *list, int pretty) { gldns_buffer *buf; char *ret; if (!list) return NULL; buf = gldns_buffer_new(4096); if (!buf) return NULL; if (getdns_pp_list(buf, 0, list, 0, pretty ? 1 : 2) < 0) { gldns_buffer_free(buf); return NULL; } ret = (char *) gldns_buffer_export(buf); gldns_buffer_free(buf); return ret; } int getdns_snprint_json_list( char *str, size_t size, const getdns_list *list, int pretty) { gldns_buffer buf; if (!list) return -1; 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); } /* dict.c */ getdns-0.9.0/src/list.h0000664000175100017510000000555012641212403011644 00000000000000/** * * \file list.h * @brief getdns list management functions * * Originally taken from the getdns API description pseudo implementation. * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _GETDNS_LIST_H_ #define _GETDNS_LIST_H_ #include "getdns/getdns.h" #include "types-internal.h" #define GETDNS_LIST_BLOCKSZ 10 /** * getdns list data type * Use helper functions getdns_list_* to manipulate and iterate lists * lists are implemented as arrays internally since the helper functions * like to reference indexes in the list. Elements are allocated in blocks * and then marked valid as they are used and invalid as they are not used * The use cases do not justify working too hard at shrinking the structures. * Indexes are 0 based. */ struct getdns_list { size_t numalloc; size_t numinuse; struct getdns_item *items; struct mem_funcs mf; }; inline static getdns_list *_getdns_list_create_with_mf(struct mem_funcs *mf) { return getdns_list_create_with_extended_memory_functions( mf->mf_arg, mf->mf.ext.malloc, mf->mf.ext.realloc, mf->mf.ext.free); } getdns_return_t _getdns_list_find( const getdns_list *dict, const char *key, getdns_item **item); getdns_return_t _getdns_list_find_and_add( getdns_list *list, const char *key, getdns_item **item); getdns_return_t _getdns_list_remove_name( getdns_list *list, const char *name); #endif /* list.h */ getdns-0.9.0/src/Makefile.in0000664000175100017510000004657012641212403012574 00000000000000# # @configure_input@ # # Copyright (c) 2013, Verisign, Inc., NLnet Labs # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the names of the copyright holders nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package = @PACKAGE_NAME@ version = @PACKAGE_VERSION@ tarname = @PACKAGE_TARNAME@ distdir = $(tarname)-$(version) libversion = @GETDNS_LIBVERSION@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ libdir = @libdir@ includedir = @includedir@ have_libevent = @have_libevent@ have_libuv = @have_libuv@ have_libev = @have_libev@ # datarootdir is here to please some checkers datarootdir=@datarootdir@ INSTALL = @INSTALL@ srcdir = @srcdir@ LIBTOOL = ../libtool CC=@CC@ CFLAGS=-I$(srcdir) -I. @CFLAGS@ @CPPFLAGS@ LDFLAGS=@LDFLAGS@ @LIBS@ EXTENSION_LIBEVENT_LIB=@EXTENSION_LIBEVENT_LIB@ EXTENSION_LIBEVENT_EXT_LIBS=@EXTENSION_LIBEVENT_EXT_LIBS@ EXTENSION_LIBEVENT_LDFLAGS=@EXTENSION_LIBEVENT_LDFLAGS@ EXTENSION_LIBEV_LIB=@EXTENSION_LIBEV_LIB@ EXTENSION_LIBEV_EXT_LIBS=@EXTENSION_LIBEV_EXT_LIBS@ EXTENSION_LIBEV_LDFLAGS=@EXTENSION_LIBEV_LDFLAGS@ EXTENSION_LIBUV_LIB=@EXTENSION_LIBUV_LIB@ EXTENSION_LIBUV_EXT_LIBS=@EXTENSION_LIBUV_EXT_LIBS@ EXTENSION_LIBUV_LDFLAGS=@EXTENSION_LIBUV_LDFLAGS@ 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 stub.lo sync.lo util-internal.lo GLDNS_OBJ=keyraw.lo gbuffer.lo wire2str.lo parse.lo parseutil.lo rrdef.lo \ str2wire.lo LIBOBJDIR= LIBOBJS=@LIBOBJS@ COMPAT_OBJ=$(LIBOBJS:.o=.lo) UTIL_OBJ=mini_event.lo winsock_event.lo rbtree.lo val_secalgo.lo EXTENSION_OBJ=libmini_event.lo libevent.lo libev.lo NON_C99_OBJS=context.lo libuv.lo .SUFFIXES: .c .o .a .lo .h .c.o: $(CC) $(CFLAGS) -c $< -o $@ .c.lo: $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -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 $@ $(GLDNS_OBJ): $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -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 $@ $(EXTENSION_OBJ): $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/extension/$(@:.lo=.c) -o $@ context.lo: $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(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 install: libgetdns.la $(INSTALL) -m 755 -d $(DESTDIR)$(includedir) $(INSTALL) -m 755 -d $(DESTDIR)$(includedir)/getdns $(INSTALL) -m 644 getdns/getdns.h $(DESTDIR)$(includedir)/getdns/getdns.h $(INSTALL) -m 644 getdns/getdns_extra.h $(DESTDIR)$(includedir)/getdns/getdns_extra.h $(INSTALL) -m 755 -d $(DESTDIR)$(libdir) $(LIBTOOL) --mode=install cp libgetdns.la $(DESTDIR)$(libdir) if test $(have_libevent) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libevent.h $(DESTDIR)$(includedir)/getdns/ ; $(LIBTOOL) --mode=install cp $(EXTENSION_LIBEVENT_LIB) $(DESTDIR)$(libdir) ; fi if test $(have_libuv) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libuv.h $(DESTDIR)$(includedir)/getdns/ ; $(LIBTOOL) --mode=install cp $(EXTENSION_LIBUV_LIB) $(DESTDIR)$(libdir) ; fi if test $(have_libev) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libev.h $(DESTDIR)$(includedir)/getdns/ ; $(LIBTOOL) --mode=install cp $(EXTENSION_LIBEV_LIB) $(DESTDIR)$(libdir) ; fi $(LIBTOOL) --mode=finish $(DESTDIR)$(libdir) uninstall: rm -rf $(DESTDIR)$(includedir)/getdns $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libgetdns.la if test $(have_libevent) = 1; then $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(EXTENSION_LIBEVENT_LIB) ; fi if test $(have_libuv) = 1; then $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(EXTENSION_LIBUV_LIB) ; fi if test $(have_libev) = 1; then $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(EXTENSION_LIBEV_LIB) ; fi 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 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 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 libgetdns.la: $(GETDNS_OBJ) version.lo context.lo libmini_event.lo $(GLDNS_OBJ) $(COMPAT_OBJ) $(UTIL_OBJ) $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ $(GETDNS_OBJ) version.lo context.lo libmini_event.lo $(GLDNS_OBJ) $(COMPAT_OBJ) $(UTIL_OBJ) $(LDFLAGS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/libgetdns.symbols test: all cd test && $(MAKE) $@ getdns_query: all cd test && $(MAKE) $@ scratchpad: all cd test && $(MAKE) $@ pad: scratchpad clean: cd test && $(MAKE) $@ rm -f *.o *.lo extension/*.lo extension/*.o $(PROGRAMS) libgetdns.la libgetdns_ext_*.la rm -rf .libs extension/.libs distclean : clean cd test && $(MAKE) $@ rmdir test 2>/dev/null || true rm -f Makefile config.status config.log Doxyfile config.h version.c getdns/Makefile getdns/getdns.h getdns/getdns_extra.h rmdir getdns 2>/dev/null || true rmdir extension 2>/dev/null || true rm -Rf autom4te.cache $(distdir): FORCE mkdir -p $(distdir)/src cp configure.ac $(distdir) cp configure $(distdir) cp Makefile.in $(distdir) cp src/Makefile.in $(distdir)/src distcheck: $(distdir).tar.gz gzip -cd $(distdir).tar.gz | tar xvf - cd $(distdir) && ./configure cd $(distdir) && $(MAKE) all cd $(distdir) && $(MAKE) check cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall @remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \ if test "$${remaining}" -ne 0; then echo "@@@ $${remaining} file(s) remaining in stage directory!"; \ exit 1; \ fi cd $(distdir) && $(MAKE) clean rm -rf $(distdir) @echo "*** Package $(distdir).tar.gz is ready for distribution" Makefile: $(srcdir)/Makefile.in ../config.status cd .. && ./config.status src/Makefile configure.status: configure cd .. && ./config.status --recheck depend: (cd $(srcdir) ; awk 'BEGIN{P=1}{if(P)print}/^# Dependencies/{P=0}' Makefile.in > Makefile.in.new ) (blddir=`pwd`; cd $(srcdir) ; gcc -MM -I. -I"$$blddir" *.c gldns/*.c compat/*.c util/*.c extension/*.c| \ sed -e "s? $$blddir/? ?g" \ -e 's?gldns/?$$(srcdir)/gldns/?g' \ -e 's?compat/?$$(srcdir)/compat/?g' \ -e 's?util/?$$(srcdir)/util/?g' \ -e 's?extension/?$$(srcdir)/extension/?g' \ -e 's? \([a-z_-]*\)\.\([ch]\)? $$(srcdir)/\1.\2?g' \ -e 's? \$$(srcdir)/config\.h? config.h?g' \ -e 's? \$$(srcdir)/getdns/getdns_extra\.h? getdns/getdns_extra.h?g' \ -e 's? \$$(srcdir)/version\.c? version.c?g' \ -e 's? getdns/getdns_ext_libevent\.h? $$(srcdir)/getdns/getdns_ext_libevent.h?g' \ -e 's? getdns/getdns_ext_libev\.h? $$(srcdir)/getdns/getdns_ext_libev.h?g' \ -e 's? getdns/getdns_ext_libuv\.h? $$(srcdir)/getdns/getdns_ext_libuv.h?g' \ -e 's!\(.*\)\.o[ :]*!\1.lo \1.o: !g' >> Makefile.in.new ) (cd $(srcdir) ; diff Makefile.in.new Makefile.in && rm Makefile.in.new \ || mv Makefile.in.new Makefile.in ) cd test && $(MAKE) $@ .PHONY: clean test 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 \ 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/libmini_event.h \ config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.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)/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 \ getdns/getdns.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \ $(srcdir)/extension/libmini_event.h config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ $(srcdir)/types-internal.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)/dict.h $(srcdir)/list.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/libmini_event.h config.h $(srcdir)/util/mini_event.h \ $(srcdir)/util/rbtree.h $(srcdir)/types-internal.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 getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \ $(srcdir)/extension/libmini_event.h config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ $(srcdir)/types-internal.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/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)/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/libmini_event.h config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ $(srcdir)/types-internal.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)/stub.h $(srcdir)/general.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/libmini_event.h config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ $(srcdir)/types-internal.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.h getdns/getdns_extra.h $(srcdir)/types-internal.h \ $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h config.h $(srcdir)/util/mini_event.h \ $(srcdir)/util/rbtree.h $(srcdir)/types-internal.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/libmini_event.h config.h \ $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.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)/debug.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/libmini_event.h config.h \ $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.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 getdns/getdns.h $(srcdir)/rr-dict.h config.h \ $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.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/libmini_event.h \ config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.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/libmini_event.h \ config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.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)/stub.h $(srcdir)/gldns/wire2str.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/libmini_event.h config.h \ $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.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 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 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 mini_event.lo mini_event.o: $(srcdir)/util/mini_event.c config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ $(srcdir)/util/fptr_wlist.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 winsock_event.lo winsock_event.o: $(srcdir)/util/winsock_event.c config.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 libmini_event.lo libmini_event.o: $(srcdir)/extension/libmini_event.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)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.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 getdns-0.9.0/src/version.c0000664000175100017510000000364112641212403012350 00000000000000/** * * /brief function for returning version info about the library and the API * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include const char *getdns_get_version(void) { return "0.9.0"; } uint32_t getdns_get_version_number(void) { return 0x00090000; } const char *getdns_get_api_version(void) { return "December 2015"; } uint32_t getdns_get_api_version_number(void) { return 0x07df0c00; } /* version.c */ getdns-0.9.0/src/extension/0000775000175100017510000000000012641212403012607 500000000000000getdns-0.9.0/src/extension/libevent.symbols0000664000175100017510000000004312641212403015746 00000000000000getdns_extension_set_libevent_base getdns-0.9.0/src/extension/libuv.symbols0000664000175100017510000000004012641212403015254 00000000000000getdns_extension_set_libuv_loop getdns-0.9.0/src/extension/libuv.c0000664000175100017510000001654712641212403014031 00000000000000/** * \file libuv.c * \brief Eventloop extension for libuv. * */ /* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "debug.h" #include "types-internal.h" #include #include "getdns/getdns_ext_libuv.h" #define UV_DEBUG 0 #if defined(UV_DEBUG) && UV_DEBUG #include #define DEBUG_UV(...) DEBUG_ON(__VA_ARGS__) #else #define DEBUG_UV(...) DEBUG_OFF(__VA_ARGS__) #endif typedef struct getdns_libuv { getdns_eventloop_vmt *vmt; uv_loop_t *loop; struct mem_funcs mf; } getdns_libuv; static void getdns_libuv_run(getdns_eventloop *loop) { (void) uv_run(((getdns_libuv *)loop)->loop, UV_RUN_DEFAULT); } static void getdns_libuv_run_once(getdns_eventloop *loop, int blocking) { (void) uv_run(((getdns_libuv *)loop)->loop, blocking ? UV_RUN_ONCE : UV_RUN_NOWAIT); } static void getdns_libuv_cleanup(getdns_eventloop *loop) { getdns_libuv *ext = (getdns_libuv *)loop; GETDNS_FREE(ext->mf, ext); } typedef struct poll_timer { uv_poll_t read; uv_poll_t write; uv_timer_t timer; int to_close; struct mem_funcs mf; } poll_timer; static void getdns_libuv_close_cb(uv_handle_t *handle) { poll_timer *my_ev = (poll_timer *)handle->data; DEBUG_UV("enter libuv_close_cb(el_ev->ev = %p, to_close = %d)\n" , my_ev, my_ev->to_close); if (--my_ev->to_close) { DEBUG_UV( "exit libuv_close_cb(el_ev->ev = %p, to_close = %d)\n" , my_ev, my_ev->to_close); return; } DEBUG_UV("enter libuv_close_cb to_free: %p\n", my_ev); GETDNS_FREE(my_ev->mf, my_ev); DEBUG_UV("enter libuv_close_cb freed: %p\n", my_ev); } static getdns_return_t 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; assert(my_ev); DEBUG_UV("enter libuv_clear(el_ev = %p, my_ev = %p, to_close = %d)\n" , el_ev, my_ev, my_ev->to_close); if (el_ev->read_cb) { my_poll = &my_ev->read; uv_poll_stop(my_poll); my_ev->to_close += 1; my_poll->data = my_ev; uv_close((uv_handle_t *)my_poll, getdns_libuv_close_cb); } if (el_ev->write_cb) { my_poll = &my_ev->write; uv_poll_stop(my_poll); my_ev->to_close += 1; my_poll->data = my_ev; uv_close((uv_handle_t *)my_poll, getdns_libuv_close_cb); } if (el_ev->timeout_cb) { my_timer = &my_ev->timer; uv_timer_stop(my_timer); my_ev->to_close += 1; my_timer->data = my_ev; uv_close((uv_handle_t *)my_timer, getdns_libuv_close_cb); } el_ev->ev = NULL; DEBUG_UV("exit libuv_clear(el_ev = %p, my_ev = %p, to_close = %d)\n" , el_ev, my_ev, my_ev->to_close); return GETDNS_RETURN_GOOD; } static void getdns_libuv_read_cb(uv_poll_t *poll, int status, int events) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)poll->data; assert(el_ev->read_cb); DEBUG_UV("enter libuv_read_cb(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); el_ev->read_cb(el_ev->userarg); DEBUG_UV("exit libuv_read_cb(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); } static void getdns_libuv_write_cb(uv_poll_t *poll, int status, int events) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)poll->data; assert(el_ev->write_cb); DEBUG_UV("enter libuv_write_cb(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); el_ev->write_cb(el_ev->userarg); DEBUG_UV("exit libuv_write_cb(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); } static void #ifdef HAVE_NEW_UV_TIMER_CB getdns_libuv_timeout_cb(uv_timer_t *timer) #else getdns_libuv_timeout_cb(uv_timer_t *timer, int status) #endif { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)timer->data; assert(el_ev->timeout_cb); DEBUG_UV("enter libuv_timeout_cb(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); el_ev->timeout_cb(el_ev->userarg); DEBUG_UV("exit libuv_timeout_cb(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); } static getdns_return_t getdns_libuv_schedule(getdns_eventloop *loop, int fd, uint64_t timeout, getdns_eventloop_event *el_ev) { getdns_libuv *ext = (getdns_libuv *)loop; poll_timer *my_ev; uv_poll_t *my_poll; uv_timer_t *my_timer; assert(el_ev); assert(!(el_ev->read_cb || el_ev->write_cb) || fd >= 0); assert( el_ev->read_cb || el_ev->write_cb || el_ev->timeout_cb); DEBUG_UV("enter libuv_schedule(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); if (!(my_ev = GETDNS_MALLOC(ext->mf, poll_timer))) return GETDNS_RETURN_MEMORY_ERROR; my_ev->to_close = 0; my_ev->mf = ext->mf; el_ev->ev = my_ev; if (el_ev->read_cb) { my_poll = &my_ev->read; my_poll->data = el_ev; uv_poll_init(ext->loop, my_poll, fd); uv_poll_start(my_poll, UV_READABLE, getdns_libuv_read_cb); } if (el_ev->write_cb) { my_poll = &my_ev->write; my_poll->data = el_ev; uv_poll_init(ext->loop, my_poll, fd); uv_poll_start(my_poll, UV_WRITABLE, getdns_libuv_write_cb); } if (el_ev->timeout_cb) { my_timer = &my_ev->timer; my_timer->data = el_ev; uv_timer_init(ext->loop, my_timer); uv_timer_start(my_timer, getdns_libuv_timeout_cb, timeout, 0); } DEBUG_UV("exit libuv_schedule(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); return GETDNS_RETURN_GOOD; } getdns_return_t getdns_extension_set_libuv_loop(getdns_context *context, uv_loop_t *loop) { static getdns_eventloop_vmt getdns_libuv_vmt = { getdns_libuv_cleanup, getdns_libuv_schedule, getdns_libuv_clear, getdns_libuv_run, getdns_libuv_run_once }; getdns_libuv *ext; if (!context) return GETDNS_RETURN_BAD_CONTEXT; if (!loop) return GETDNS_RETURN_INVALID_PARAMETER; ext = GETDNS_MALLOC(*priv_getdns_context_mf(context), getdns_libuv); if (!ext) return GETDNS_RETURN_MEMORY_ERROR; ext->vmt = &getdns_libuv_vmt; ext->loop = loop; ext->mf = *priv_getdns_context_mf(context); return getdns_context_set_eventloop(context, (getdns_eventloop *)ext); } getdns-0.9.0/src/extension/libmini_event.h0000664000175100017510000000462012641212403015526 00000000000000/** * * \file libmini_event.h * @brief Build in default eventloop extension that uses select. * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _GETDNS_LIBMINI_EVENT_H_ #define _GETDNS_LIBMINI_EVENT_H_ #include "config.h" #ifndef USE_WINSOCK #include "util/mini_event.h" #else #include "util/winsock_event.h" #endif #include "types-internal.h" typedef struct _getdns_mini_event { getdns_eventloop loop; time_t time_secs; struct timeval time_tv; struct _getdns_event_base *base; size_t n_events; struct mem_funcs mf; } _getdns_mini_event; getdns_return_t _getdns_mini_event_init(getdns_context *context, _getdns_mini_event *mini_event); getdns_return_t _getdns_mini_event_create(getdns_context *ctxt, _getdns_mini_event **mini_event); void _getdns_mini_event_destroy(_getdns_mini_event *mini_event); #endif /* _GETDNS_LIBMINI_EVENT_H_ */ getdns-0.9.0/src/extension/libmini_event.c0000664000175100017510000002006212641212403015517 00000000000000/** * * \file libmini_event.c * @brief Build in default eventloop extension that uses select. * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "debug.h" #include "types-internal.h" #include "extension/libmini_event.h" #if defined(SCHED_DEBUG) && SCHED_DEBUG #include #endif static void _getdns_mini_event_cleanup(getdns_eventloop *loop) { _getdns_mini_event *ext = (_getdns_mini_event *)loop; _getdns_event_base_free(ext->base); } void _getdns_mini_event_destroy(_getdns_mini_event *ext) { assert(ext); ext->loop.vmt->cleanup(&ext->loop); GETDNS_FREE(ext->mf, ext); } void _getdns_handle_timeouts(struct _getdns_event_base* base, struct timeval* now, struct timeval* wait); int _getdns_handle_select(struct _getdns_event_base* base, struct timeval* wait); static int _getdns_mini_event_settime(_getdns_mini_event *ext) { if (gettimeofday(&ext->time_tv, NULL) < 0) return -1; ext->time_secs = (time_t)ext->time_tv.tv_sec; return 0; } static void _getdns_mini_event_run(getdns_eventloop *loop) { _getdns_mini_event *ext = (_getdns_mini_event *)loop; struct timeval wait; if (ext->n_events == 0 || _getdns_mini_event_settime(ext) < 0) return; do { (void) _getdns_handle_timeouts(ext->base, &ext->time_tv, &wait); if (!ext->n_events) break; if (_getdns_handle_select(ext->base, &wait)) break; } while (ext->n_events); } static void _getdns_mini_event_run_once(getdns_eventloop *loop, int blocking) { static struct timeval immediately = { 0, 0 }; _getdns_mini_event *ext = (_getdns_mini_event *)loop; struct timeval wait; if (blocking) { if (_getdns_mini_event_settime(ext) < 0) return; _getdns_handle_timeouts(ext->base, &ext->time_tv, &wait); if (_getdns_handle_select(ext->base, &wait) < 0) return; } else if (_getdns_handle_select(ext->base, &immediately) < 0) return; _getdns_handle_timeouts(ext->base, &ext->time_tv, &wait); } static getdns_return_t _getdns_mini_event_clear(getdns_eventloop *loop, getdns_eventloop_event *el_ev) { getdns_return_t r = GETDNS_RETURN_GOOD; _getdns_mini_event *ext = (_getdns_mini_event *)loop; assert(el_ev->ev); DEBUG_SCHED("1. _getdns_mini_event_clear(loop: %p, el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p]); n_events: %d, times: %d\n", loop, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev, (int)ext->n_events, (int)ext->base->times->count); if (_getdns_event_del(el_ev->ev) != 0) r = GETDNS_RETURN_GENERIC_ERROR; GETDNS_FREE(ext->mf, el_ev->ev); el_ev->ev = NULL; ext->n_events--; DEBUG_SCHED("2. %d <- _getdns_mini_event_clear(loop: %p, el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p]); n_events: %d, times: %d\n", r, loop, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev, (int)ext->n_events, (int)ext->base->times->count); return r; } static void _getdns_mini_event_callback(int fd, short bits, void *arg) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)arg; DEBUG_SCHED("1. _getdns_mini_event_callback(fd: %d, bits: %d, el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p])\n", fd, (int)bits, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev); if (bits & EV_READ) { assert(el_ev->read_cb); el_ev->read_cb(el_ev->userarg); } else if (bits & EV_WRITE) { assert(el_ev->write_cb); el_ev->write_cb(el_ev->userarg); } else if (bits & EV_TIMEOUT) { assert(el_ev->timeout_cb); el_ev->timeout_cb(el_ev->userarg); } else assert(ASSERT_UNREACHABLE); } static getdns_return_t _getdns_mini_event_schedule(getdns_eventloop *loop, int fd, uint64_t timeout, getdns_eventloop_event *el_ev) { _getdns_mini_event *ext = (_getdns_mini_event *)loop; struct _getdns_event *my_ev; struct timeval tv = { timeout / 1000, (timeout % 1000) * 1000 }; assert(el_ev); assert(!(el_ev->read_cb || el_ev->write_cb) || fd >= 0); assert( el_ev->read_cb || el_ev->write_cb || el_ev->timeout_cb); if (!(my_ev = GETDNS_MALLOC(ext->mf, struct _getdns_event))) return GETDNS_RETURN_MEMORY_ERROR; el_ev->ev = my_ev; DEBUG_SCHED("1. _getdns_mini_event_schedule(loop: %p, fd: %d, timeout: %"PRId64", el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p]); n_events: %d\n", loop, fd, timeout, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev, (int)ext->n_events); _getdns_event_set(my_ev, fd, ( (el_ev->read_cb ? EV_READ|EV_PERSIST : 0) | (el_ev->write_cb ? EV_WRITE|EV_PERSIST : 0) | (el_ev->timeout_cb ? EV_TIMEOUT : 0)), _getdns_mini_event_callback, el_ev); if (_getdns_mini_event_settime(ext)) goto error; (void) _getdns_event_base_set(ext->base, my_ev); if (_getdns_event_add(my_ev, el_ev->timeout_cb ? &tv : NULL)) goto error; ext->n_events++; DEBUG_SCHED("2. _getdns_mini_event_schedule(loop: %p, fd: %d, timeout: %"PRId64", el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p]); n_events: %d\n", loop, fd, timeout, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev, (int)ext->n_events); return GETDNS_RETURN_GOOD; error: GETDNS_FREE(ext->mf, my_ev); el_ev->ev = NULL; DEBUG_SCHED("3. _getdns_mini_event_schedule(loop: %p, fd: %d, timeout: %"PRId64", el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p]); n_events: %d\n", loop, fd, timeout, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev, (int)ext->n_events); return GETDNS_RETURN_GENERIC_ERROR; } getdns_return_t _getdns_mini_event_init(getdns_context *context, _getdns_mini_event *ext) { static getdns_eventloop_vmt _getdns_mini_event_vmt = { _getdns_mini_event_cleanup, _getdns_mini_event_schedule, _getdns_mini_event_clear, _getdns_mini_event_run, _getdns_mini_event_run_once }; if (!context) return GETDNS_RETURN_BAD_CONTEXT; if (!ext) return GETDNS_RETURN_INVALID_PARAMETER; #ifdef USE_WINSOCK int r; WSADATA wsa_data; if ((r = WSAStartup(MAKEWORD(2, 2), &wsa_data)) != 0) { printf("could not init winsock. WSAStartup: %s", wsa_strerror(r)); return GETDNS_RETURN_GENERIC_ERROR; } #endif ext->n_events = 0; ext->loop.vmt = &_getdns_mini_event_vmt; ext->base = _getdns_event_init(&ext->time_secs, &ext->time_tv); if (!ext->base) return GETDNS_RETURN_MEMORY_ERROR; ext->mf = *priv_getdns_context_mf(context); return GETDNS_RETURN_GOOD; } getdns_return_t _getdns_mini_event_create(getdns_context *context, _getdns_mini_event **ext) { if (!context) return GETDNS_RETURN_BAD_CONTEXT; if (!ext) return GETDNS_RETURN_INVALID_PARAMETER; *ext = GETDNS_MALLOC(*priv_getdns_context_mf(context), _getdns_mini_event); return _getdns_mini_event_init(context, *ext); } getdns-0.9.0/src/extension/libevent.c0000664000175100017510000001244212641212403014506 00000000000000/** * \file libevent.c * \brief Eventloop extension for libevent * */ /* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "types-internal.h" #include #include "getdns/getdns_ext_libevent.h" #ifdef HAVE_EVENT2_EVENT_H # include #else # include # define evutil_socket_t int # define event_free free # define evtimer_new(b, cb, arg) event_new((b), -1, 0, (cb), (arg)) #endif #ifndef HAVE_EVENT_BASE_FREE #define event_base_free(x) /* nop */ #endif #ifndef HAVE_EVENT_BASE_NEW #define event_base_new event_init #endif #ifndef HAVE_EVENT2_EVENT_H static struct event * event_new(struct event_base *b, evutil_socket_t fd, short ev, void (*cb)(int, short, void*), void *arg) { struct event* e = (struct event*)calloc(1, sizeof(struct event)); if (!e) return NULL; event_set(e, fd, ev, cb, arg); event_base_set(b, e); return e; } #endif /* no event2 */ typedef struct getdns_libevent { getdns_eventloop_vmt *vmt; struct event_base *base; struct mem_funcs mf; } getdns_libevent; static void getdns_libevent_run(getdns_eventloop *loop) { (void) event_base_dispatch(((getdns_libevent *)loop)->base); } static void getdns_libevent_run_once(getdns_eventloop *loop, int blocking) { (void) event_base_loop(((getdns_libevent *)loop)->base, EVLOOP_ONCE | (blocking ? EVLOOP_NONBLOCK : 0)); } static void getdns_libevent_cleanup(getdns_eventloop *loop) { getdns_libevent *ext = (getdns_libevent *)loop; GETDNS_FREE(ext->mf, ext); } static getdns_return_t getdns_libevent_clear(getdns_eventloop *loop, getdns_eventloop_event *el_ev) { struct event *my_ev = (struct event *)el_ev->ev; assert(my_ev); if (event_del(my_ev) != 0) return GETDNS_RETURN_GENERIC_ERROR; event_free(my_ev); el_ev->ev = NULL; return GETDNS_RETURN_GOOD; } static void getdns_libevent_callback(evutil_socket_t fd, short bits, void *arg) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)arg; if (bits & EV_READ) { assert(el_ev->read_cb); el_ev->read_cb(el_ev->userarg); } else if (bits & EV_WRITE) { assert(el_ev->write_cb); el_ev->write_cb(el_ev->userarg); } else if (bits & EV_TIMEOUT) { assert(el_ev->timeout_cb); el_ev->timeout_cb(el_ev->userarg); } else assert(ASSERT_UNREACHABLE); } static getdns_return_t getdns_libevent_schedule(getdns_eventloop *loop, int fd, uint64_t timeout, getdns_eventloop_event *el_ev) { getdns_libevent *ext = (getdns_libevent *)loop; struct event *my_ev; struct timeval tv = { timeout / 1000, (timeout % 1000) * 1000 }; assert(el_ev); assert(!(el_ev->read_cb || el_ev->write_cb) || fd >= 0); assert( el_ev->read_cb || el_ev->write_cb || el_ev->timeout_cb); my_ev = event_new(ext->base, fd, ( (el_ev->read_cb ? EV_READ|EV_PERSIST : 0) | (el_ev->write_cb ? EV_WRITE|EV_PERSIST : 0) | (el_ev->timeout_cb ? EV_TIMEOUT : 0)), getdns_libevent_callback, el_ev); if (!my_ev) return GETDNS_RETURN_MEMORY_ERROR; el_ev->ev = my_ev; if (event_add(my_ev, el_ev->timeout_cb ? &tv : NULL)) { event_free(my_ev); el_ev->ev = NULL; return GETDNS_RETURN_GENERIC_ERROR; } return GETDNS_RETURN_GOOD; } getdns_return_t getdns_extension_set_libevent_base(getdns_context *context, struct event_base *base) { static getdns_eventloop_vmt getdns_libevent_vmt = { getdns_libevent_cleanup, getdns_libevent_schedule, getdns_libevent_clear, getdns_libevent_run, getdns_libevent_run_once }; getdns_libevent *ext; if (!context) return GETDNS_RETURN_BAD_CONTEXT; if (!base) return GETDNS_RETURN_INVALID_PARAMETER; ext = GETDNS_MALLOC(*priv_getdns_context_mf(context), getdns_libevent); if (!ext) return GETDNS_RETURN_MEMORY_ERROR; ext->vmt = &getdns_libevent_vmt; ext->base = base; ext->mf = *priv_getdns_context_mf(context); return getdns_context_set_eventloop(context, (getdns_eventloop *)ext); } getdns-0.9.0/src/extension/libev.symbols0000664000175100017510000000004012641212403015234 00000000000000getdns_extension_set_libev_loop getdns-0.9.0/src/extension/libev.c0000664000175100017510000001242612641212403014001 00000000000000/** * \file libev.c * \brief Eventloop extension for libev * */ /* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "types-internal.h" #include "getdns/getdns_ext_libev.h" #ifdef HAVE_LIBEV_EV_H #include #else #include #endif typedef struct getdns_libev { getdns_eventloop_vmt *vmt; struct ev_loop *loop; struct mem_funcs mf; } getdns_libev; static void getdns_libev_run(getdns_eventloop *loop) { (void) ev_run(((getdns_libev *)loop)->loop, 0); } static void getdns_libev_run_once(getdns_eventloop *loop, int blocking) { (void) ev_run(((getdns_libev *)loop)->loop, blocking ? EVRUN_ONCE : EVRUN_NOWAIT); } static void getdns_libev_cleanup(getdns_eventloop *loop) { getdns_libev *ext = (getdns_libev *)loop; GETDNS_FREE(ext->mf, ext); } typedef struct io_timer { ev_io read; ev_io write; ev_timer timer; } io_timer; static getdns_return_t getdns_libev_clear(getdns_eventloop *loop, getdns_eventloop_event *el_ev) { getdns_libev *ext = (getdns_libev *)loop; io_timer *my_ev = (io_timer *)el_ev->ev; assert(my_ev); if (el_ev->read_cb) ev_io_stop(ext->loop, &my_ev->read); if (el_ev->write_cb) ev_io_stop(ext->loop, &my_ev->write); if (el_ev->timeout_cb) ev_timer_stop(ext->loop, &my_ev->timer); GETDNS_FREE(ext->mf, el_ev->ev); el_ev->ev = NULL; return GETDNS_RETURN_GOOD; } 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; assert(el_ev->read_cb); el_ev->read_cb(el_ev->userarg); } 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; 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_eventloop_event *el_ev = (getdns_eventloop_event *)timer->data; assert(el_ev->timeout_cb); el_ev->timeout_cb(el_ev->userarg); } static getdns_return_t getdns_libev_schedule(getdns_eventloop *loop, int fd, uint64_t timeout, getdns_eventloop_event *el_ev) { getdns_libev *ext = (getdns_libev *)loop; io_timer *my_ev; ev_io *my_io; ev_timer *my_timer; ev_tstamp to = ((ev_tstamp)timeout) / 1000; assert(el_ev); assert(!(el_ev->read_cb || el_ev->write_cb) || fd >= 0); assert( el_ev->read_cb || el_ev->write_cb || el_ev->timeout_cb); if (!(my_ev = GETDNS_MALLOC(ext->mf, io_timer))) return GETDNS_RETURN_MEMORY_ERROR; el_ev->ev = my_ev; if (el_ev->read_cb) { my_io = &my_ev->read; ev_io_init(my_io, getdns_libev_read_cb, fd, EV_READ); my_io->data = el_ev; ev_io_start(ext->loop, my_io); } if (el_ev->write_cb) { my_io = &my_ev->write; ev_io_init(my_io, getdns_libev_write_cb, fd, EV_WRITE); my_io->data = el_ev; ev_io_start(ext->loop, my_io); } if (el_ev->timeout_cb) { my_timer = &my_ev->timer; ev_timer_init(my_timer, getdns_libev_timeout_cb, to, 0); my_timer->data = el_ev; ev_timer_start(ext->loop, my_timer); } return GETDNS_RETURN_GOOD; } getdns_return_t getdns_extension_set_libev_loop(getdns_context *context, struct ev_loop *loop) { static getdns_eventloop_vmt getdns_libev_vmt = { getdns_libev_cleanup, getdns_libev_schedule, getdns_libev_clear, getdns_libev_run, getdns_libev_run_once }; getdns_libev *ext; if (!context) return GETDNS_RETURN_BAD_CONTEXT; if (!loop) return GETDNS_RETURN_INVALID_PARAMETER; ext = GETDNS_MALLOC(*priv_getdns_context_mf(context), getdns_libev); if (!ext) return GETDNS_RETURN_MEMORY_ERROR; ext->vmt = &getdns_libev_vmt; ext->loop = loop; ext->mf = *priv_getdns_context_mf(context); return getdns_context_set_eventloop(context, (getdns_eventloop *)ext); } getdns-0.9.0/src/const-info.c0000664000175100017510000001752612641212403012751 00000000000000/* WARNING! This file is generated by the mk-const-info.c.sh program. * Do not edit manually! */ #include #include "getdns/getdns.h" #include "getdns/getdns_extra.h" #include "const-info.h" static struct const_info consts_info[] = { { -1, NULL, "/* */" }, { 0, "GETDNS_RETURN_GOOD", GETDNS_RETURN_GOOD_TEXT }, { 1, "GETDNS_RETURN_GENERIC_ERROR", GETDNS_RETURN_GENERIC_ERROR_TEXT }, { 300, "GETDNS_RETURN_BAD_DOMAIN_NAME", GETDNS_RETURN_BAD_DOMAIN_NAME_TEXT }, { 301, "GETDNS_RETURN_BAD_CONTEXT", GETDNS_RETURN_BAD_CONTEXT_TEXT }, { 302, "GETDNS_RETURN_CONTEXT_UPDATE_FAIL", GETDNS_RETURN_CONTEXT_UPDATE_FAIL_TEXT }, { 303, "GETDNS_RETURN_UNKNOWN_TRANSACTION", GETDNS_RETURN_UNKNOWN_TRANSACTION_TEXT }, { 304, "GETDNS_RETURN_NO_SUCH_LIST_ITEM", GETDNS_RETURN_NO_SUCH_LIST_ITEM_TEXT }, { 305, "GETDNS_RETURN_NO_SUCH_DICT_NAME", GETDNS_RETURN_NO_SUCH_DICT_NAME_TEXT }, { 306, "GETDNS_RETURN_WRONG_TYPE_REQUESTED", GETDNS_RETURN_WRONG_TYPE_REQUESTED_TEXT }, { 307, "GETDNS_RETURN_NO_SUCH_EXTENSION", GETDNS_RETURN_NO_SUCH_EXTENSION_TEXT }, { 308, "GETDNS_RETURN_EXTENSION_MISFORMAT", GETDNS_RETURN_EXTENSION_MISFORMAT_TEXT }, { 309, "GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED", GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED_TEXT }, { 310, "GETDNS_RETURN_MEMORY_ERROR", GETDNS_RETURN_MEMORY_ERROR_TEXT }, { 311, "GETDNS_RETURN_INVALID_PARAMETER", GETDNS_RETURN_INVALID_PARAMETER_TEXT }, { 312, "GETDNS_RETURN_NOT_IMPLEMENTED", GETDNS_RETURN_NOT_IMPLEMENTED_TEXT }, { 399, "GETDNS_RETURN_NEED_MORE_SPACE", GETDNS_RETURN_NEED_MORE_SPACE_TEXT }, { 400, "GETDNS_DNSSEC_SECURE", GETDNS_DNSSEC_SECURE_TEXT }, { 401, "GETDNS_DNSSEC_BOGUS", GETDNS_DNSSEC_BOGUS_TEXT }, { 402, "GETDNS_DNSSEC_INDETERMINATE", GETDNS_DNSSEC_INDETERMINATE_TEXT }, { 403, "GETDNS_DNSSEC_INSECURE", GETDNS_DNSSEC_INSECURE_TEXT }, { 404, "GETDNS_DNSSEC_NOT_PERFORMED", GETDNS_DNSSEC_NOT_PERFORMED_TEXT }, { 500, "GETDNS_NAMESPACE_DNS", GETDNS_NAMESPACE_DNS_TEXT }, { 501, "GETDNS_NAMESPACE_LOCALNAMES", GETDNS_NAMESPACE_LOCALNAMES_TEXT }, { 502, "GETDNS_NAMESPACE_NETBIOS", GETDNS_NAMESPACE_NETBIOS_TEXT }, { 503, "GETDNS_NAMESPACE_MDNS", GETDNS_NAMESPACE_MDNS_TEXT }, { 504, "GETDNS_NAMESPACE_NIS", GETDNS_NAMESPACE_NIS_TEXT }, { 520, "GETDNS_RESOLUTION_STUB", GETDNS_RESOLUTION_STUB_TEXT }, { 521, "GETDNS_RESOLUTION_RECURSING", GETDNS_RESOLUTION_RECURSING_TEXT }, { 530, "GETDNS_REDIRECTS_FOLLOW", GETDNS_REDIRECTS_FOLLOW_TEXT }, { 531, "GETDNS_REDIRECTS_DO_NOT_FOLLOW", GETDNS_REDIRECTS_DO_NOT_FOLLOW_TEXT }, { 540, "GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP", GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP_TEXT }, { 541, "GETDNS_TRANSPORT_UDP_ONLY", GETDNS_TRANSPORT_UDP_ONLY_TEXT }, { 542, "GETDNS_TRANSPORT_TCP_ONLY", GETDNS_TRANSPORT_TCP_ONLY_TEXT }, { 543, "GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN_TEXT }, { 544, "GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN_TEXT }, { 545, "GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT }, { 550, "GETDNS_APPEND_NAME_ALWAYS", GETDNS_APPEND_NAME_ALWAYS_TEXT }, { 551, "GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE_TEXT }, { 552, "GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE_TEXT }, { 553, "GETDNS_APPEND_NAME_NEVER", GETDNS_APPEND_NAME_NEVER_TEXT }, { 600, "GETDNS_CONTEXT_CODE_NAMESPACES", GETDNS_CONTEXT_CODE_NAMESPACES_TEXT }, { 601, "GETDNS_CONTEXT_CODE_RESOLUTION_TYPE", GETDNS_CONTEXT_CODE_RESOLUTION_TYPE_TEXT }, { 602, "GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS", GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS_TEXT }, { 603, "GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS", GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS_TEXT }, { 604, "GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS", GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS_TEXT }, { 605, "GETDNS_CONTEXT_CODE_DNS_TRANSPORT", GETDNS_CONTEXT_CODE_DNS_TRANSPORT_TEXT }, { 606, "GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES", GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES_TEXT }, { 607, "GETDNS_CONTEXT_CODE_APPEND_NAME", GETDNS_CONTEXT_CODE_APPEND_NAME_TEXT }, { 608, "GETDNS_CONTEXT_CODE_SUFFIX", GETDNS_CONTEXT_CODE_SUFFIX_TEXT }, { 609, "GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS", GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS_TEXT }, { 610, "GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE", GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE_TEXT }, { 611, "GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE", GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE_TEXT }, { 612, "GETDNS_CONTEXT_CODE_EDNS_VERSION", GETDNS_CONTEXT_CODE_EDNS_VERSION_TEXT }, { 613, "GETDNS_CONTEXT_CODE_EDNS_DO_BIT", GETDNS_CONTEXT_CODE_EDNS_DO_BIT_TEXT }, { 614, "GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW", GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW_TEXT }, { 615, "GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS", GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS_TEXT }, { 616, "GETDNS_CONTEXT_CODE_TIMEOUT", GETDNS_CONTEXT_CODE_TIMEOUT_TEXT }, { 617, "GETDNS_CONTEXT_CODE_IDLE_TIMEOUT", GETDNS_CONTEXT_CODE_IDLE_TIMEOUT_TEXT }, { 618, "GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION", GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION_TEXT }, { 619, "GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE", GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE_TEXT }, { 620, "GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE", GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE_TEXT }, { 621, "GETDNS_CONTEXT_CODE_PUBKEY_PINSET", GETDNS_CONTEXT_CODE_PUBKEY_PINSET_TEXT }, { 700, "GETDNS_CALLBACK_COMPLETE", GETDNS_CALLBACK_COMPLETE_TEXT }, { 701, "GETDNS_CALLBACK_CANCEL", GETDNS_CALLBACK_CANCEL_TEXT }, { 702, "GETDNS_CALLBACK_TIMEOUT", GETDNS_CALLBACK_TIMEOUT_TEXT }, { 703, "GETDNS_CALLBACK_ERROR", GETDNS_CALLBACK_ERROR_TEXT }, { 800, "GETDNS_NAMETYPE_DNS", GETDNS_NAMETYPE_DNS_TEXT }, { 801, "GETDNS_NAMETYPE_WINS", GETDNS_NAMETYPE_WINS_TEXT }, { 900, "GETDNS_RESPSTATUS_GOOD", GETDNS_RESPSTATUS_GOOD_TEXT }, { 901, "GETDNS_RESPSTATUS_NO_NAME", GETDNS_RESPSTATUS_NO_NAME_TEXT }, { 902, "GETDNS_RESPSTATUS_ALL_TIMEOUT", GETDNS_RESPSTATUS_ALL_TIMEOUT_TEXT }, { 903, "GETDNS_RESPSTATUS_NO_SECURE_ANSWERS", GETDNS_RESPSTATUS_NO_SECURE_ANSWERS_TEXT }, { 904, "GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS", GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS_TEXT }, { 1000, "GETDNS_EXTENSION_TRUE", GETDNS_EXTENSION_TRUE_TEXT }, { 1001, "GETDNS_EXTENSION_FALSE", GETDNS_EXTENSION_FALSE_TEXT }, { 1100, "GETDNS_BAD_DNS_CNAME_IN_TARGET", GETDNS_BAD_DNS_CNAME_IN_TARGET_TEXT }, { 1101, "GETDNS_BAD_DNS_ALL_NUMERIC_LABEL", GETDNS_BAD_DNS_ALL_NUMERIC_LABEL_TEXT }, { 1102, "GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE", GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE_TEXT }, { 1200, "GETDNS_TRANSPORT_UDP", GETDNS_TRANSPORT_UDP_TEXT }, { 1201, "GETDNS_TRANSPORT_TCP", GETDNS_TRANSPORT_TCP_TEXT }, { 1202, "GETDNS_TRANSPORT_TLS", GETDNS_TRANSPORT_TLS_TEXT }, { 1300, "GETDNS_AUTHENTICATION_NONE", GETDNS_AUTHENTICATION_NONE_TEXT }, { 1301, "GETDNS_AUTHENTICATION_REQUIRED", GETDNS_AUTHENTICATION_REQUIRED_TEXT }, }; static int const_info_cmp(const void *a, const void *b) { return ((struct const_info *) a)->code - ((struct const_info *) b)->code; } struct const_info * _getdns_get_const_info(int value) { struct const_info key = { value, "", "" }; struct const_info *i = bsearch(&key, consts_info, sizeof(consts_info) / sizeof(struct const_info), sizeof(struct const_info), const_info_cmp); if (i) return i; return consts_info; } const char * getdns_get_errorstr_by_id(uint16_t err) { struct const_info key = { (int)err, "", "" }; struct const_info *i = bsearch(&key, consts_info, sizeof(consts_info) / sizeof(struct const_info), sizeof(struct const_info), const_info_cmp); if (i) return i->text; else return NULL; } getdns-0.9.0/src/config.h.in0000664000175100017510000003356212641212403012547 00000000000000/* src/config.h.in. Generated from configure.ac by autoheader. */ /* Define this to disable recursing resolution type. */ #undef DISABLE_RESOLUTION_RECURSING /* Define this to enable the experimental draft dnssec roadblock avoidance. */ #undef DNSSEC_ROADBLOCK_AVOIDANCE /* Define this to enable the experimental draft edns cookies. */ #undef EDNS_COOKIES /* The edns cookie option code. */ #undef EDNS_COOKIE_OPCODE /* How often the edns client cookie is refreshed. */ #undef EDNS_COOKIE_ROLLOVER_TIME /* The edns padding option code. */ #undef EDNS_PADDING_OPCODE /* Define this to enable Windows build. */ #undef GETDNS_ON_WINDOWS /* Define to 1 if you have the `arc4random' function. */ #undef HAVE_ARC4RANDOM /* Define to 1 if you have the `arc4random_uniform' function. */ #undef HAVE_ARC4RANDOM_UNIFORM /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Whether the C compiler accepts the "format" attribute */ #undef HAVE_ATTR_FORMAT /* Whether the C compiler accepts the "unused" attribute */ #undef HAVE_ATTR_UNUSED /* Define to 1 if you have the header file. */ #undef HAVE_BSD_STRING_H /* Define to 1 if you have the declaration of `arc4random', and to 0 if you don't. */ #undef HAVE_DECL_ARC4RANDOM /* Define to 1 if you have the declaration of `arc4random_uniform', and to 0 if you don't. */ #undef HAVE_DECL_ARC4RANDOM_UNIFORM /* Define to 1 if you have the declaration of `NID_secp384r1', and to 0 if you don't. */ #undef HAVE_DECL_NID_SECP384R1 /* Define to 1 if you have the declaration of `NID_X9_62_prime256v1', and to 0 if you don't. */ #undef HAVE_DECL_NID_X9_62_PRIME256V1 /* Define to 1 if you have the declaration of `reallocarray', and to 0 if you don't. */ #undef HAVE_DECL_REALLOCARRAY /* Define to 1 if you have the declaration of `sk_SSL_COMP_pop_free', and to 0 if you don't. */ #undef HAVE_DECL_SK_SSL_COMP_POP_FREE /* Define to 1 if you have the declaration of `SSL_COMP_get_compression_methods', and to 0 if you don't. */ #undef HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS /* Define to 1 if you have the declaration of `SSL_CTX_set_ecdh_auto', and to 0 if you don't. */ #undef HAVE_DECL_SSL_CTX_SET_ECDH_AUTO /* Define to 1 if you have the declaration of `strlcat', and to 0 if you don't. */ #undef HAVE_DECL_STRLCAT /* Define to 1 if you have the declaration of `strlcpy', and to 0 if you don't. */ #undef HAVE_DECL_STRLCPY /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_EVENT2_EVENT_H /* Define to 1 if you have the `event_base_free' function. */ #undef HAVE_EVENT_BASE_FREE /* Define to 1 if you have the `event_base_new' function. */ #undef HAVE_EVENT_BASE_NEW /* Define to 1 if you have the header file. */ #undef HAVE_EVENT_H /* Define to 1 if you have the `EVP_md5' function. */ #undef HAVE_EVP_MD5 /* Define to 1 if you have the `EVP_sha1' function. */ #undef HAVE_EVP_SHA1 /* Define to 1 if you have the `EVP_sha224' function. */ #undef HAVE_EVP_SHA224 /* Define to 1 if you have the `EVP_sha256' function. */ #undef HAVE_EVP_SHA256 /* Define to 1 if you have the `EVP_sha384' function. */ #undef HAVE_EVP_SHA384 /* Define to 1 if you have the `EVP_sha512' function. */ #undef HAVE_EVP_SHA512 /* Define to 1 if you have the header file. */ #undef HAVE_EV_H /* Define to 1 if you have the `fcntl' function. */ #undef HAVE_FCNTL /* Define to 1 if you have the `FIPS_mode' function. */ #undef HAVE_FIPS_MODE /* Whether getaddrinfo is available */ #undef HAVE_GETADDRINFO /* Define to 1 if you have the `getauxval' function. */ #undef HAVE_GETAUXVAL /* Define to 1 if you have the `getentropy' function. */ #undef HAVE_GETENTROPY /* If you have HMAC_CTX_init */ #undef HAVE_HMAC_CTX_INIT /* Define to 1 if you have the `inet_ntop' function. */ #undef HAVE_INET_NTOP /* Define to 1 if you have the `inet_pton' function. */ #undef HAVE_INET_PTON /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* if the function 'ioctlsocket' is available */ #undef HAVE_IOCTLSOCKET /* Define to 1 if you have the header file. */ #undef HAVE_LIBEV_EV_H /* Define to 1 if you have the `idn' library (-lidn). */ #undef HAVE_LIBIDN /* Have libldns */ #undef HAVE_LIBLDNS /* Define if we have LibreSSL */ #undef HAVE_LIBRESSL /* Define to 1 if you have the `unbound' library (-lunbound). */ #undef HAVE_LIBUNBOUND /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Does libuv have the new uv_time_cb signature */ #undef HAVE_NEW_UV_TIMER_CB /* Define to 1 if you have the `OPENSSL_config' function. */ #undef HAVE_OPENSSL_CONFIG /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_CONF_H /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_ENGINE_H /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_ERR_H /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_RAND_H /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_SSL_H /* Define to 1 if you have the `SHA512_Update' function. */ #undef HAVE_SHA512_UPDATE /* Define if you have the SSL libraries installed. */ #undef HAVE_SSL /* Define if you have libssl with host name verification */ #undef HAVE_SSL_HN_AUTH /* Define to 1 if you have the header file. */ #undef HAVE_STDARG_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDIO_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SHA2_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SYSCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_TIME_H /* Define if you have libssl with tls 1.2 */ #undef HAVE_TLS_v1_2 /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the header file. */ #undef HAVE_UV_H /* Define to 1 if you have the header file. */ #undef HAVE_WINDOWS_H /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK2_H /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK_H /* Define to 1 if you have the header file. */ #undef HAVE_WS2TCPIP_H /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* limit for dynamically-generated DNS options */ #undef MAXIMUM_UPSTREAM_OPTION_SPACE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define this to enable printing of scheduling debugging messages. */ #undef SCHED_DEBUG /* Define this to enable printing of dnssec debugging messages. */ #undef SEC_DEBUG /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define this to enable printing of stub debugging messages. */ #undef STUB_DEBUG /* Define this to enable native stub DNSSEC support. */ #undef STUB_NATIVE_DNSSEC /* System configuration dir */ #undef SYSCONFDIR /* Default trust anchor file */ #undef TRUST_ANCHOR_FILE /* Define this to enable ECDSA support. */ #undef USE_ECDSA /* Define this to enable an EVP workaround for older openssl */ #undef USE_ECDSA_EVP_WORKAROUND /* Define this to enable GOST support. */ #undef USE_GOST /* Needed for sync stub resolver functions */ #undef USE_MINI_EVENT /* Define this to enable TCP fast open. */ #undef USE_OSX_TCP_FASTOPEN /* Define this to enable SHA256 and SHA512 support. */ #undef USE_SHA2 /* Define this to enable TCP fast open. */ #undef USE_TCP_FASTOPEN /* Whether the windows socket API is used */ #undef USE_WINSOCK /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT32_T /* Define for Solaris 2.5.1 so the uint64_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT64_T /* Define for Solaris 2.5.1 so the uint8_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT8_T /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to the type of an unsigned integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ #undef uint16_t /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef uint32_t /* Define to the type of an unsigned integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ #undef uint64_t /* Define to the type of an unsigned integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ #undef uint8_t /* the version of the windows API enabled */ #undef WINVER #undef _WIN32_WINNT #define WINVER 0x0600 // 0x0502 #define _WIN32_WINNT 0x0600 // 0x0502 #ifdef HAVE_WINSOCK2_H #include #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif #ifndef USE_WINSOCK #define ARG_LL "%ll" #else #define ARG_LL "%I64" #endif /* detect if we need to cast to unsigned int for FD_SET to avoid warnings */ #ifdef HAVE_WINSOCK2_H #define FD_SET_T (u_int) #else #define FD_SET_T #endif #include #include #include #include #include #ifdef HAVE_BSD_STRING_H #include #endif #ifdef __cplusplus extern "C" { #endif #if STDC_HEADERS #include #include #endif #if !defined(HAVE_STRLCPY) || !HAVE_DECL_STRLCPY || !defined(strlcpy) size_t strlcpy(char *dst, const char *src, size_t siz); #else #ifndef __BSD_VISIBLE #define __BSD_VISIBLE 1 #endif #endif #if !defined(HAVE_ARC4RANDOM) || !HAVE_DECL_ARC4RANDOM uint32_t arc4random(void); #endif #if !defined(HAVE_ARC4RANDOM_UNIFORM) || !HAVE_DECL_ARC4RANDOM_UNIFORM uint32_t arc4random_uniform(uint32_t upper_bound); #endif #ifndef HAVE_ARC4RANDOM void explicit_bzero(void* buf, size_t len); int getentropy(void* buf, size_t len); void arc4random_buf(void* buf, size_t n); void _ARC4_LOCK(void); void _ARC4_UNLOCK(void); #endif #ifdef COMPAT_SHA512 #ifndef SHA512_DIGEST_LENGTH #define SHA512_BLOCK_LENGTH 128 #define SHA512_DIGEST_LENGTH 64 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) typedef struct _SHA512_CTX { uint64_t state[8]; uint64_t bitcount[2]; uint8_t buffer[SHA512_BLOCK_LENGTH]; } SHA512_CTX; #endif /* SHA512_DIGEST_LENGTH */ void SHA512_Init(SHA512_CTX*); void SHA512_Update(SHA512_CTX*, void*, size_t); void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); unsigned char *SHA512(void* data, unsigned int data_len, unsigned char *digest); #endif /* COMPAT_SHA512 */ #ifndef HAVE_INET_PTON int inet_pton(int af, const char* src, void* dst); #endif /* HAVE_INET_PTON */ #ifndef HAVE_INET_NTOP const char *inet_ntop(int af, const void *src, char *dst, size_t size); #endif #ifdef __cplusplus } #endif /** Use on-board gldns */ #define USE_GLDNS 1 #ifdef HAVE_SSL # define GLDNS_BUILD_CONFIG_HAVE_SSL 1 #endif #ifdef HAVE_STDARG_H #include #endif #include #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #ifdef HAVE_OPENSSL_SSL_H #include #endif #ifdef HAVE_ATTR_FORMAT # define ATTR_FORMAT(archetype, string_index, first_to_check) \ __attribute__ ((format (archetype, string_index, first_to_check))) #else /* !HAVE_ATTR_FORMAT */ # define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */ #endif /* !HAVE_ATTR_FORMAT */ #if defined(DOXYGEN) # define ATTR_UNUSED(x) x #elif defined(__cplusplus) # define ATTR_UNUSED(x) #elif defined(HAVE_ATTR_UNUSED) # define ATTR_UNUSED(x) x __attribute__((unused)) #else /* !HAVE_ATTR_UNUSED */ # define ATTR_UNUSED(x) x #endif /* !HAVE_ATTR_UNUSED */ #ifdef TIME_WITH_SYS_TIME # include # include #else # ifdef HAVE_SYS_TIME_H # include # else # include # endif #endif #ifdef HAVE_LIBUNBOUND #include #endif getdns-0.9.0/src/version.c.in0000664000175100017510000000370512641212403012756 00000000000000/** * * /brief function for returning version info about the library and the API * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include const char *getdns_get_version(void) { return "@GETDNS_VERSION@"; } uint32_t getdns_get_version_number(void) { return @GETDNS_NUMERIC_VERSION@; } const char *getdns_get_api_version(void) { return "@API_VERSION@"; } uint32_t getdns_get_api_version_number(void) { return @API_NUMERIC_VERSION@; } /* version.c */ getdns-0.9.0/src/context.c0000664000175100017510000031336612641212403012357 00000000000000/** * * \file context.c * @brief getdns context management functions * * Declarations taken from the getdns API description pseudo implementation. * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #ifndef USE_WINSOCK #include #include #include #else #include #include typedef unsigned short in_port_t; #endif #include #include #include #include #include #include #include "config.h" #include "debug.h" #include "gldns/str2wire.h" #include "gldns/wire2str.h" #include "context.h" #include "types-internal.h" #include "util-internal.h" #include "dnssec.h" #include "stub.h" #include "list.h" #include "dict.h" #include "pubkey-pinning.h" #define GETDNS_PORT_ZERO 0 #define GETDNS_PORT_DNS 53 #define GETDNS_PORT_DNS_OVER_TLS 853 #define GETDNS_STR_PORT_ZERO "0" #define GETDNS_STR_PORT_DNS "53" #define GETDNS_STR_PORT_DNS_OVER_TLS "853" void *plain_mem_funcs_user_arg = MF_PLAIN; typedef struct host_name_addrs { _getdns_rbnode_t node; getdns_list *ipv4addrs; getdns_list *ipv6addrs; uint8_t host_name[]; } host_name_addrs; /* If changing these lists also remember to change the value of GETDNS_UPSTREAM_TRANSPORTS */ static getdns_transport_list_t getdns_upstream_transports[GETDNS_UPSTREAM_TRANSPORTS] = { GETDNS_TRANSPORT_TCP, GETDNS_TRANSPORT_TLS, }; static in_port_t getdns_port_array[GETDNS_UPSTREAM_TRANSPORTS] = { GETDNS_PORT_DNS, GETDNS_PORT_DNS_OVER_TLS }; static char* getdns_port_str_array[] = { GETDNS_STR_PORT_DNS, GETDNS_STR_PORT_DNS_OVER_TLS }; static const uint8_t no_suffixes[] = { 1, 0 }; /* Private functions */ static getdns_return_t create_default_namespaces(struct getdns_context *context); static getdns_return_t create_default_dns_transports(struct getdns_context *context); static int transaction_id_cmp(const void *, const void *); static void dispatch_updated(struct getdns_context *, uint16_t); static void cancel_dns_req(getdns_dns_req *); static void cancel_outstanding_requests(struct getdns_context*, int); /* unbound helpers */ #ifdef HAVE_LIBUNBOUND static getdns_return_t rebuild_ub_ctx(struct getdns_context* context); static void set_ub_string_opt(struct getdns_context *, char *, char *); static void set_ub_number_opt(struct getdns_context *, char *, uint16_t); static getdns_return_t set_ub_dns_transport(struct getdns_context*); static void set_ub_limit_outstanding_queries(struct getdns_context*, uint16_t); static void set_ub_dnssec_allowed_skew(struct getdns_context*, uint32_t); static void set_ub_edns_maximum_udp_payload_size(struct getdns_context*, int); #endif /* Stuff to make it compile pedantically */ #define RETURN_IF_NULL(ptr, code) if(ptr == NULL) return code; static void destroy_local_host(_getdns_rbnode_t * node, void *arg) { getdns_context *context = (getdns_context *)arg; host_name_addrs *hnas = (host_name_addrs *)node; getdns_list_destroy(hnas->ipv4addrs); getdns_list_destroy(hnas->ipv6addrs); GETDNS_FREE(context->my_mf, hnas); } /** * Helper to get default lookup namespaces. * TODO: Determine from OS */ static getdns_return_t create_default_namespaces(struct getdns_context *context) { context->namespaces = GETDNS_XMALLOC(context->my_mf, getdns_namespace_t, 2); if(context->namespaces == NULL) return GETDNS_RETURN_GENERIC_ERROR; context->namespaces[0] = GETDNS_NAMESPACE_LOCALNAMES; context->namespaces[1] = GETDNS_NAMESPACE_DNS; context->namespace_count = 2; return GETDNS_RETURN_GOOD; } /** * Helper to get default transports. */ static getdns_return_t create_default_dns_transports(struct getdns_context *context) { context->dns_transports = GETDNS_XMALLOC(context->my_mf, getdns_transport_list_t, 2); if(context->dns_transports == NULL) return GETDNS_RETURN_GENERIC_ERROR; context->dns_transports[0] = GETDNS_TRANSPORT_UDP; context->dns_transports[1] = GETDNS_TRANSPORT_TCP; context->dns_transport_count = 2; context->dns_transport_current = 0; return GETDNS_RETURN_GOOD; } static inline void canonicalize_dname(uint8_t *dname) { uint8_t *next_label; while (*dname && !(*dname & 0xC0)) { next_label = dname + *dname + 1; dname += 1; while (dname < next_label) { *dname = (uint8_t)tolower((unsigned char)*dname); dname++; } } } static int canonical_dname_compare(register const uint8_t *d1, register const uint8_t *d2) { register uint8_t lab1, lab2; assert(d1 && d2); lab1 = *d1++; lab2 = *d2++; while (lab1 != 0 || lab2 != 0) { /* compare label length */ /* if one dname ends, it has labellength 0 */ if (lab1 != lab2) { if (lab1 < lab2) return -1; return 1; } while (lab1--) { /* compare bytes first for speed */ if (*d1 != *d2) { if (*d1 < *d2) return -1; return 1; } d1++; d2++; } /* next pair of labels. */ lab1 = *d1++; lab2 = *d2++; } return 0; } static int local_host_cmp(const void *id1, const void *id2) { return canonical_dname_compare(id1, id2); } static void add_local_host(getdns_context *context, getdns_dict *address, const char *str) { uint8_t host_name[256]; size_t host_name_len = sizeof(host_name); host_name_addrs *hnas; getdns_bindata *address_type; int hnas_found = 0; getdns_list **addrs; if (gldns_str2wire_dname_buf(str, host_name, &host_name_len)) return; canonicalize_dname(host_name); if (!(hnas = (host_name_addrs *)_getdns_rbtree_search( &context->local_hosts, host_name))) { if (!(hnas = (host_name_addrs *)GETDNS_XMALLOC(context->mf, uint8_t, sizeof(host_name_addrs) + host_name_len))) return; hnas->ipv4addrs = NULL; hnas->ipv6addrs = NULL; (void)memcpy(hnas->host_name, host_name, host_name_len); hnas->node.key = &hnas->host_name; } else hnas_found = 1; if (getdns_dict_get_bindata(address, "address_type", &address_type) || address_type->size < 4 || !(addrs = address_type->data[3] == '4'? &hnas->ipv4addrs : address_type->data[3] == '6'? &hnas->ipv4addrs : NULL)) { if (!hnas_found) GETDNS_FREE(context->mf, hnas); return; } if (!*addrs && !(*addrs = getdns_list_create_with_context(context))) { if (!hnas_found) GETDNS_FREE(context->mf, hnas); return; } if (_getdns_list_append_dict(*addrs, address) && !hnas_found) { getdns_list_destroy(*addrs); GETDNS_FREE(context->mf, hnas); } else if (!hnas_found) (void)_getdns_rbtree_insert(&context->local_hosts, &hnas->node); } static getdns_dict * sockaddr_dict(getdns_context *context, struct sockaddr *sa) { getdns_dict *address = getdns_dict_create_with_context(context); char addrstr[1024], *b; getdns_bindata bindata; uint16_t port; if (!address) return NULL; switch (sa->sa_family) { case AF_INET: if (getdns_dict_util_set_string(address,"address_type","IPv4")) break; bindata.size = 4; bindata.data = (void *)&((struct sockaddr_in*)sa)->sin_addr; if ((getdns_dict_set_bindata(address,"address_data",&bindata))) break; port = ntohs(((struct sockaddr_in *)sa)->sin_port); if (port != GETDNS_PORT_ZERO && port != GETDNS_PORT_DNS && getdns_dict_set_int(address, "port", (uint32_t)port)) break; return address; case AF_INET6: if (getdns_dict_util_set_string(address,"address_type","IPv6")) break; bindata.size = 16; bindata.data = (void *)&((struct sockaddr_in6*)sa)->sin6_addr; if ((getdns_dict_set_bindata(address,"address_data",&bindata))) break; port = ntohs(((struct sockaddr_in6 *)sa)->sin6_port); if (port != GETDNS_PORT_DNS && port != GETDNS_PORT_DNS && getdns_dict_set_int(address, "port", (uint32_t)port)) break; /* Try to get scope_id too */ if (getnameinfo(sa, sizeof(struct sockaddr_in6), addrstr, sizeof(addrstr), NULL, 0, NI_NUMERICHOST)) break; if ((b = strchr(addrstr, '%')) && getdns_dict_util_set_string(address, "scope_id", b+1)) break; return address; default: /* Unknown protocol */ break; } getdns_dict_destroy(address); return NULL; } static getdns_dict * str_addr_dict(getdns_context *context, const char *str) { static struct addrinfo hints = { .ai_family = AF_UNSPEC , .ai_flags = AI_NUMERICHOST }; struct addrinfo *ai; getdns_dict *address; if (getaddrinfo(str, NULL, &hints, &ai)) return NULL; if (!ai) return NULL; address = sockaddr_dict(context, ai->ai_addr); freeaddrinfo(ai); return address; } static void create_local_hosts(getdns_context *context) { /* enough space in buf for longest allowed domain name */ char buf[1024]; char *pos = buf, prev_c, *start_of_word = NULL; FILE *in; int start_of_line = 1; getdns_dict *address = NULL; #ifdef USE_WINSOCK in = fopen("c:\\WINDOWS\\system32\\drivers\\etc\\hosts", "r"); #else in = fopen("/etc/hosts", "r"); #endif while (fgets(pos, (int)(sizeof(buf) - (pos - buf)), in)) { pos = buf; /* Break out of for to read more */ for (;;) { /* Skip whitespace */ while (*pos == ' ' || *pos == '\f' || *pos == '\t' || *pos == '\v') pos++; if (*pos == '\0') { /* End of read data */ pos = buf; goto read_more; } else if (*pos == '#' || *pos == '\r' || *pos == '\n') /* Comments or end of line */ break; /* skip to next line */ assert(*pos && !isspace(*pos)); start_of_word = pos; /* Search for end of word */ while (*pos && !isspace(*pos)) pos++; /* '\0' before whitespace, so either the word did not * fit, or we are at the end of the file. */ if (*pos == '\0') { if (start_of_word == buf) /* word too big */ break; /* skip to next line */ /* Move word to fit in buffer */ memmove(buf,start_of_word,pos - start_of_word); pos = buf + (pos - start_of_word); start_of_word = buf; *pos = '\0'; goto read_more; } assert(isspace(*pos)); prev_c = *pos; *pos = '\0'; if (start_of_line) { start_of_line = 0; if (address) getdns_dict_destroy(address); if (!(address = str_addr_dict(context, start_of_word))) /* Unparseable address */ break; /* skip to next line */ } else add_local_host(context, address, start_of_word); start_of_word = NULL; *pos = prev_c; /* process next word in buf */ } /* skip to next line */ while (*pos != '\r' && *pos != '\n') if (*pos) pos++; else if (!fgets((pos = buf), sizeof(buf), in)) break; /* We're done */ start_of_line = 1; if (address) { getdns_dict_destroy(address); address = NULL; } pos = buf; read_more: ; } fclose(in); if (address) { /* One last name for this address? */ if (start_of_word && !start_of_line) add_local_host(context, address, start_of_word); getdns_dict_destroy(address); } } /** * check a file for changes since the last check * and refresh the current data if changes are detected * @param context pointer to a previously created context to be used for this call * @param fchg file to check * @returns changes as OR'd list of GETDNS_FCHG_* values * @returns GETDNS_FCHG_NONE if no changes * @returns GETDNS_FCHG_ERRORS if problems (see fchg->errors for details) */ int _getdns_filechg_check(struct getdns_context *context, struct filechg *fchg) { struct stat *finfo; if(fchg == NULL) return 0; fchg->errors = GETDNS_FCHG_NOERROR; fchg->changes = GETDNS_FCHG_NOCHANGES; finfo = GETDNS_MALLOC(context->my_mf, struct stat); if(finfo == NULL) { fchg->errors = errno; return GETDNS_FCHG_ERRORS; } if(stat(fchg->fn, finfo) != 0) { GETDNS_FREE(context->my_mf, finfo); fchg->errors = errno; return GETDNS_FCHG_ERRORS; } /* we want to consider a file that previously returned error for stat() as a change */ if(fchg->prevstat == NULL) fchg->changes = GETDNS_FCHG_MTIME | GETDNS_FCHG_CTIME; else { if(fchg->prevstat->st_mtime != finfo->st_mtime) fchg->changes |= GETDNS_FCHG_MTIME; if(fchg->prevstat->st_ctime != finfo->st_ctime) fchg->changes |= GETDNS_FCHG_CTIME; GETDNS_FREE(context->my_mf, fchg->prevstat); } fchg->prevstat = finfo; return fchg->changes; } /* filechg */ static getdns_upstreams * upstreams_create(getdns_context *context, size_t size) { getdns_upstreams *r = (void *) GETDNS_XMALLOC(context->mf, char, sizeof(getdns_upstreams) + sizeof(getdns_upstream) * size); r->mf = context->mf; r->referenced = 1; r->count = 0; r->current = 0; return r; } void _getdns_upstreams_dereference(getdns_upstreams *upstreams) { getdns_upstream *upstream; if (!upstreams || --upstreams->referenced > 0) return; for ( upstream = upstreams->upstreams ; upstreams->count ; upstreams->count--, upstream++ ) { sha256_pin_t *pin = upstream->tls_pubkey_pinset; if (upstream->loop && ( upstream->event.read_cb || upstream->event.write_cb || upstream->event.timeout_cb) ) { GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event); upstream->event.read_cb = NULL; upstream->event.write_cb = NULL; upstream->event.timeout_cb = NULL; } if (upstream->tls_obj != NULL) { SSL_shutdown(upstream->tls_obj); SSL_free(upstream->tls_obj); } if (upstream->fd != -1) close(upstream->fd); while (pin) { sha256_pin_t *nextpin = pin->next; GETDNS_FREE(upstreams->mf, pin); pin = nextpin; } upstream->tls_pubkey_pinset = NULL; } GETDNS_FREE(upstreams->mf, upstreams); } void _getdns_upstream_shutdown(getdns_upstream *upstream) { /*There is a race condition with a new request being scheduled while this happens so take ownership of the fd asap*/ int fd = upstream->fd; upstream->fd = -1; /* If the connection had a problem, but had worked this time, * then allow re-use in the future*/ if (upstream->tcp.write_error == 1 && upstream->responses_received > 0) upstream->tcp.write_error = 0; upstream->writes_done = 0; upstream->responses_received = 0; upstream->keepalive_timeout = 0; if (upstream->tls_hs_state != GETDNS_HS_FAILED) { upstream->tls_hs_state = GETDNS_HS_NONE; upstream->tls_auth_failed = 0; } /* Now TLS stuff*/ if (upstream->tls_obj != NULL) { SSL_shutdown(upstream->tls_obj); SSL_free(upstream->tls_obj); upstream->tls_obj = NULL; } if (fd != -1) close(fd); } static int tls_is_in_transports_list(getdns_context *context) { for (int i=0; i< context->dns_transport_count;i++) { if (context->dns_transports[i] == GETDNS_TRANSPORT_TLS) return 1; } return 0; } static int tls_only_is_in_transports_list(getdns_context *context) { if (context->dns_transport_count != 1) return 0; if (context->dns_transports[0] == GETDNS_TRANSPORT_TLS) return 1; return 0; } static int net_req_query_id_cmp(const void *id1, const void *id2) { return (intptr_t)id1 - (intptr_t)id2; } static getdns_tsig_info const tsig_info[] = { { GETDNS_NO_TSIG, NULL, 0, NULL, 0, 0, 0 } , { GETDNS_HMAC_MD5 , "hmac-md5.sig-alg.reg.int", 24 , (uint8_t *)"\x08hmac-md5\x07sig-alg\x03reg\x03int", 26, 10, 16 } , { GETDNS_NO_TSIG, NULL, 0, NULL, 0, 0, 0 } , { GETDNS_HMAC_SHA1 , "hmac-sha1" , 9 , (uint8_t *)"\x09hmac-sha1" , 11, 10, 20 } , { GETDNS_HMAC_SHA224, "hmac-sha224", 11 , (uint8_t *)"\x0bhmac-sha224", 13, 14, 28 } , { GETDNS_HMAC_SHA256, "hmac-sha256", 11 , (uint8_t *)"\x0bhmac-sha256", 13, 16, 32 } , { GETDNS_HMAC_SHA384, "hmac-sha384", 11 , (uint8_t *)"\x0bhmac-sha384", 13, 24, 48 } , { GETDNS_HMAC_SHA512, "hmac-sha512", 11 , (uint8_t *)"\x0bhmac-sha512", 13, 32, 64 } , { GETDNS_HMAC_MD5 , "hmac-md5" , 8 , (uint8_t *)"\x08hmac-md5" , 10, 10, 16 } }; static size_t const n_tsig_infos = sizeof(tsig_info) / sizeof(getdns_tsig_info); static getdns_tsig_info const * const last_tsig_info = tsig_info + (sizeof(tsig_info) / sizeof(getdns_tsig_info)); const getdns_tsig_info *_getdns_get_tsig_info(getdns_tsig_algo tsig_alg) { return tsig_alg > n_tsig_infos - 1 || tsig_info[tsig_alg].alg == GETDNS_NO_TSIG ? NULL : &tsig_info[tsig_alg]; } static getdns_tsig_algo _getdns_get_tsig_algo(getdns_bindata *algo) { const getdns_tsig_info *i; if (!algo || algo->size == 0) return GETDNS_NO_TSIG; if (algo->data[algo->size-1] != 0) { /* Unterminated string */ for (i = tsig_info; i < last_tsig_info; i++) if ((algo->size == i->strlen_name || (algo->size - 1 == i->strlen_name && algo->data[algo->size - 1] == '.' ) )&& strncasecmp((const char *)algo->data, i->name, i->strlen_name) == 0) return i->alg; } else if (!_getdns_bindata_is_dname(algo)) { /* Terminated string */ for (i = tsig_info; i < last_tsig_info; i++) if (algo->size - 1 == i->strlen_name && strncasecmp((const char *)algo->data, i->name, i->strlen_name) == 0) return i->alg; } else { /* fqdn, canonical_dname_compare is now safe to use! */ for (i = tsig_info; i < last_tsig_info; i++) if (canonical_dname_compare(algo->data, i->dname) == 0) return i->alg; } return GETDNS_NO_TSIG; } static void upstream_init(getdns_upstream *upstream, getdns_upstreams *parent, struct addrinfo *ai) { upstream->upstreams = parent; upstream->addr_len = ai->ai_addrlen; (void) memcpy(&upstream->addr, ai->ai_addr, ai->ai_addrlen); /* How is this upstream doing? */ upstream->writes_done = 0; upstream->responses_received = 0; upstream->keepalive_timeout = 0; upstream->to_retry = 2; upstream->back_off = 1; /* For sharing a socket to this upstream with TCP */ upstream->fd = -1; upstream->tls_obj = NULL; upstream->transport = GETDNS_TRANSPORT_TCP; upstream->tls_hs_state = GETDNS_HS_NONE; upstream->tls_auth_failed = 0; upstream->tls_auth_name[0] = '\0'; upstream->tls_pubkey_pinset = NULL; upstream->tcp.write_error = 0; upstream->loop = NULL; (void) getdns_eventloop_event_init( &upstream->event, upstream, NULL, NULL, NULL); (void) memset(&upstream->tcp, 0, sizeof(upstream->tcp)); upstream->write_queue = NULL; upstream->write_queue_last = NULL; upstream->has_client_cookie = 0; upstream->has_prev_client_cookie = 0; upstream->has_server_cookie = 0; upstream->tsig_alg = GETDNS_NO_TSIG; upstream->tsig_dname_len = 0; upstream->tsig_size = 0; /* Tracking of network requests on this socket */ _getdns_rbtree_init(&upstream->netreq_by_query_id, net_req_query_id_cmp); } #ifdef USE_WINSOCK static getdns_return_t set_os_defaults_windows(struct getdns_context *context) { char domain[1024] = ""; size_t upstreams_limit = 10; struct addrinfo hints; struct addrinfo *result; getdns_upstream *upstream; int s; if (context->fchg_resolvconf == NULL) { context->fchg_resolvconf = GETDNS_MALLOC(context->my_mf, struct filechg); if (context->fchg_resolvconf == NULL) return GETDNS_RETURN_MEMORY_ERROR; context->fchg_resolvconf->fn = "InvalidOnWindows"; context->fchg_resolvconf->prevstat = NULL; context->fchg_resolvconf->changes = GETDNS_FCHG_NOCHANGES; context->fchg_resolvconf->errors = GETDNS_FCHG_NOERROR; } _getdns_filechg_check(context, context->fchg_resolvconf); context->upstreams = upstreams_create(context, upstreams_limit); memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ hints.ai_socktype = 0; /* Datagram socket */ hints.ai_flags = AI_NUMERICHOST; /* No reverse name lookups */ hints.ai_protocol = 0; /* Any protocol */ hints.ai_canonname = NULL; hints.ai_addr = NULL; hints.ai_next = NULL; FIXED_INFO *info; ULONG buflen = sizeof(*info); IP_ADDR_STRING *ptr = 0; info = (FIXED_INFO *)malloc(sizeof(FIXED_INFO)); if (info == NULL) return GETDNS_RETURN_GENERIC_ERROR; if (GetNetworkParams(info, &buflen) == ERROR_BUFFER_OVERFLOW) { free(info); info = (FIXED_INFO *)malloc(buflen); if (info == NULL) return GETDNS_RETURN_GENERIC_ERROR; } if (GetNetworkParams(info, &buflen) == NO_ERROR) { ptr = info->DnsServerList.Next; *domain = 0; while (ptr) { for (size_t i = 0; i < GETDNS_UPSTREAM_TRANSPORTS; i++) { char *port_str = getdns_port_str_array[i]; if ((s = getaddrinfo(ptr->IpAddress.String, port_str, &hints, &result))) continue; if (!result) continue; upstream = &context->upstreams-> upstreams[context->upstreams->count++]; upstream_init(upstream, context->upstreams, result); upstream->transport = getdns_upstream_transports[i]; freeaddrinfo(result); } ptr = ptr->Next; } free(info); } return GETDNS_RETURN_GOOD; } /* set_os_defaults_windows */ #else static getdns_return_t set_os_defaults(struct getdns_context *context) { FILE *in; char line[1024], domain[1024]; char *parse, *token, prev_ch; size_t upstream_count, length; struct addrinfo hints; struct addrinfo *result; getdns_upstream *upstream; getdns_list *suffix; int s; if(context->fchg_resolvconf == NULL) { context->fchg_resolvconf = GETDNS_MALLOC(context->my_mf, struct filechg); if(context->fchg_resolvconf == NULL) return GETDNS_RETURN_MEMORY_ERROR; context->fchg_resolvconf->fn = "/etc/resolv.conf"; context->fchg_resolvconf->prevstat = NULL; context->fchg_resolvconf->changes = GETDNS_FCHG_NOCHANGES; context->fchg_resolvconf->errors = GETDNS_FCHG_NOERROR; } _getdns_filechg_check(context, context->fchg_resolvconf); in = fopen(context->fchg_resolvconf->fn, "r"); if (!in) return GETDNS_RETURN_GOOD; upstream_count = 0; while (fgets(line, (int)sizeof(line), in)) if (strncmp(line, "nameserver", 10) == 0) upstream_count++; fclose(in); suffix = getdns_list_create_with_context(context); context->upstreams = upstreams_create( context, upstream_count * GETDNS_UPSTREAM_TRANSPORTS); in = fopen(context->fchg_resolvconf->fn, "r"); if (!in) return GETDNS_RETURN_GOOD; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ hints.ai_socktype = 0; /* Datagram socket */ hints.ai_flags = AI_NUMERICHOST; /* No reverse name lookups */ hints.ai_protocol = 0; /* Any protocol */ hints.ai_canonname = NULL; hints.ai_addr = NULL; hints.ai_next = NULL; *domain = 0; while (fgets(line, (int)sizeof(line), in)) { line[sizeof(line)-1] = 0; /* parse = line + strspn(line, " \t"); */ /* No leading whitespace */ parse = line; if (strncmp(parse, "domain", 6) == 0) { parse += 6; parse += strspn(parse, " \t"); if (*parse == 0 || *parse == '#') continue; token = parse + strcspn(parse, " \t\r\n"); *token = 0; (void) strlcpy(domain, parse, sizeof(domain)); } else if (strncmp(parse, "search", 6) == 0) { parse += 6; do { parse += strspn(parse, " \t"); if (*parse == '#' || *parse == '\n') break; token = parse + strcspn(parse, " \t\r\n"); prev_ch = *token; *token = 0; _getdns_list_append_string(suffix, parse); *token = prev_ch; parse = token; } while (*parse); } else if (strncmp(parse, "nameserver", 10) != 0) continue; parse += 10; parse += strspn(parse, " \t"); if (*parse == 0 || *parse == '#') continue; token = parse + strcspn(parse, " \t\r\n"); *token = 0; for (size_t i = 0; i < GETDNS_UPSTREAM_TRANSPORTS; i++) { char *port_str = getdns_port_str_array[i]; if ((s = getaddrinfo(parse, port_str, &hints, &result))) continue; if (!result) continue; upstream = &context->upstreams-> upstreams[context->upstreams->count++]; upstream_init(upstream, context->upstreams, result); upstream->transport = getdns_upstream_transports[i]; freeaddrinfo(result); } } fclose(in); (void) getdns_list_get_length(suffix, &length); if (length == 0 && *domain != 0) _getdns_list_append_string(suffix, domain); (void )getdns_context_set_suffix(context, suffix); getdns_list_destroy(suffix); return GETDNS_RETURN_GOOD; } /* set_os_defaults */ #endif /* compare of transaction ids in DESCENDING order so that 0 comes last */ static int transaction_id_cmp(const void *id1, const void *id2) { if (id1 == NULL && id2 == NULL) { return 0; } else if (id1 == NULL && id2 != NULL) { return 1; } else if (id1 != NULL && id2 == NULL) { return -1; } else { getdns_transaction_t t1 = *((const getdns_transaction_t *) id1); getdns_transaction_t t2 = *((const getdns_transaction_t *) id2); if (t1 == t2) { return 0; } else if (t1 > t2) { return -1; } else { return 1; } } } static void NULL_update_callback( getdns_context *context, getdns_context_code_t code, void *userarg) { (void)context; (void)code; (void)userarg; } /* * getdns_context_create * * Call this to initialize the context that is used in other getdns calls. */ getdns_return_t getdns_context_create_with_extended_memory_functions( struct getdns_context ** context, int set_from_os, void *userarg, void *(*malloc)(void *userarg, size_t), void *(*realloc)(void *userarg, void *, size_t), void (*free)(void *userarg, void *) ) { getdns_return_t r; struct getdns_context *result = NULL; mf_union mf; gldns_buffer gbuf; if (!context || !malloc || !realloc || !free) return GETDNS_RETURN_INVALID_PARAMETER; /** default init **/ mf.ext.malloc = malloc; result = userarg == MF_PLAIN ? (*mf.pln.malloc)( sizeof(struct getdns_context)) : (*mf.ext.malloc)(userarg, sizeof(struct getdns_context)); if (!result) return GETDNS_RETURN_MEMORY_ERROR; result->processing = 0; result->destroying = 0; result->my_mf.mf_arg = userarg; result->my_mf.mf.ext.malloc = malloc; result->my_mf.mf.ext.realloc = realloc; result->my_mf.mf.ext.free = free; result->update_callback = NULL; result->update_callback2 = NULL_update_callback; result->update_userarg = NULL; result->mf.mf_arg = userarg; result->mf.mf.ext.malloc = malloc; result->mf.mf.ext.realloc = realloc; result->mf.mf.ext.free = free; result->resolution_type_set = 0; _getdns_rbtree_init(&result->outbound_requests, transaction_id_cmp); _getdns_rbtree_init(&result->local_hosts, local_host_cmp); #ifdef HAVE_LIBUNBOUND result->resolution_type = GETDNS_RESOLUTION_RECURSING; #else result->resolution_type = GETDNS_RESOLUTION_STUB; #endif if ((r = create_default_namespaces(result))) goto error; result->timeout = 5000; result->idle_timeout = 0; result->follow_redirects = GETDNS_REDIRECTS_FOLLOW; result->dns_root_servers = NULL; result->root_servers_fn[0] = 0; result->append_name = GETDNS_APPEND_NAME_ALWAYS; result->suffixes = no_suffixes; result->suffixes_len = sizeof(no_suffixes); gldns_buffer_init_frm_data(&gbuf, result->trust_anchors_spc , sizeof(result->trust_anchors_spc)); if (!_getdns_parse_ta_file(NULL, &gbuf)) { result->trust_anchors = NULL; result->trust_anchors_len = 0; } else if ((result->trust_anchors_len = gldns_buffer_position(&gbuf)) > sizeof(result->trust_anchors_spc)) { if ((result->trust_anchors = GETDNS_XMALLOC( result->mf, uint8_t, result->trust_anchors_len))) { gldns_buffer_init_frm_data(&gbuf , result->trust_anchors , result->trust_anchors_len); if (!_getdns_parse_ta_file(NULL, &gbuf)) { result->trust_anchors = NULL; result->trust_anchors_len = 0; } } } else result->trust_anchors = result->trust_anchors_spc; result->upstreams = NULL; result->edns_extended_rcode = 0; result->edns_version = 0; result->edns_do_bit = 0; result->edns_client_subnet_private = 0; result->tls_query_padding_blocksize = 1; /* default is to not try to pad */ result-> tls_ctx = NULL; result->extension = &result->mini_event.loop; if ((r = _getdns_mini_event_init(result, &result->mini_event))) goto error; result->fchg_resolvconf = NULL; result->fchg_hosts = NULL; // resolv.conf does not exist on Windows, handle differently #ifndef USE_WINSOCK if (set_from_os && (r = set_os_defaults(result))) goto error; #else if (set_from_os && (r = set_os_defaults_windows(result))) goto error; #endif result->dnssec_allowed_skew = 0; result->edns_maximum_udp_payload_size = -1; if ((r = create_default_dns_transports(result))) goto error; result->tls_auth = GETDNS_AUTHENTICATION_NONE; result->tls_auth_min = GETDNS_AUTHENTICATION_NONE; result->limit_outstanding_queries = 0; result->return_dnssec_status = GETDNS_EXTENSION_FALSE; /* unbound context is initialized here */ /* Unbound needs SSL to be init'ed this early when TLS is used. However we * don't know that till later so we will have to do this every time. */ SSL_library_init(); #ifdef HAVE_LIBUNBOUND result->unbound_ctx = NULL; if ((r = rebuild_ub_ctx(result))) goto error; #endif create_local_hosts(result); *context = result; return GETDNS_RETURN_GOOD; error: getdns_context_destroy(result); return r; } /* getdns_context_create_with_extended_memory_functions */ /* * getdns_context_create * * Call this to initialize the context that is used in other getdns calls. */ getdns_return_t getdns_context_create_with_memory_functions(struct getdns_context ** context, int set_from_os, void *(*malloc)(size_t), void *(*realloc)(void *, size_t), void (*free)(void *) ) { mf_union mf; mf.pln.malloc = malloc; mf.pln.realloc = realloc; mf.pln.free = free; return getdns_context_create_with_extended_memory_functions( context, set_from_os, MF_PLAIN, mf.ext.malloc, mf.ext.realloc, mf.ext.free); } /* getdns_context_create */ /* * getdns_context_create * * Call this to initialize the context that is used in other getdns calls. */ getdns_return_t getdns_context_create(struct getdns_context ** context, int set_from_os) { return getdns_context_create_with_memory_functions(context, set_from_os, malloc, realloc, free); } /* getdns_context_create */ /* * getdns_context_destroy * * Call this to dispose of resources associated with a context once you * are done with it. */ void getdns_context_destroy(struct getdns_context *context) { if (context == NULL) return; /* If being destroyed during getdns callback, fail via assert */ assert(context->processing == 0); if (context->destroying) return; context->destroying = 1; /* cancel all outstanding requests */ cancel_outstanding_requests(context, 1); /* This needs to be done before cleaning the extension, because there * might be an idle_timeout schedules, which will not get unscheduled * with cancel_outstanding_requests. */ _getdns_upstreams_dereference(context->upstreams); #ifdef HAVE_LIBUNBOUND if (context->unbound_ctx) ub_ctx_delete(context->unbound_ctx); #endif context->extension->vmt->cleanup(context->extension); if (context->namespaces) GETDNS_FREE(context->my_mf, context->namespaces); if (context->dns_transports) GETDNS_FREE(context->my_mf, context->dns_transports); if(context->fchg_resolvconf) { if(context->fchg_resolvconf->prevstat) GETDNS_FREE(context->my_mf, context->fchg_resolvconf->prevstat); GETDNS_FREE(context->my_mf, context->fchg_resolvconf); } if(context->fchg_hosts) { if(context->fchg_hosts->prevstat) GETDNS_FREE(context->my_mf, context->fchg_hosts->prevstat); GETDNS_FREE(context->my_mf, context->fchg_hosts); } if (context->tls_ctx) SSL_CTX_free(context->tls_ctx); if (context->dns_root_servers) getdns_list_destroy(context->dns_root_servers); if (context->root_servers_fn[0]) unlink(context->root_servers_fn); if (context->suffixes && context->suffixes != no_suffixes) GETDNS_FREE(context->mf, (void *)context->suffixes); if (context->trust_anchors && context->trust_anchors != context->trust_anchors_spc) GETDNS_FREE(context->mf, context->trust_anchors); _getdns_traverse_postorder(&context->local_hosts, destroy_local_host, context); GETDNS_FREE(context->my_mf, context); } /* getdns_context_destroy */ /* * getdns_context_set_context_update_callback * */ getdns_return_t getdns_context_set_context_update_callback(struct getdns_context *context, void (*value) (struct getdns_context *context, getdns_context_code_t changed_item)) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); context->update_callback = value; return GETDNS_RETURN_GOOD; } /* getdns_context_set_context_update_callback */ getdns_return_t getdns_context_set_update_callback(getdns_context *context, void *userarg, void (*cb)(getdns_context *, getdns_context_code_t, void *)) { if (!context) return GETDNS_RETURN_INVALID_PARAMETER; context->update_userarg = userarg; context->update_callback2 = cb ? cb : NULL_update_callback; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_update_callback(getdns_context *context, void **userarg, void (**cb)(getdns_context *, getdns_context_code_t, void *)) { if (!context || !userarg || !cb) return GETDNS_RETURN_INVALID_PARAMETER; *userarg = context->update_userarg; *cb = context->update_callback2; return GETDNS_RETURN_GOOD; } #ifdef HAVE_LIBUNBOUND /* * Helpers to set options on the unbound ctx */ static void set_ub_string_opt(struct getdns_context *ctx, char *opt, char *value) { if (ctx->unbound_ctx) ub_ctx_set_option(ctx->unbound_ctx, opt, value); } static void set_ub_number_opt(struct getdns_context *ctx, char *opt, uint16_t value) { char buffer[64]; snprintf(buffer, 64, "%hu", value); set_ub_string_opt(ctx, opt, buffer); } static void getdns_context_request_count_changed(getdns_context *context) { DEBUG_SCHED("getdns_context_request_count_changed(%d)\n", (int) context->outbound_requests.count); if (context->outbound_requests.count) { if (context->ub_event.ev) return; DEBUG_SCHED("gc_request_count_changed " "-> ub schedule(el_ev = %p, el_ev->ev = %p)\n", &context->ub_event, context->ub_event.ev); context->extension->vmt->schedule( context->extension, ub_fd(context->unbound_ctx), TIMEOUT_FOREVER, &context->ub_event); } else if (context->ub_event.ev) /* Only test if count == 0! */ { DEBUG_SCHED("gc_request_count_changed " "-> ub clear(el_ev = %p, el_ev->ev = %p)\n", &context->ub_event, context->ub_event.ev); context->extension->vmt->clear( context->extension, &context->ub_event); } } void _getdns_context_ub_read_cb(void *userarg) { getdns_context *context = (getdns_context *)userarg; /* getdns_context_process_async, but without reinvoking an eventloop * (with context->extension->vmt->run*), because we are already * called from a running eventloop. */ if (ub_poll(context->unbound_ctx)) (void) ub_process(context->unbound_ctx); /* No need to handle timeouts. They are handled by the extension. */ getdns_context_request_count_changed(context); } static getdns_return_t rebuild_ub_ctx(struct getdns_context* context) { if (context->unbound_ctx != NULL) { /* cancel all requests and delete */ cancel_outstanding_requests(context, 1); ub_ctx_delete(context->unbound_ctx); context->unbound_ctx = NULL; } /* setup */ context->unbound_ctx = ub_ctx_create(); (void) ub_ctx_async(context->unbound_ctx, 1); context->unbound_ta_set = 0; if (!context->unbound_ctx) { return GETDNS_RETURN_MEMORY_ERROR; } set_ub_dnssec_allowed_skew(context, context->dnssec_allowed_skew); set_ub_edns_maximum_udp_payload_size(context, context->edns_maximum_udp_payload_size); set_ub_dns_transport(context); context->ub_event.userarg = context; context->ub_event.read_cb = _getdns_context_ub_read_cb; context->ub_event.write_cb = NULL; context->ub_event.timeout_cb = NULL; context->ub_event.ev = NULL; return GETDNS_RETURN_GOOD; } #else #define set_ub_string_opt(ctx, opt, value) do {} while (0) #define set_ub_number_opt(ctx, opt, value) do {} while (0) #define getdns_context_request_count_changed(context) do {} while (0) #endif /** * Helper to dispatch the updated callback */ static void dispatch_updated(struct getdns_context *context, uint16_t item) { if (context->update_callback2 != NULL_update_callback) context->update_callback2( context, item, context->update_userarg); if (context->update_callback) { context->update_callback(context, item); } } /* * getdns_context_set_resolution_type * */ getdns_return_t getdns_context_set_resolution_type(struct getdns_context *context, getdns_resolution_t value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); if (value != GETDNS_RESOLUTION_STUB && value != GETDNS_RESOLUTION_RECURSING) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } #ifndef HAVE_LIBUNBOUND if (value == GETDNS_RESOLUTION_RECURSING) return GETDNS_RETURN_NOT_IMPLEMENTED; #endif #ifndef STUB_NATIVE_DNSSEC if (context->resolution_type_set != 0) { /* already setup */ return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } #endif context->resolution_type = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_RESOLUTION_TYPE); return GETDNS_RETURN_GOOD; } /* getdns_context_set_resolution_type */ /* * getdns_context_set_namespaces * */ getdns_return_t getdns_context_set_namespaces(getdns_context *context, size_t namespace_count, getdns_namespace_t *namespaces) { size_t i; getdns_return_t r = GETDNS_RETURN_GOOD; if (!context) return GETDNS_RETURN_INVALID_PARAMETER; if (namespace_count == 0 || namespaces == NULL) return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; for (i = 0; i < namespace_count; i++) { if (namespaces[i] == GETDNS_NAMESPACE_NETBIOS || namespaces[i] == GETDNS_NAMESPACE_MDNS || namespaces[i] == GETDNS_NAMESPACE_NIS) r = GETDNS_RETURN_NOT_IMPLEMENTED; else if (namespaces[i] != GETDNS_NAMESPACE_DNS && namespaces[i] != GETDNS_NAMESPACE_LOCALNAMES) return GETDNS_RETURN_INVALID_PARAMETER; } GETDNS_FREE(context->my_mf, context->namespaces); /** duplicate **/ context->namespaces = GETDNS_XMALLOC( context->my_mf, getdns_namespace_t, namespace_count); (void) memcpy(context->namespaces, namespaces, namespace_count * sizeof(getdns_namespace_t)); context->namespace_count = namespace_count; dispatch_updated(context, GETDNS_CONTEXT_CODE_NAMESPACES); return r; } /* getdns_context_set_namespaces */ static getdns_return_t getdns_set_base_dns_transports( getdns_context *context, size_t transport_count, getdns_transport_list_t *transports) { size_t i; getdns_transport_list_t *new_transports; if (!context || transport_count == 0 || transports == NULL) return GETDNS_RETURN_INVALID_PARAMETER; /* Check for valid transports and that they are used only once*/ int u=0,t=0,l=0; for(i=0; i1 || t>1 || l>1) return GETDNS_RETURN_INVALID_PARAMETER; if (!(new_transports = GETDNS_XMALLOC(context->my_mf, getdns_transport_list_t, transport_count))) return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; if (context->dns_transports) GETDNS_FREE(context->my_mf, context->dns_transports); /** duplicate **/ context->dns_transports = new_transports; memcpy(context->dns_transports, transports, transport_count * sizeof(getdns_transport_list_t)); context->dns_transport_count = transport_count; return GETDNS_RETURN_GOOD; } static getdns_return_t set_ub_dns_transport(struct getdns_context* context) { /* These mappings are not exact because Unbound is configured differently, so just map as close as possible. Not all options can be supported.*/ switch (context->dns_transports[0]) { case GETDNS_TRANSPORT_UDP: set_ub_string_opt(context, "do-udp:", "yes"); if (context->dns_transport_count > 1 && context->dns_transports[1] == GETDNS_TRANSPORT_TCP) set_ub_string_opt(context, "do-tcp:", "yes"); else set_ub_string_opt(context, "do-tcp:", "no"); break; case GETDNS_TRANSPORT_TCP: set_ub_string_opt(context, "do-udp:", "no"); set_ub_string_opt(context, "do-tcp:", "yes"); break; case GETDNS_TRANSPORT_TLS: set_ub_string_opt(context, "do-udp:", "no"); set_ub_string_opt(context, "do-tcp:", "yes"); /* Find out if there is a fallback available. */ int fallback = 0; for (size_t i = 1; i < context->dns_transport_count; i++) { if (context->dns_transports[i] == GETDNS_TRANSPORT_TCP) { fallback = 1; break; } else if (context->dns_transports[i] == GETDNS_TRANSPORT_UDP) { set_ub_string_opt(context, "do-udp:", "yes"); set_ub_string_opt(context, "do-tcp:", "no"); fallback = 1; break; } } if (fallback == 0) /* Use TLS if it is the only thing.*/ set_ub_string_opt(context, "ssl-upstream:", "yes"); break; default: return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } return GETDNS_RETURN_GOOD; } /* * getdns_context_set_dns_transport * */ getdns_return_t getdns_context_set_dns_transport( getdns_context *context, getdns_transport_t value) { size_t count = 2; getdns_transport_list_t *new_transports; if (value == GETDNS_TRANSPORT_UDP_ONLY || value == GETDNS_TRANSPORT_TCP_ONLY || value == GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN || value == GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN) count = 1; if (!context) return GETDNS_RETURN_INVALID_PARAMETER; if (!(new_transports = GETDNS_XMALLOC( context->my_mf, getdns_transport_list_t, count))) return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; if (context->dns_transports) GETDNS_FREE(context->my_mf, context->dns_transports); context->dns_transport_count = count; context->dns_transports = new_transports; switch ((int)value) { case GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP: context->dns_transports[0] = GETDNS_TRANSPORT_UDP; context->dns_transports[1] = GETDNS_TRANSPORT_TCP; break; case GETDNS_TRANSPORT_UDP_ONLY: context->dns_transports[0] = GETDNS_TRANSPORT_UDP; break; case GETDNS_TRANSPORT_TCP_ONLY: case GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN: context->dns_transports[0] = GETDNS_TRANSPORT_TCP; break; case GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN: context->dns_transports[0] = GETDNS_TRANSPORT_TLS; break; case GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN: context->dns_transports[0] = GETDNS_TRANSPORT_TLS; context->dns_transports[1] = GETDNS_TRANSPORT_TCP; break; default: return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } /* Note that the call below does not have any effect in unbound after the * ctx is finalised so for recursive mode or stub + dnssec only the first * transport specified on the first query is used. * However the method returns success as otherwise the transport could not * be reset for stub mode. * Also, not all transport options supported in libunbound yet */ if (set_ub_dns_transport(context) != GETDNS_RETURN_GOOD) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } dispatch_updated(context, GETDNS_CONTEXT_CODE_DNS_TRANSPORT); return GETDNS_RETURN_GOOD; } /* * getdns_context_set_dns_transport_list * */ getdns_return_t getdns_context_set_dns_transport_list(getdns_context *context, size_t transport_count, getdns_transport_list_t *transports) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); if (getdns_set_base_dns_transports(context, transport_count, transports) != GETDNS_RETURN_GOOD) return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; /* Note that the call below does not have any effect in unbound after the * ctx is finalised so for recursive mode or stub + dnssec only the first * transport specified on the first query is used. * However the method returns success as otherwise the transport could not * be reset for stub mode. * Also, not all transport options supported in libunbound yet */ if (set_ub_dns_transport(context) != GETDNS_RETURN_GOOD) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } dispatch_updated(context, GETDNS_CONTEXT_CODE_DNS_TRANSPORT); return GETDNS_RETURN_GOOD; } /* getdns_context_set_dns_transport_list */ /* * getdns_context_set_tls_authentication * */ getdns_return_t getdns_context_set_tls_authentication(getdns_context *context, getdns_tls_authentication_t value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); if (value != GETDNS_AUTHENTICATION_NONE && value != GETDNS_AUTHENTICATION_REQUIRED) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } context->tls_auth = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION); return GETDNS_RETURN_GOOD; } /* getdns_context_set_tls_authentication_list */ static void set_ub_limit_outstanding_queries(struct getdns_context* context, uint16_t value) { /* num-queries-per-thread */ set_ub_number_opt(context, "num-queries-per-thread:", value); } /* * getdns_context_set_limit_outstanding_queries * */ getdns_return_t getdns_context_set_limit_outstanding_queries(struct getdns_context *context, uint16_t limit) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); set_ub_limit_outstanding_queries(context, limit); if (limit != context->limit_outstanding_queries) { context->limit_outstanding_queries = limit; dispatch_updated(context, GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES); } return GETDNS_RETURN_GOOD; } /* getdns_context_set_limit_outstanding_queries */ /* * getdns_context_set_timeout * */ getdns_return_t getdns_context_set_timeout(struct getdns_context *context, uint64_t timeout) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); if (timeout == 0) { return GETDNS_RETURN_INVALID_PARAMETER; } context->timeout = timeout; dispatch_updated(context, GETDNS_CONTEXT_CODE_TIMEOUT); return GETDNS_RETURN_GOOD; } /* getdns_context_set_timeout */ /* * getdns_context_set_idle_timeout * */ getdns_return_t getdns_context_set_idle_timeout(struct getdns_context *context, uint64_t timeout) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); /* Shuold we enforce maximum based on edns-tcp-keepalive spec? */ /* 0 should be allowed as that is the default.*/ context->idle_timeout = timeout; dispatch_updated(context, GETDNS_CONTEXT_CODE_IDLE_TIMEOUT); return GETDNS_RETURN_GOOD; } /* getdns_context_set_timeout */ /* * getdns_context_set_follow_redirects * */ getdns_return_t getdns_context_set_follow_redirects( getdns_context *context, getdns_redirects_t value) { if (!context) return GETDNS_RETURN_INVALID_PARAMETER; if (value != GETDNS_REDIRECTS_FOLLOW && value != GETDNS_REDIRECTS_DO_NOT_FOLLOW) return GETDNS_RETURN_INVALID_PARAMETER; context->follow_redirects = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS); return GETDNS_RETURN_NOT_IMPLEMENTED; } /* getdns_context_set_follow_redirects */ /* * getdns_context_set_dns_root_servers * */ getdns_return_t getdns_context_set_dns_root_servers( getdns_context *context, getdns_list *addresses) { char tmpfn[FILENAME_MAX] = P_tmpdir "/getdns-root-dns-servers-XXXXXX"; FILE *fh; int fd; size_t i; getdns_dict *rr_dict; getdns_return_t r; getdns_bindata *addr_bd; char dst[2048]; size_t dst_len; getdns_list *newlist; if (!context) return GETDNS_RETURN_INVALID_PARAMETER; if (!addresses) { #ifdef HAVE_LIBUNBOUND if (ub_ctx_set_option( context->unbound_ctx, "root-hints:", "")) return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; #endif if (context->dns_root_servers) getdns_list_destroy(context->dns_root_servers); context->dns_root_servers = NULL; if (context->root_servers_fn[0]) unlink(context->root_servers_fn); context->root_servers_fn[0] = 0; dispatch_updated( context, GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS); return GETDNS_RETURN_GOOD; } if ((fd = mkstemp(tmpfn)) < 0) return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; if (!(fh = fdopen(fd, "w"))) return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; for (i=0; (!(r = getdns_list_get_dict(addresses, i, &rr_dict))); i++) { dst_len = sizeof(dst); if (!getdns_rr_dict2str_buf(rr_dict, dst, &dst_len)) fprintf(fh, "%s", dst); else if (getdns_dict_get_bindata( rr_dict, "address_data", &addr_bd) && getdns_dict_get_bindata( rr_dict, "/rdata/ipv4_address", &addr_bd) && getdns_dict_get_bindata( rr_dict, "/rdata/ipv6_address", &addr_bd)) ; /* pass */ else if (addr_bd->size == 16 && inet_ntop(AF_INET6, addr_bd->data, dst, sizeof(dst))) fprintf(fh, ". NS %zu.root-servers.getdnsapi.net.\n" "%zu.root-servers.getdnsapi.net. AAAA %s\n", i, i, dst); else if (addr_bd->size == 4 && inet_ntop(AF_INET, addr_bd->data, dst, sizeof(dst))) fprintf(fh, ". NS %zu.root-servers.getdnsapi.net.\n" "%zu.root-servers.getdnsapi.net. A %s\n", i, i, dst); } fclose(fh); #ifdef HAVE_LIBUNBOUND if (ub_ctx_set_option( context->unbound_ctx, "root-hints:", tmpfn)) { unlink(tmpfn); return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } #endif if (_getdns_list_copy(addresses, &newlist)) { unlink(tmpfn); return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } if (context->dns_root_servers) getdns_list_destroy(context->dns_root_servers); context->dns_root_servers = newlist; if (context->root_servers_fn[0]) unlink(context->root_servers_fn); (void) memcpy(context->root_servers_fn, tmpfn, strlen(tmpfn)); dispatch_updated(context, GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS); return GETDNS_RETURN_GOOD; } /* getdns_context_set_dns_root_servers */ /* * getdns_context_set_append_name * */ getdns_return_t getdns_context_set_append_name(struct getdns_context *context, getdns_append_name_t value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); if (value != GETDNS_APPEND_NAME_ALWAYS && value != GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE && value != GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE && value != GETDNS_APPEND_NAME_NEVER) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } context->append_name = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_APPEND_NAME); return GETDNS_RETURN_GOOD; } /* getdns_context_set_append_name */ /* * getdns_context_set_suffix * */ getdns_return_t getdns_context_set_suffix(getdns_context *context, getdns_list *value) { getdns_return_t r; size_t i; gldns_buffer gbuf; uint8_t buf_spc[1024], *suffixes = NULL; size_t suffixes_len = 0; uint8_t dname[256]; size_t dname_len; char name_spc[1025], *name; getdns_bindata *bindata; if (!context) return GETDNS_RETURN_INVALID_PARAMETER; if (value == NULL) { if (context->suffixes && context->suffixes != no_suffixes) GETDNS_FREE(context->mf, (void *)context->suffixes); context->suffixes = no_suffixes; context->suffixes_len = sizeof(no_suffixes); return GETDNS_RETURN_GOOD; } gldns_buffer_init_frm_data(&gbuf, buf_spc, sizeof(buf_spc)); for (;;) { for ( i = 0 ; !(r = getdns_list_get_bindata(value, i, &bindata)) ; i++) { if (bindata->size == 0 || bindata->size >= sizeof(name_spc)) continue; if (bindata->data[bindata->size-1] != 0) { /* Unterminated string */ (void) memcpy(name_spc, bindata->data, bindata->size); name_spc[bindata->size] = 0; name = name_spc; } else /* Terminated string */ name = (char *)bindata->data; dname_len = sizeof(dname); if (gldns_str2wire_dname_buf(name, dname, &dname_len)) return GETDNS_RETURN_GENERIC_ERROR; gldns_buffer_write_u8(&gbuf, dname_len); gldns_buffer_write(&gbuf, dname, dname_len); } if (r == GETDNS_RETURN_NO_SUCH_LIST_ITEM) r = GETDNS_RETURN_GOOD; else break; gldns_buffer_write_u8(&gbuf, 1); gldns_buffer_write_u8(&gbuf, 0); if (gldns_buffer_begin(&gbuf) != buf_spc) break; suffixes_len = gldns_buffer_position(&gbuf); if (!(suffixes = GETDNS_XMALLOC( context->mf, uint8_t, suffixes_len))) { r = GETDNS_RETURN_MEMORY_ERROR; break; } if (suffixes_len <= gldns_buffer_limit(&gbuf)) { (void) memcpy (suffixes, buf_spc, suffixes_len); break; } gldns_buffer_init_frm_data(&gbuf, suffixes, suffixes_len); } if (r) { if (gldns_buffer_begin(&gbuf) != buf_spc) GETDNS_FREE(context->mf, suffixes); return r; } if (context->suffixes && context->suffixes != no_suffixes) GETDNS_FREE(context->mf, (void *)context->suffixes); context->suffixes = suffixes; context->suffixes_len = suffixes_len; dispatch_updated(context, GETDNS_CONTEXT_CODE_SUFFIX); return GETDNS_RETURN_GOOD; } /* getdns_context_set_suffix */ /* * getdns_context_set_dnssec_trust_anchors * */ getdns_return_t getdns_context_set_dnssec_trust_anchors( getdns_context *context, getdns_list *value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); if (context->trust_anchors && context->trust_anchors != context->trust_anchors_spc) GETDNS_FREE(context->mf, context->trust_anchors); if (value) { context->trust_anchors_len = sizeof(context->trust_anchors_spc); context->trust_anchors = _getdns_list2wire(value, context->trust_anchors_spc, &context->trust_anchors_len, &context->mf); } else { context->trust_anchors = NULL; context->trust_anchors_len = 0; } dispatch_updated(context, GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS); return GETDNS_RETURN_GOOD; } /* getdns_context_set_dnssec_trust_anchors */ 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); } /* * getdns_context_set_dnssec_allowed_skew * */ getdns_return_t getdns_context_set_dnssec_allowed_skew(struct getdns_context *context, uint32_t value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); set_ub_dnssec_allowed_skew(context, value); if (value != context->dnssec_allowed_skew) { context->dnssec_allowed_skew = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW); } return GETDNS_RETURN_GOOD; } /* getdns_context_set_dnssec_allowed_skew */ /* * getdns_context_set_upstream_recursive_servers * */ getdns_return_t getdns_context_set_upstream_recursive_servers(struct getdns_context *context, struct getdns_list *upstream_list) { getdns_return_t r; size_t count = 0; size_t i; getdns_upstreams *upstreams; char addrstr[1024], portstr[1024], *eos; struct addrinfo hints; RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(upstream_list, GETDNS_RETURN_INVALID_PARAMETER); r = getdns_list_get_length(upstream_list, &count); if (count == 0 || r != GETDNS_RETURN_GOOD) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ hints.ai_socktype = 0; /* Datagram socket */ hints.ai_flags = AI_NUMERICHOST; /* No reverse name lookups */ hints.ai_protocol = 0; /* Any protocol */ hints.ai_canonname = NULL; hints.ai_addr = NULL; hints.ai_next = NULL; upstreams = upstreams_create( context, count * GETDNS_UPSTREAM_TRANSPORTS); for (i = 0; i < count; i++) { getdns_dict *dict; getdns_bindata *address_type; getdns_bindata *address_data; getdns_bindata *tls_auth_name; struct sockaddr_storage addr; getdns_bindata *scope_id; getdns_upstream *upstream; getdns_bindata *tsig_alg_name, *tsig_name, *tsig_key; getdns_tsig_algo tsig_alg; char tsig_name_str[1024]; uint8_t tsig_dname_spc[256], *tsig_dname; size_t tsig_dname_len; if ((r = getdns_list_get_dict(upstream_list, i, &dict))) goto error; if ((r = getdns_dict_get_bindata( dict, "address_type",&address_type))) goto error; if (address_type->size < 4) goto invalid_parameter; if (strncmp((char *)address_type->data, "IPv4", 4) == 0) addr.ss_family = AF_INET; else if (strncmp((char *)address_type->data, "IPv6", 4) == 0) addr.ss_family = AF_INET6; else goto invalid_parameter; if ((r = getdns_dict_get_bindata( dict, "address_data", &address_data))) goto error; if ((addr.ss_family == AF_INET && address_data->size != 4) || (addr.ss_family == AF_INET6 && address_data->size != 16)) goto invalid_parameter; if (inet_ntop(addr.ss_family, address_data->data, addrstr, 1024) == NULL) goto invalid_parameter; if (getdns_dict_get_bindata(dict, "scope_id", &scope_id) == GETDNS_RETURN_GOOD) { if (strlen(addrstr) + scope_id->size > 1022) goto invalid_parameter; eos = &addrstr[strlen(addrstr)]; *eos++ = '%'; (void) memcpy(eos, scope_id->data, scope_id->size); eos[scope_id->size] = 0; } tsig_alg_name = tsig_name = tsig_key = NULL; tsig_dname = NULL; tsig_dname_len = 0; if (getdns_dict_get_bindata(dict, "tsig_algorithm", &tsig_alg_name) == GETDNS_RETURN_GOOD) tsig_alg = _getdns_get_tsig_algo(tsig_alg_name); else tsig_alg = GETDNS_HMAC_MD5; if (getdns_dict_get_bindata(dict, "tsig_name", &tsig_name)) tsig_alg = GETDNS_NO_TSIG; /* No name, no TSIG */ else if (tsig_name->size == 0) tsig_alg = GETDNS_NO_TSIG; else if (tsig_name->data[tsig_name->size - 1] != 0) { /* Unterminated string */ if (tsig_name->size >= sizeof(tsig_name_str) - 1) tsig_alg = GETDNS_NO_TSIG; else { (void) memcpy(tsig_name_str, tsig_name->data , tsig_name->size); tsig_name_str[tsig_name->size] = 0; tsig_dname_len = sizeof(tsig_dname_spc); if (gldns_str2wire_dname_buf(tsig_name_str, tsig_dname_spc, &tsig_dname_len)) tsig_alg = GETDNS_NO_TSIG; else tsig_dname = tsig_dname_spc; } } else if (!_getdns_bindata_is_dname(tsig_name)) { /* Terminated string */ tsig_dname_len = sizeof(tsig_dname_spc); if (gldns_str2wire_dname_buf(tsig_name_str, tsig_dname_spc, &tsig_dname_len)) tsig_alg = GETDNS_NO_TSIG; else tsig_dname = tsig_dname_spc; } else if (tsig_name->size > sizeof(tsig_dname_spc)) tsig_alg = GETDNS_NO_TSIG; else { /* fqdn */ tsig_dname = memcpy(tsig_dname_spc, tsig_name->data , tsig_name->size); tsig_dname_len = tsig_name->size; } if (getdns_dict_get_bindata(dict, "tsig_secret", &tsig_key)) tsig_alg = GETDNS_NO_TSIG; /* No key, no TSIG */ /* Don't check TSIG length contraints here. * Let the upstream decide what is secure enough. */ /* Loop to create upstreams as needed*/ for (size_t j = 0; j < GETDNS_UPSTREAM_TRANSPORTS; j++) { uint32_t port; struct addrinfo *ai; port = getdns_port_array[j]; if (port == GETDNS_PORT_ZERO) continue; if (getdns_upstream_transports[j] != GETDNS_TRANSPORT_TLS) (void) getdns_dict_get_int(dict, "port", &port); else (void) getdns_dict_get_int(dict, "tls_port", &port); (void) snprintf(portstr, 1024, "%d", (int)port); if (getaddrinfo(addrstr, portstr, &hints, &ai)) goto invalid_parameter; if (!ai) continue; /* TODO[TLS]: Should probably check that the upstream doesn't * already exist (in case user has specified TLS port explicitly and * to prevent duplicates) */ upstream = &upstreams->upstreams[upstreams->count]; upstream->addr.ss_family = addr.ss_family; upstream_init(upstream, upstreams, ai); upstream->transport = getdns_upstream_transports[j]; if (getdns_upstream_transports[j] == GETDNS_TRANSPORT_TLS) { getdns_list *pubkey_pinset = NULL; if ((r = getdns_dict_get_bindata( dict, "tls_auth_name", &tls_auth_name)) == GETDNS_RETURN_GOOD) { /*TODO: VALIDATE THIS STRING!*/ memcpy(upstream->tls_auth_name, (char *)tls_auth_name->data, tls_auth_name->size); upstream->tls_auth_name[tls_auth_name->size] = '\0'; } if ((r = getdns_dict_get_list(dict, "tls_pubkey_pinset", &pubkey_pinset)) == GETDNS_RETURN_GOOD) { /* TODO: what if the user supplies tls_pubkey_pinset with * something other than a list? */ r = _getdns_get_pubkey_pinset_from_list(pubkey_pinset, &(upstreams->mf), &(upstream->tls_pubkey_pinset)); if (r != GETDNS_RETURN_GOOD) goto invalid_parameter; } } if ((upstream->tsig_alg = tsig_alg)) { if (tsig_name) { (void) memcpy(upstream->tsig_dname, tsig_dname, tsig_dname_len); upstream->tsig_dname_len = tsig_dname_len; } else upstream->tsig_dname_len = 0; if (tsig_key) { (void) memcpy(upstream->tsig_key, tsig_key->data, tsig_key->size); upstream->tsig_size = tsig_key->size; } else upstream->tsig_size = 0; } else { upstream->tsig_dname_len = 0; upstream->tsig_size = 0; } upstreams->count++; freeaddrinfo(ai); } } _getdns_upstreams_dereference(context->upstreams); context->upstreams = upstreams; dispatch_updated(context, GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS); return GETDNS_RETURN_GOOD; invalid_parameter: r = GETDNS_RETURN_INVALID_PARAMETER; error: _getdns_upstreams_dereference(upstreams); return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } /* getdns_context_set_upstream_recursive_servers */ static void set_ub_edns_maximum_udp_payload_size(struct getdns_context* context, int value) { /* edns-buffer-size */ if (value >= 512 && value <= 65535) set_ub_number_opt(context, "edns-buffer-size:", (uint16_t)value); } /* * getdns_context_set_edns_maximum_udp_payload_size * */ getdns_return_t getdns_context_set_edns_maximum_udp_payload_size(struct getdns_context *context, uint16_t value) { if (!context) return GETDNS_RETURN_INVALID_PARAMETER; /* check for < 512. uint16_t won't let it go above max) */ if (value < 512) value = 512; set_ub_edns_maximum_udp_payload_size(context, value); if (value != context->edns_maximum_udp_payload_size) { context->edns_maximum_udp_payload_size = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE); } return GETDNS_RETURN_GOOD; } /* getdns_context_set_edns_maximum_udp_payload_size */ /* * getdns_context_set_edns_extended_rcode * */ getdns_return_t getdns_context_set_edns_extended_rcode(struct getdns_context *context, uint8_t value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); context->edns_extended_rcode = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE); return GETDNS_RETURN_GOOD; } /* getdns_context_set_edns_extended_rcode */ /* * getdns_context_set_edns_version * */ getdns_return_t getdns_context_set_edns_version(struct getdns_context *context, uint8_t value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); context->edns_version = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_EDNS_VERSION); return GETDNS_RETURN_GOOD; } /* getdns_context_set_edns_version */ /* * getdns_context_set_edns_do_bit * */ getdns_return_t getdns_context_set_edns_do_bit(struct getdns_context *context, uint8_t value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); /* only allow 1 */ if (value != 0 && value != 1) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } context->edns_do_bit = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_EDNS_DO_BIT); return GETDNS_RETURN_GOOD; } /* getdns_context_set_edns_do_bit */ /* * getdns_context_set_edns_client_subnet_private * */ getdns_return_t getdns_context_set_edns_client_subnet_private(struct getdns_context *context, uint8_t value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); /* only allow 1 */ if (value != 0 && value != 1) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } context->edns_client_subnet_private = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE); return GETDNS_RETURN_GOOD; } /* getdns_context_set_edns_client_subnet_private */ /* * getdns_context_set_tls_query_padding_blocksize * */ getdns_return_t getdns_context_set_tls_query_padding_blocksize(struct getdns_context *context, uint16_t value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); /* only allow values between 0 and MAXIMUM_UPSTREAM_OPTION_SPACE - 4 (4 is for the overhead of the option itself) */ if (value > MAXIMUM_UPSTREAM_OPTION_SPACE - 4) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } context->tls_query_padding_blocksize = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE); return GETDNS_RETURN_GOOD; } /* getdns_context_set_tls_query_padding_blocksize */ /* * getdns_context_set_extended_memory_functions * */ getdns_return_t getdns_context_set_extended_memory_functions( struct getdns_context *context, void *userarg, void *(*malloc) (void *userarg, size_t), void *(*realloc) (void *userarg, void *, size_t), void (*free) (void *userarg, void *) ) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); if (!malloc || !realloc || !free) return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; context->mf.mf_arg = userarg; context->mf.mf.ext.malloc = malloc; context->mf.mf.ext.realloc = realloc; context->mf.mf.ext.free = free; dispatch_updated(context, GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS); return GETDNS_RETURN_GOOD; } /* getdns_context_set_extended_memory_functions*/ /* * getdns_context_set_memory_functions * */ getdns_return_t getdns_context_set_memory_functions(struct getdns_context *context, void *(*malloc) (size_t), void *(*realloc) (void *, size_t), void (*free) (void *) ) { mf_union mf; mf.pln.malloc = malloc; mf.pln.realloc = realloc; mf.pln.free = free; return getdns_context_set_extended_memory_functions( context, MF_PLAIN, mf.ext.malloc, mf.ext.realloc, mf.ext.free); } /* getdns_context_set_memory_functions*/ /* cancel the request */ static void cancel_dns_req(getdns_dns_req *req) { getdns_network_req *netreq, **netreq_p; for (netreq_p = req->netreqs; (netreq = *netreq_p); netreq_p++) #ifdef HAVE_LIBUNBOUND if (netreq->unbound_id != -1) { ub_cancel(req->context->unbound_ctx, netreq->unbound_id); netreq->unbound_id = -1; } else #endif _getdns_cancel_stub_request(netreq); req->canceled = 1; } getdns_return_t _getdns_context_cancel_request(getdns_context *context, getdns_transaction_t transaction_id, int fire_callback) { getdns_dns_req *dnsreq; if (!context) return GETDNS_RETURN_INVALID_PARAMETER; /* delete the node from the tree */ if (!(dnsreq = (getdns_dns_req *)_getdns_rbtree_delete( &context->outbound_requests, &transaction_id))) return GETDNS_RETURN_UNKNOWN_TRANSACTION; /* do the cancel */ cancel_dns_req(dnsreq); if (fire_callback) { context->processing = 1; dnsreq->user_callback(context, GETDNS_CALLBACK_CANCEL, NULL, dnsreq->user_pointer, transaction_id); context->processing = 0; } /* clean up */ _getdns_dns_req_free(dnsreq); return GETDNS_RETURN_GOOD; } /* * getdns_cancel_callback * */ getdns_return_t getdns_cancel_callback(getdns_context *context, getdns_transaction_t transaction_id) { if (!context) return GETDNS_RETURN_INVALID_PARAMETER; getdns_return_t r = _getdns_context_cancel_request(context, transaction_id, 1); getdns_context_request_count_changed(context); return r; } /* getdns_cancel_callback */ #ifndef STUB_NATIVE_DNSSEC static uint8_t* upstream_addr(getdns_upstream *upstream) { return upstream->addr.ss_family == AF_INET ? (void *)&((struct sockaddr_in*)&upstream->addr)->sin_addr : (void *)&((struct sockaddr_in6*)&upstream->addr)->sin6_addr; } static in_port_t upstream_port(getdns_upstream *upstream) { return ntohs(upstream->addr.ss_family == AF_INET ? ((struct sockaddr_in *)&upstream->addr)->sin_port : ((struct sockaddr_in6*)&upstream->addr)->sin6_port); } static uint32_t * upstream_scope_id(getdns_upstream *upstream) { return upstream->addr.ss_family == AF_INET ? NULL : (upstream_addr(upstream)[0] == 0xFE && (upstream_addr(upstream)[1] & 0xC0) == 0x80 ? &((struct sockaddr_in6*)&upstream->addr)->sin6_scope_id : NULL); } static void upstream_ntop_buf(getdns_upstream *upstream, char *buf, size_t len) { /* Also possible but prints scope_id by name (nor parsed by unbound) * * getnameinfo((struct sockaddr *)&upstream->addr, upstream->addr_len, * buf, len, NULL, 0, NI_NUMERICHOST) */ (void) inet_ntop(upstream->addr.ss_family, upstream_addr(upstream), buf, len); if (upstream_scope_id(upstream)) (void) snprintf(buf + strlen(buf), len - strlen(buf), "%%%d", (int)*upstream_scope_id(upstream)); else if (upstream_port(upstream) != GETDNS_PORT_DNS && upstream_port(upstream) != GETDNS_PORT_ZERO) (void) snprintf(buf + strlen(buf), len - strlen(buf), "@%d", (int)upstream_port(upstream)); } static getdns_return_t ub_setup_stub(struct ub_ctx *ctx, getdns_context *context) { getdns_return_t r = GETDNS_RETURN_GOOD; size_t i; getdns_upstream *upstream; char addr[1024]; getdns_upstreams *upstreams = context->upstreams; (void) ub_ctx_set_fwd(ctx, NULL); for (i = 0; i < upstreams->count; i++) { upstream = &upstreams->upstreams[i]; /*[TLS]: Use only the TLS subset of upstreams when TLS is the only thing * used. All other cases must currently fallback to TCP for libunbound.*/ if (context->dns_transports[0] == GETDNS_TRANSPORT_TLS && context->dns_transport_count ==1 && upstream->transport != GETDNS_TRANSPORT_TLS) continue; upstream_ntop_buf(upstream, addr, 1024); ub_ctx_set_fwd(ctx, addr); } /* Allow lookups of: */ /* - localhost */ (void)ub_ctx_zone_remove(ctx, "localhost."); /* - reverse IPv4 loopback */ (void)ub_ctx_zone_remove(ctx, "127.in-addr.arpa."); /* - reverse IPv6 loopback */ (void)ub_ctx_zone_remove(ctx, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0." "0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa."); /* - reverse RFC1918 local use zones */ (void)ub_ctx_zone_remove(ctx, "10.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "16.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "17.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "18.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "19.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "20.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "21.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "22.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "23.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "24.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "25.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "26.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "27.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "28.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "29.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "30.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "31.172.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "168.192.in-addr.arpa."); /* - reverse RFC3330 IP4 this, link-local, testnet and broadcast */ (void)ub_ctx_zone_remove(ctx, "0.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "254.169.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "2.0.192.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "100.51.198.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "113.0.203.in-addr.arpa."); (void)ub_ctx_zone_remove(ctx, "255.255.255.255.in-addr.arpa."); /* - reverse RFC4291 IP6 unspecified */ (void)ub_ctx_zone_remove(ctx, "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0." "0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa."); /* - reverse RFC4193 IPv6 Locally Assigned Local Addresses */ (void)ub_ctx_zone_remove(ctx, "D.F.ip6.arpa."); /* - reverse RFC4291 IPv6 Link Local Addresses */ (void)ub_ctx_zone_remove(ctx, "8.E.F.ip6.arpa."); (void)ub_ctx_zone_remove(ctx, "9.E.F.ip6.arpa."); (void)ub_ctx_zone_remove(ctx, "A.E.F.ip6.arpa."); (void)ub_ctx_zone_remove(ctx, "B.E.F.ip6.arpa."); /* - reverse IPv6 Example Prefix */ (void)ub_ctx_zone_remove(ctx, "8.B.D.0.1.0.0.2.ip6.arpa."); return r; } #endif #ifdef HAVE_LIBUNBOUND static getdns_return_t ub_setup_recursing(struct ub_ctx *ctx, getdns_context *context) { _getdns_rr_iter rr_spc, *rr; char ta_str[8192]; (void) ub_ctx_set_fwd(ctx, NULL); if (!context->unbound_ta_set && context->trust_anchors) { for ( rr = _getdns_rr_iter_init( &rr_spc , context->trust_anchors , context->trust_anchors_len) ; rr ; rr = _getdns_rr_iter_next(rr) ) { (void) gldns_wire2str_rr_buf((UNCONST_UINT8_p)rr->pos, rr->nxt - rr->pos, ta_str, sizeof(ta_str)); (void) ub_ctx_add_ta(ctx, ta_str); } context->unbound_ta_set = 1; } return GETDNS_RETURN_GOOD; } #endif static getdns_return_t _getdns_ns_dns_setup(struct getdns_context *context) { assert(context); switch (context->resolution_type) { case GETDNS_RESOLUTION_STUB: if (!context->upstreams || !context->upstreams->count) return GETDNS_RETURN_GENERIC_ERROR; #ifdef STUB_NATIVE_DNSSEC #ifdef DNSSEC_ROADBLOCK_AVOIDANCE return ub_setup_recursing(context->unbound_ctx, context); #else return GETDNS_RETURN_GOOD; #endif #else return ub_setup_stub(context->unbound_ctx, context); #endif case GETDNS_RESOLUTION_RECURSING: #ifdef HAVE_LIBUNBOUND return ub_setup_recursing(context->unbound_ctx, context); #else return GETDNS_RETURN_NOT_IMPLEMENTED; #endif } return GETDNS_RETURN_BAD_CONTEXT; } getdns_return_t _getdns_context_prepare_for_resolution(struct getdns_context *context, int usenamespaces) { int i; getdns_return_t r; RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); if (context->destroying) { return GETDNS_RETURN_BAD_CONTEXT; } /* Transport can in theory be set per query in stub mode */ if (context->resolution_type == GETDNS_RESOLUTION_STUB && tls_is_in_transports_list(context) == 1) { if (context->tls_ctx == NULL) { #ifdef HAVE_TLS_v1_2 /* Create client context, use TLS v1.2 only for now */ context->tls_ctx = SSL_CTX_new(TLSv1_2_client_method()); if(context->tls_ctx == NULL) #ifndef USE_WINSOCK return GETDNS_RETURN_BAD_CONTEXT; #else printf("Warning! Bad TLS context, check openssl version on Windows!\n");; #endif /* Be strict and only use the cipher suites recommended in RFC7525 Unless we later fallback to opportunistic. */ const char* const PREFERRED_CIPHERS = "EECDH+aRSA+AESGCM:EECDH+aECDSA+AESGCM:EDH+aRSA+AESGCM"; if (!SSL_CTX_set_cipher_list(context->tls_ctx, PREFERRED_CIPHERS)) return GETDNS_RETURN_BAD_CONTEXT; if (!SSL_CTX_set_default_verify_paths(context->tls_ctx)) return GETDNS_RETURN_BAD_CONTEXT; #else if (tls_only_is_in_transports_list(context) == 1) return GETDNS_RETURN_BAD_CONTEXT; /* A null tls_ctx will make TLS fail and fallback to the other transports will kick-in.*/ #endif } if (tls_only_is_in_transports_list(context) == 1 && context->tls_auth == GETDNS_AUTHENTICATION_REQUIRED) { context->tls_auth_min = GETDNS_AUTHENTICATION_REQUIRED; /* TODO: If no auth data provided for any upstream, fail here */ } else { context->tls_auth_min = GETDNS_AUTHENTICATION_NONE; } } /* Block use of TLS ONLY in recursive mode as it won't work */ /* Note: If TLS is used in recursive mode this will try TLS on port * 53 so it is blocked here. */ if (context->resolution_type == GETDNS_RESOLUTION_RECURSING && tls_only_is_in_transports_list(context) == 1) return GETDNS_RETURN_BAD_CONTEXT; if (context->resolution_type_set == context->resolution_type) /* already set and no config changes * have caused this to be bad. */ return GETDNS_RETURN_GOOD; /* TODO: respect namespace order (unbound always uses local first if cfg * the spec calls for us to treat the namespace list as ordered * so we need to respect that order */ if (! usenamespaces) { r = _getdns_ns_dns_setup(context); if (r == GETDNS_RETURN_GOOD) context->resolution_type_set = context->resolution_type; return r; } r = GETDNS_RETURN_GOOD; for (i = 0; i < context->namespace_count; i++) { switch (context->namespaces[i]) { case GETDNS_NAMESPACE_DNS: r = _getdns_ns_dns_setup(context); break; default: r = GETDNS_RETURN_BAD_CONTEXT; break; } if (r != GETDNS_RETURN_GOOD) return r; /* try again later (resolution_type_set) */ } context->resolution_type_set = context->resolution_type; return r; } /* _getdns_context_prepare_for_resolution */ getdns_return_t _getdns_context_track_outbound_request(getdns_dns_req *dnsreq) { if (!dnsreq) return GETDNS_RETURN_INVALID_PARAMETER; dnsreq->node.key = &(dnsreq->trans_id); if (!_getdns_rbtree_insert( &dnsreq->context->outbound_requests, &dnsreq->node)) return GETDNS_RETURN_GENERIC_ERROR; getdns_context_request_count_changed(dnsreq->context); return GETDNS_RETURN_GOOD; } getdns_return_t _getdns_context_clear_outbound_request(getdns_dns_req *dnsreq) { if (!dnsreq) return GETDNS_RETURN_INVALID_PARAMETER; if (!_getdns_rbtree_delete( &dnsreq->context->outbound_requests, &dnsreq->trans_id)) return GETDNS_RETURN_GENERIC_ERROR; getdns_context_request_count_changed(dnsreq->context); return GETDNS_RETURN_GOOD; } getdns_return_t _getdns_context_request_timed_out(getdns_dns_req *req) { /* Don't use req after callback */ getdns_context* context = req->context; getdns_transaction_t trans_id = req->trans_id; getdns_callback_t cb = req->user_callback; void *user_arg = req->user_pointer; getdns_dict *response = _getdns_create_getdns_response(req); /* cancel the req - also clears it from outbound and cleans up*/ _getdns_context_cancel_request(context, trans_id, 0); context->processing = 1; cb(context, GETDNS_CALLBACK_TIMEOUT, response, user_arg, trans_id); context->processing = 0; getdns_context_request_count_changed(context); return GETDNS_RETURN_GOOD; } char * _getdns_strdup(const struct mem_funcs *mfs, const char *s) { size_t sz = strlen(s) + 1; char *r = GETDNS_XMALLOC(*mfs, char, sz); if (r) return memcpy(r, s, sz); else return NULL; } struct getdns_bindata * _getdns_bindata_copy(struct mem_funcs *mfs, size_t size, const uint8_t *data) { /* Don't know why, but nodata allows * empty bindatas with the python bindings */ static uint8_t nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; struct getdns_bindata *dst; if (!(dst = GETDNS_MALLOC(*mfs, struct getdns_bindata))) return NULL; if ((dst->size = size)) { dst->data = GETDNS_XMALLOC(*mfs, uint8_t, size); if (!dst->data) { GETDNS_FREE(*mfs, dst); return NULL; } (void) memcpy(dst->data, data, size); } else { dst->data = nodata; } return dst; } void _getdns_bindata_destroy(struct mem_funcs *mfs, struct getdns_bindata *bindata) { if (!bindata) return; if (bindata->size) GETDNS_FREE(*mfs, bindata->data); GETDNS_FREE(*mfs, bindata); } /* TODO: Remove next_timeout argument from getdns_context_get_num_pending_requests */ void _getdns_handle_timeouts(struct _getdns_event_base* base, struct timeval* now, struct timeval* wait); uint32_t getdns_context_get_num_pending_requests(struct getdns_context* context, struct timeval* next_timeout) { struct timeval dispose; RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); if (context->outbound_requests.count) context->extension->vmt->run_once(context->extension, 0); /* TODO: Remove this when next_timeout is gone */ if (context->extension == &context->mini_event.loop) _getdns_handle_timeouts(context->mini_event.base, &context->mini_event.time_tv, next_timeout ? next_timeout : &dispose); return context->outbound_requests.count; } /* process async reqs */ getdns_return_t getdns_context_process_async(struct getdns_context* context) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); #ifdef HAVE_LIBUNBOUND if (ub_poll(context->unbound_ctx) && ub_process(context->unbound_ctx)){ /* need an async return code? */ return GETDNS_RETURN_GENERIC_ERROR; } #endif context->extension->vmt->run_once(context->extension, 0); return GETDNS_RETURN_GOOD; } void getdns_context_run(getdns_context *context) { if (context->extension == &context->mini_event.loop) { if (getdns_context_get_num_pending_requests(context, NULL) > 0 && !getdns_context_process_async(context)) context->extension->vmt->run(context->extension); } else context->extension->vmt->run(context->extension); } typedef struct timeout_accumulator { getdns_transaction_t* ids; int idx; } timeout_accumulator; static void accumulate_outstanding_transactions(_getdns_rbnode_t* node, void* arg) { timeout_accumulator* acc = (timeout_accumulator*) arg; acc->ids[acc->idx] = *((getdns_transaction_t*) node->key); acc->idx++; } static void cancel_outstanding_requests(struct getdns_context* context, int fire_callback) { if (context->outbound_requests.count > 0) { timeout_accumulator acc; int i; acc.idx = 0; acc.ids = GETDNS_XMALLOC(context->my_mf, getdns_transaction_t, context->outbound_requests.count); _getdns_traverse_postorder(&context->outbound_requests, accumulate_outstanding_transactions, &acc); for (i = 0; i < acc.idx; ++i) { _getdns_context_cancel_request(context, acc.ids[i], fire_callback); } GETDNS_FREE(context->my_mf, acc.ids); } } getdns_return_t getdns_context_detach_eventloop(struct getdns_context* context) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); /* When called from within a callback, do not execute pending * context destroys. * The (other) callback handler will handle it. * * ( because callbacks occur in cancel_outstanding_requests, * and they may destroy the context ) */ /* cancel all outstanding requests */ cancel_outstanding_requests(context, 1); context->extension->vmt->cleanup(context->extension); context->extension = &context->mini_event.loop; return _getdns_mini_event_init(context, &context->mini_event); } getdns_return_t getdns_context_set_eventloop(getdns_context* context, getdns_eventloop* loop) { if (!context || !loop) return GETDNS_RETURN_INVALID_PARAMETER; if (context->extension) { cancel_outstanding_requests(context, 1); context->extension->vmt->cleanup(context->extension); } context->extension = loop; return GETDNS_RETURN_GOOD; } static in_port_t upstream_port(getdns_upstream *upstream) { return ntohs(upstream->addr.ss_family == AF_INET ? ((struct sockaddr_in *)&upstream->addr)->sin_port : ((struct sockaddr_in6*)&upstream->addr)->sin6_port); } static getdns_dict* _get_context_settings(getdns_context* context) { getdns_return_t r = GETDNS_RETURN_GOOD; getdns_dict* result = getdns_dict_create_with_context(context); getdns_list *list; if (!result) { return NULL; } /* int fields */ r = getdns_dict_set_int(result, "timeout", context->timeout); r |= getdns_dict_set_int(result, "limit_outstanding_queries", context->limit_outstanding_queries); r |= getdns_dict_set_int(result, "dnssec_allowed_skew", context->dnssec_allowed_skew); r |= getdns_dict_set_int(result, "follow_redirects", context->follow_redirects); if (context->edns_maximum_udp_payload_size != -1) r |= getdns_dict_set_int(result, "edns_maximum_udp_payload_size", context->edns_maximum_udp_payload_size); r |= getdns_dict_set_int(result, "edns_extended_rcode", context->edns_extended_rcode); r |= getdns_dict_set_int(result, "edns_version", context->edns_version); r |= getdns_dict_set_int(result, "edns_do_bit", context->edns_do_bit); r |= getdns_dict_set_int(result, "append_name", context->append_name); /* list fields */ if (!getdns_context_get_suffix(context, &list)) { r |= getdns_dict_set_list(result, "suffix", list); getdns_list_destroy(list); } if (!getdns_context_get_upstream_recursive_servers(context, &list)) { r |= getdns_dict_set_list(result, "upstream_recursive_servers", list); getdns_list_destroy(list); } if (context->dns_transport_count > 0) { /* create a namespace list */ size_t i; getdns_list* transports = getdns_list_create_with_context(context); if (transports) { for (i = 0; i < context->dns_transport_count; ++i) { r |= getdns_list_set_int(transports, i, context->dns_transports[i]); } r |= getdns_dict_set_list(result, "dns_transport_list", transports); } r |= getdns_dict_set_int(result, "tls_authentication", context->tls_auth); } if (context->namespace_count > 0) { /* create a namespace list */ size_t i; getdns_list* namespaces = getdns_list_create_with_context(context); if (namespaces) { for (i = 0; i < context->namespace_count; ++i) { r |= getdns_list_set_int(namespaces, i, context->namespaces[i]); } r |= getdns_dict_set_list(result, "namespaces", namespaces); } } if (r != GETDNS_RETURN_GOOD) { getdns_dict_destroy(result); result = NULL; } return result; } getdns_dict* getdns_context_get_api_information(getdns_context* context) { getdns_return_t r = GETDNS_RETURN_GOOD; getdns_dict* result = getdns_dict_create_with_context(context); getdns_dict* settings; if (!result) { return NULL; } r = getdns_dict_util_set_string(result, "version_string", GETDNS_VERSION); r |= getdns_dict_util_set_string(result, "implementation_string", PACKAGE_URL); r |= getdns_dict_set_int(result, "resolution_type", context->resolution_type); settings = _get_context_settings(context); r |= getdns_dict_set_dict(result, "all_context", settings); getdns_dict_destroy(settings); if (r != GETDNS_RETURN_GOOD) { getdns_dict_destroy(result); result = NULL; } return result; } getdns_return_t getdns_context_set_return_dnssec_status(getdns_context* context, int enabled) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); if (enabled != GETDNS_EXTENSION_TRUE && enabled != GETDNS_EXTENSION_FALSE) { return GETDNS_RETURN_INVALID_PARAMETER; } context->return_dnssec_status = enabled; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_set_use_threads(getdns_context* context, int use_threads) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); int r = 0; if (context->resolution_type_set != 0) { /* already setup */ return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } #ifdef HAVE_LIBUNBOUND if (use_threads) r = ub_ctx_async(context->unbound_ctx, 1); else r = ub_ctx_async(context->unbound_ctx, 0); #else (void)use_threads; #endif return r == 0 ? GETDNS_RETURN_GOOD : GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } getdns_return_t _getdns_context_local_namespace_resolve( getdns_dns_req *dnsreq, getdns_dict **response) { getdns_context *context = dnsreq->context; host_name_addrs *hnas; uint8_t lookup[256]; getdns_list empty_list = { 0 }; getdns_bindata bindata; getdns_list *jaa; size_t i; getdns_dict *addr; int ipv4 = dnsreq->netreqs[0]->request_type == GETDNS_RRTYPE_A || (dnsreq->netreqs[1] && dnsreq->netreqs[1]->request_type == GETDNS_RRTYPE_A); int ipv6 = dnsreq->netreqs[0]->request_type == GETDNS_RRTYPE_AAAA || (dnsreq->netreqs[1] && dnsreq->netreqs[1]->request_type == GETDNS_RRTYPE_AAAA); if (!ipv4 && !ipv6) return GETDNS_RETURN_GENERIC_ERROR; /*Do the lookup*/ (void)memcpy(lookup, dnsreq->name, dnsreq->name_len); canonicalize_dname(lookup); if (!(hnas = (host_name_addrs *) _getdns_rbtree_search(&context->local_hosts, lookup))) return GETDNS_RETURN_GENERIC_ERROR; if (!hnas->ipv4addrs && (!ipv6 || !hnas->ipv6addrs)) return GETDNS_RETURN_GENERIC_ERROR; if (!hnas->ipv6addrs && (!ipv4 || !hnas->ipv4addrs)) return GETDNS_RETURN_GENERIC_ERROR; if (!(*response = getdns_dict_create_with_context(context))) return GETDNS_RETURN_GENERIC_ERROR; bindata.size = dnsreq->name_len; bindata.data = dnsreq->name; if (getdns_dict_set_bindata(*response, "canonical_name", &bindata)) goto error; empty_list.mf = context->mf; if (getdns_dict_set_list(*response, "replies_full", &empty_list)) goto error; if (getdns_dict_set_list(*response, "replies_tree", &empty_list)) goto error; if (getdns_dict_set_int(*response, "status", GETDNS_RESPSTATUS_GOOD)) goto error; if (!ipv4 || !hnas->ipv4addrs) { if (getdns_dict_set_list(*response, "just_address_answers", hnas->ipv6addrs)) goto error; return GETDNS_RETURN_GOOD; } else if (!ipv6 || !hnas->ipv6addrs) { if (getdns_dict_set_list(*response, "just_address_answers", hnas->ipv4addrs)) goto error; return GETDNS_RETURN_GOOD; } if (!(jaa = getdns_list_create_with_context(context))) goto error; for (i = 0; !getdns_list_get_dict(hnas->ipv4addrs, i, &addr); i++) if (_getdns_list_append_dict(jaa, addr)) break; for (i = 0; !getdns_list_get_dict(hnas->ipv6addrs, i, &addr); i++) if (_getdns_list_append_dict(jaa, addr)) break; if (!getdns_dict_set_list(*response, "just_address_answers", jaa)) { getdns_list_destroy(jaa); return GETDNS_RETURN_GOOD; } getdns_list_destroy(jaa); error: getdns_dict_destroy(*response); return GETDNS_RETURN_GENERIC_ERROR; } struct mem_funcs * priv_getdns_context_mf(getdns_context *context) { return &context->mf; } /** begin getters **/ getdns_return_t getdns_context_get_resolution_type(getdns_context *context, getdns_resolution_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->resolution_type; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_namespaces(getdns_context *context, size_t* namespace_count, getdns_namespace_t **namespaces) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(namespace_count, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(namespaces, GETDNS_RETURN_INVALID_PARAMETER); *namespace_count = context->namespace_count; if (!context->namespace_count) { *namespaces = NULL; return GETDNS_RETURN_GOOD; } // use normal malloc here so users can do normal free *namespaces = malloc(context->namespace_count * sizeof(getdns_namespace_t)); memcpy(*namespaces, context->namespaces, context->namespace_count * sizeof(getdns_namespace_t)); return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_dns_transport(getdns_context *context, getdns_transport_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); int count = context->dns_transport_count; getdns_transport_list_t *transports = context->dns_transports; if (!count) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; /* Best effort mapping for backwards compatibility*/ if (transports[0] == GETDNS_TRANSPORT_UDP) { if (count == 1) *value = GETDNS_TRANSPORT_UDP_ONLY; else if (count == 2 && transports[1] == GETDNS_TRANSPORT_TCP) *value = GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP; else return GETDNS_RETURN_WRONG_TYPE_REQUESTED; } if (transports[0] == GETDNS_TRANSPORT_TCP) { if (count == 1) *value = GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN; } if (transports[0] == GETDNS_TRANSPORT_TLS) { if (count == 1) *value = GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN; else if (count == 2 && transports[1] == GETDNS_TRANSPORT_TCP) *value = GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN; else return GETDNS_RETURN_WRONG_TYPE_REQUESTED; } return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_dns_transport_list(getdns_context *context, size_t* transport_count, getdns_transport_list_t **transports) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(transport_count, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(transports, GETDNS_RETURN_INVALID_PARAMETER); *transport_count = context->dns_transport_count; if (!context->dns_transport_count) { *transports = NULL; return GETDNS_RETURN_GOOD; } // use normal malloc here so users can do normal free *transports = malloc(context->dns_transport_count * sizeof(getdns_transport_list_t)); memcpy(*transports, context->dns_transports, context->dns_transport_count * sizeof(getdns_transport_list_t)); return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_tls_authentication(getdns_context *context, getdns_tls_authentication_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->tls_auth; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_limit_outstanding_queries(getdns_context *context, uint16_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->limit_outstanding_queries; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_timeout(getdns_context *context, uint64_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->timeout; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_idle_timeout(getdns_context *context, uint64_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->idle_timeout; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_follow_redirects( getdns_context *context, getdns_redirects_t* value) { if (!context || !value) return GETDNS_RETURN_INVALID_PARAMETER; *value = context->follow_redirects; return GETDNS_RETURN_NOT_IMPLEMENTED; } getdns_return_t getdns_context_get_dns_root_servers(getdns_context *context, getdns_list **value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = NULL; if (context->dns_root_servers) return _getdns_list_copy(context->dns_root_servers, value); return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_append_name(getdns_context *context, getdns_append_name_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->append_name; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_suffix(getdns_context *context, getdns_list **value) { size_t dname_len; const uint8_t *dname; char name[1024]; getdns_return_t r = GETDNS_RETURN_GOOD; getdns_list *list; if (!context || !value) return GETDNS_RETURN_INVALID_PARAMETER; if (!(list = getdns_list_create_with_context(context))) return GETDNS_RETURN_MEMORY_ERROR; assert(context->suffixes); dname_len = context->suffixes[0]; dname = context->suffixes + 1; while (dname_len && *dname) { if (! gldns_wire2str_dname_buf((UNCONST_UINT8_p) dname, dname_len, name, sizeof(name))) { r = GETDNS_RETURN_GENERIC_ERROR; break; } if ((r = _getdns_list_append_const_bindata( list, strlen(name) + 1, name))) break; dname += dname_len; dname_len = *dname++; } if (r) getdns_list_destroy(list); else *value = list; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_dnssec_trust_anchors( getdns_context *context, getdns_list **value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); if (context->trust_anchors) { if ((*value = getdns_list_create_with_context(context))) _getdns_wire2list( context->trust_anchors , context->trust_anchors_len , *value); else return GETDNS_RETURN_MEMORY_ERROR; } else *value = NULL; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_dnssec_allowed_skew(getdns_context *context, uint32_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->dnssec_allowed_skew; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_upstream_recursive_servers(getdns_context *context, getdns_list **upstreams_r) { size_t i; getdns_list *upstreams; getdns_return_t r; if (!context || !upstreams_r) return GETDNS_RETURN_INVALID_PARAMETER; if (!(upstreams = getdns_list_create_with_context(context))) return GETDNS_RETURN_MEMORY_ERROR; if (!context->upstreams || context->upstreams->count == 0) { *upstreams_r = upstreams; return GETDNS_RETURN_GOOD; } r = GETDNS_RETURN_GOOD; i = 0; while (!r && i < context->upstreams->count) { size_t j; getdns_dict *d; getdns_upstream *upstream = &context->upstreams->upstreams[i]; getdns_bindata bindata; const getdns_tsig_info *tsig_info; if (!(d = sockaddr_dict(context, (struct sockaddr*)&upstream->addr))) { r = GETDNS_RETURN_MEMORY_ERROR; break; } if (upstream->tsig_alg) { tsig_info = _getdns_get_tsig_info(upstream->tsig_alg); if ((r = _getdns_dict_set_const_bindata( d, "tsig_algorithm", tsig_info->dname_len, tsig_info->dname))) break; if (upstream->tsig_dname_len) { bindata.data = upstream->tsig_dname; bindata.size = upstream->tsig_dname_len; if ((r = getdns_dict_set_bindata( d, "tsig_name", &bindata))) break; } if (upstream->tsig_size) { bindata.data = upstream->tsig_key; bindata.size = upstream->tsig_size; if ((r = getdns_dict_set_bindata( d, "tsig_secret", &bindata))) break; } } for ( j = 1, i++ ; j < GETDNS_UPSTREAM_TRANSPORTS && i < context->upstreams->count ; j++, i++) { upstream = &context->upstreams->upstreams[i]; if (upstream->transport == GETDNS_TRANSPORT_UDP && upstream_port(upstream) != getdns_port_array[j] && (r = getdns_dict_set_int(d, "port", (uint32_t)upstream_port(upstream)))) break; if (upstream->transport == GETDNS_TRANSPORT_TLS) { if (upstream_port(upstream) == getdns_port_array[j]) (void) getdns_dict_set_int(d, "tls_port", (uint32_t) upstream_port(upstream)); if (upstream->tls_pubkey_pinset) { getdns_list *pins = NULL; if (_getdns_get_pubkey_pinset_list(context, upstream->tls_pubkey_pinset, &pins) == GETDNS_RETURN_GOOD) (void) getdns_dict_set_list(d, "tls_pubkey_pinset", pins); getdns_list_destroy(pins); } } } if (!r) r = _getdns_list_append_dict(upstreams, d); getdns_dict_destroy(d); } if (r) getdns_list_destroy(upstreams); else *upstreams_r = upstreams; return r; } getdns_return_t getdns_context_get_edns_maximum_udp_payload_size(getdns_context *context, uint16_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->edns_maximum_udp_payload_size; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_edns_extended_rcode(getdns_context *context, uint8_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->edns_extended_rcode; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_edns_version(getdns_context *context, uint8_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->edns_version; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_edns_do_bit(getdns_context *context, uint8_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->edns_do_bit; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_edns_client_subnet_private(getdns_context *context, uint8_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->edns_client_subnet_private; return GETDNS_RETURN_GOOD; } getdns_return_t getdns_context_get_tls_query_padding_blocksize(getdns_context *context, uint16_t* value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER); *value = context->tls_query_padding_blocksize; return GETDNS_RETURN_GOOD; } /* context.c */ getdns-0.9.0/src/stub.h0000664000175100017510000000350412641212403011643 00000000000000/** * * /brief functions for stub resolving * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef STUB_H_ #define STUB_H_ #include "getdns/getdns.h" #include "types-internal.h" getdns_return_t _getdns_submit_stub_request(getdns_network_req *netreq); void _getdns_cancel_stub_request(getdns_network_req *netreq); #endif /* stub.h */ getdns-0.9.0/src/rr-iter.c0000664000175100017510000002065012641212403012246 00000000000000/** * * /brief RR iterator over wireformat DNS packet */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rr-iter.h" #include "config.h" #include "gldns/rrdef.h" static void rr_iter_find_nxt(_getdns_rr_iter *i) { assert(i); assert(i->rr_type); i->nxt = i->pkt && i->n < GLDNS_QDCOUNT(i->pkt) ? i->rr_type + 4 : i->rr_type + 10 > i->pkt_end ? i->pkt_end : i->rr_type + 10 + gldns_read_uint16(i->rr_type + 8) > i->pkt_end ? i->pkt_end : i->rr_type + 10 + gldns_read_uint16(i->rr_type + 8); } static _getdns_rr_iter * find_rrtype(_getdns_rr_iter *i) { const uint8_t *pos; assert(i); assert(i->pos); /* 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) goto done; for (pos = i->pos; pos + 4 < i->pkt_end; pos += *pos + 1) if (!*pos) { i->rr_type = pos + 1; rr_iter_find_nxt(i); return i; } else if ((*pos & 0xC0) == 0xC0) { if ( pos + 6 > i->pkt_end) break; /* No space for class */ i->rr_type = pos + 2; rr_iter_find_nxt(i); return i; } else if (*pos & 0xC0) break; /* Unknown label type */ done: i->pos = NULL; return NULL; } _getdns_rr_iter * _getdns_rr_iter_init(_getdns_rr_iter *i, const uint8_t *pkt, size_t pkt_len) { assert(i); if (!pkt || pkt_len < GLDNS_HEADER_SIZE + 5) { i->pos = NULL; return NULL; } i->pkt = pkt; i->pkt_end = pkt + pkt_len; i->n = 0; i->pos = pkt + GLDNS_HEADER_SIZE; return find_rrtype(i); } _getdns_rr_iter * _getdns_single_rr_iter_init( _getdns_rr_iter *i, const uint8_t *wire, size_t wire_len) { assert(i); if (!wire || wire_len < 5 /* name + type + class */) { i->pos = NULL; return NULL; } i->pkt = NULL; i->pos = wire; i->pkt_end = wire + wire_len; i->n = 0; return find_rrtype(i); } _getdns_rr_iter * _getdns_rr_iter_rewind(_getdns_rr_iter *i) { assert(i); return _getdns_rr_iter_init(i, i->pkt, i->pkt_end - i->pkt); } _getdns_rr_iter * _getdns_rr_iter_next(_getdns_rr_iter *i) { assert(i); /* Already done */ if (!i->pos) return NULL; i->n += 1; i->pos = i->nxt; return find_rrtype(i); } static const uint8_t * dname_if_or_as_decompressed(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *pos, uint8_t *buf, size_t *len, size_t refs) { uint16_t offset; const uint8_t *start; uint8_t *dst; assert(pkt_end); assert(pos); assert(buf); assert(len); if (refs > GLDNS_MAX_POINTERS) goto error; if ((*pos & 0xC0) == 0xC0) { if (!pkt || pos + 1 >= pkt_end) goto error; offset = gldns_read_uint16(pos) & 0x3FFF; if (pkt + offset >= pkt_end) goto error; return dname_if_or_as_decompressed(pkt, pkt_end, pkt + offset, buf, len, refs + 1); } if (*pos & 0xC0) goto error; start = pos; *len = 0; while (*pos) { if ((*pos & 0xC0) == 0xC0) break; else if (*pos & 0xC0) goto error; *len += *pos + 1; pos += *pos + 1; } if (!*pos) { *len += 1; return start; } dst = buf; for (;;) { if (pos > start) { if (dst + (pos - start) > buf + 255) goto error; (void) memcpy(dst, start, pos - start); dst += (pos - start); start = pos; } if ((*pos & 0xC0) == 0xC0) { if (!pkt || pos + 1 >= pkt_end) goto error; offset = gldns_read_uint16(pos) & 0x3FFF; if (pkt + offset >= pkt_end) goto error; start = pos = pkt + offset; if (++refs > 256) goto error; } if ((*pos & 0xC0) == 0xC0) continue; else if (*pos & 0xC0) goto error; else if (!*pos) { *len += 1; *dst = 0; return buf; } *len += *pos + 1; pos += *pos + 1; } error: *len = 0; return NULL; } const uint8_t * _getdns_owner_if_or_as_decompressed(_getdns_rr_iter *i, uint8_t *ff_bytes, size_t *len) { return dname_if_or_as_decompressed(i->pkt, i->pkt_end, i->pos, ff_bytes, len, 0); } static _getdns_rdf_iter * rdf_iter_find_nxt(_getdns_rdf_iter *i) { const uint8_t *pos; assert(i); assert(i->pos); assert(i->rdd_pos); if (!i->rdd_repeat && (i->rdd_pos->type & GETDNS_RDF_REPEAT)) { i->rdd_repeat = i->rdd_pos; if (i->rdd_pos->type == GETDNS_RDF_REPEAT && ++i->rdd_pos == i->rdd_end) goto done; } if (i->rdd_pos->type & GETDNS_RDF_FIXEDSZ) i->nxt = i->pos + (i->rdd_pos->type & GETDNS_RDF_FIXEDSZ); else if ((i->rdd_pos->type & GETDNS_RDF_LEN_VAL) == 0x100) i->nxt = i->pos < i->end ? i->pos + *i->pos + 1 : i->end; else if ((i->rdd_pos->type & GETDNS_RDF_LEN_VAL) == 0x200) i->nxt = i->pos + 1 < i->end ? i->pos + gldns_read_uint16(i->pos) + 2 : i->end; else if (i->rdd_pos->type & GETDNS_RDF_DNAME) for (pos = i->pos; pos < i->end; pos += *pos + 1) { if (!*pos) { i->nxt = pos + 1; break; } else if ((*pos & 0xC0) == 0xC0) { i->nxt = pos + 2; break; } else if (*pos & 0xC0) /* Uknown label type */ goto done; } else if ((i->rdd_pos->type & GETDNS_RDF_SPECIAL) && i->rdd_pos->special) { if (!(i->nxt = i->rdd_pos->special->rdf_end( i->pkt, i->pkt_end, i->pos))) i->nxt = i->end; } else /* RDF is for remaining data */ i->nxt = i->end; if ( i->nxt <= i->end && /* Empty rdata fields are only allowed in case of non-repeating * remaining data. So only the GETDNS_RDF_BINDATA bit is set. */ (i->nxt > i->pos || (i->rdd_pos->type == GETDNS_RDF_BINDATA))) return i; done: i->pos = NULL; return NULL; } _getdns_rdf_iter * _getdns_rdf_iter_init(_getdns_rdf_iter *i, _getdns_rr_iter *rr) { const _getdns_rr_def *rr_def; assert(i); assert(rr); i->end = NULL; /* rr_iter already done or in question section */ if (!rr->pos || _getdns_rr_iter_section(rr) == GLDNS_SECTION_QUESTION) goto done; i->pkt = rr->pkt; i->pkt_end = rr->pkt_end; rr_def = _getdns_rr_def_lookup(gldns_read_uint16(rr->rr_type)); i->rdd_pos = rr_def->rdata; i->rdd_end = rr_def->rdata + rr_def->n_rdata_fields; /* No space to read rdata len */ if (rr->rr_type + 10 >= rr->nxt) goto done; i->rdd_repeat = NULL; i->pos = rr->rr_type + 10; i->end = rr->nxt; /* rdata */ if (i->rdd_pos != i->rdd_end) return rdf_iter_find_nxt(i); done: i->pos = NULL; return NULL; } _getdns_rdf_iter * _getdns_rdf_iter_next(_getdns_rdf_iter *i) { if (!i->pos) return NULL; i->rdd_pos += 1; if ((i->pos = i->nxt) > i->end) goto done; /* Overflow */ if (i->rdd_pos >= i->rdd_end && !(i->rdd_pos = i->rdd_repeat)) goto done; /* Remaining rdata, but out of definitions! */ if (i->rdd_pos->type == GETDNS_RDF_REPEAT) i->rdd_pos += 1; return rdf_iter_find_nxt(i); done: i->pos = NULL; return NULL; } _getdns_rdf_iter * _getdns_rdf_iter_init_at( _getdns_rdf_iter *i, _getdns_rr_iter *rr, size_t pos) { for ( i = _getdns_rdf_iter_init(i, rr) ; i && pos ; i = _getdns_rdf_iter_next(i), pos--); return i; } const uint8_t * _getdns_rdf_if_or_as_decompressed( _getdns_rdf_iter *i, uint8_t *ff_bytes, size_t *len) { return dname_if_or_as_decompressed(i->pkt, i->pkt_end, i->pos, ff_bytes, len, 0); } getdns-0.9.0/src/debug.h0000664000175100017510000000542512641212403011760 00000000000000/** * * \file debug.h * /brief Macro's for debugging * */ /* * Copyright (c) 2015, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef DEBUG_H #define DEBUG_H #include "config.h" #define DEBUG_ON(...) do { \ struct timeval tv; \ struct tm tm; \ char buf[10]; \ \ gettimeofday(&tv, NULL); \ gmtime_r(&tv.tv_sec, &tm); \ strftime(buf, 10, "%T", &tm); \ fprintf(stderr, "[%s.%.6d] ", buf, (int)tv.tv_usec); \ fprintf(stderr, __VA_ARGS__); \ } while (0) #define DEBUG_NL(...) do { \ struct timeval tv; \ struct tm tm; \ char buf[10]; \ \ gettimeofday(&tv, NULL); \ gmtime_r(&tv.tv_sec, &tm); \ strftime(buf, 10, "%T", &tm); \ fprintf(stderr, "[%s.%.6d] ", buf, (int)tv.tv_usec); \ fprintf(stderr, __VA_ARGS__); \ fprintf(stderr, "\n"); \ } while (0) #define DEBUG_OFF(...) do {} while (0) #if defined(SCHED_DEBUG) && SCHED_DEBUG #include #define DEBUG_SCHED(...) DEBUG_ON(__VA_ARGS__) #else #define DEBUG_SCHED(...) DEBUG_OFF(__VA_ARGS__) #endif #if defined(STUB_DEBUG) && STUB_DEBUG #include #define DEBUG_STUB(...) DEBUG_ON(__VA_ARGS__) #else #define DEBUG_STUB(...) DEBUG_OFF(__VA_ARGS__) #endif #if defined(SEC_DEBUG) && SEC_DEBUG #include #define DEBUG_SEC(...) DEBUG_ON(__VA_ARGS__) #else #define DEBUG_SEC(...) DEBUG_OFF(__VA_ARGS__) #endif #endif /* debug.h */ getdns-0.9.0/src/types-internal.h0000664000175100017510000002720512641212403013650 00000000000000/** * * /brief type declarations private to the getdns library * * These type declarations are not meant to be used by applications calling * the public library functions. */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef TYPES_INTERNAL_H_ #define TYPES_INTERNAL_H_ #include "getdns/getdns.h" #include "getdns/getdns_extra.h" #include "util/rbtree.h" /** * this structure represents a single item in a list or dict */ typedef union getdns_union { void *ptr; getdns_dict *dict; getdns_list *list; getdns_bindata *bindata; uint32_t n; } getdns_union; typedef struct getdns_item { getdns_data_type dtype; getdns_union data; } getdns_item; struct getdns_context; struct getdns_upstreams; struct getdns_upstream; /** * \defgroup strings String Constants * @{ */ #define GETDNS_STR_IPV4 "IPv4" #define GETDNS_STR_IPV6 "IPv6" #define GETDNS_STR_ADDRESS_TYPE "address_type" #define GETDNS_STR_ADDRESS_DATA "address_data" #define GETDNS_STR_PORT "port" #define GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6 "return_both_v4_and_v6" #define GETDNS_STR_KEY_STATUS "status" #define GETDNS_STR_KEY_REPLIES_TREE "replies_tree" #define GETDNS_STR_KEY_REPLIES_FULL "replies_full" #define GETDNS_STR_KEY_JUST_ADDRS "just_address_answers" #define GETDNS_STR_KEY_CANONICAL_NM "canonical_name" #define GETDNS_STR_KEY_ANSWER_TYPE "answer_type" #define GETDNS_STR_KEY_INTERM_ALIASES "intermediate_aliases" #define GETDNS_STR_KEY_NAME "name" #define GETDNS_STR_KEY_HEADER "header" #define GETDNS_STR_KEY_QUESTION "question" #define GETDNS_STR_KEY_ANSWER "answer" #define GETDNS_STR_KEY_TYPE "type" #define GETDNS_STR_KEY_CLASS "class" #define GETDNS_STR_KEY_TTL "ttl" #define GETDNS_STR_KEY_RDATA "rdata" #define GETDNS_STR_KEY_V4_ADDR "ipv4_address" #define GETDNS_STR_KEY_V6_ADDR "ipv6_address" #define GETDNS_STR_KEY_RDATA_RAW "rdata_raw" #define GETDNS_STR_KEY_AUTHORITY "authority" #define GETDNS_STR_KEY_ADDITIONAL "additional" #define GETDNS_STR_KEY_QTYPE "qtype" #define GETDNS_STR_KEY_QCLASS "qclass" #define GETDNS_STR_KEY_QNAME "qname" #define GETDNS_STR_KEY_QR "qr" /* header flags */ #define GETDNS_STR_KEY_ID "id" #define GETDNS_STR_KEY_OPCODE "opcode" #define GETDNS_STR_KEY_RCODE "rcode" #define GETDNS_STR_KEY_AA "aa" #define GETDNS_STR_KEY_TC "tc" #define GETDNS_STR_KEY_RD "rd" #define GETDNS_STR_KEY_RA "ra" #define GETDNS_STR_KEY_AD "ad" #define GETDNS_STR_KEY_CD "cd" #define GETDNS_STR_KEY_Z "z" #define GETDNS_STR_KEY_QDCOUNT "qdcount" #define GETDNS_STR_KEY_ANCOUNT "ancount" #define GETDNS_STR_KEY_NSCOUNT "nscount" #define GETDNS_STR_KEY_ARCOUNT "arcount" #define TIMEOUT_FOREVER ((int64_t)-1) #define ASSERT_UNREACHABLE 0 #define GETDNS_TRANSPORTS_MAX 3 #define GETDNS_UPSTREAM_TRANSPORTS 2 /** @} */ /* declarations */ struct getdns_dns_req; struct getdns_network_req; typedef void (*internal_cb_t)(struct getdns_dns_req *dns_req); #define MF_PLAIN ((void *)&plain_mem_funcs_user_arg) extern void *plain_mem_funcs_user_arg; typedef union { struct { void *(*malloc)(size_t); void *(*realloc)(void *, size_t); void (*free)(void *); } pln; struct { void *(*malloc)(void *userarg, size_t); void *(*realloc)(void *userarg, void *, size_t); void (*free)(void *userarg, void *); } ext; } mf_union; struct mem_funcs { void *mf_arg; mf_union mf; }; struct mem_funcs * priv_getdns_context_mf(getdns_context *context); typedef enum network_req_state_enum { NET_REQ_NOT_SENT, NET_REQ_IN_FLIGHT, NET_REQ_FINISHED, NET_REQ_CANCELED } network_req_state; /** * structure used by validate_extensions() to check extension formats */ typedef struct getdns_extension_format { char *extstring; getdns_data_type exttype; } getdns_extension_format; /* State for async tcp stub resolving */ typedef struct getdns_tcp_state { uint8_t *write_buf; size_t write_buf_len; size_t written; int write_error; uint8_t *read_buf; size_t read_buf_len; uint8_t *read_pos; size_t to_read; } getdns_tcp_state; /** * Request data **/ typedef struct getdns_network_req { /* For storage in upstream->netreq_by_query_id */ _getdns_rbnode_t node; /* the async_id from unbound */ int unbound_id; /* state var */ network_req_state state; /* owner request (contains name) */ struct getdns_dns_req *owner; /* request type */ uint16_t request_type; /* dnssec status */ int dnssec_status; /* tsig status: * GETDNS_DNSSEC_INDETERMINATE means "No TSIG processing" * GETDNS_DNSSEC_INSECURE means "TSIG sent, validate reply" * GETDNS_DNSSEC_SECURE means "Validated" * GETDNS_DNSSEC_BOGUS means "Validation failed" */ int tsig_status; /* For stub resolving */ struct getdns_upstream *upstream; int fd; getdns_transport_list_t transports[GETDNS_TRANSPORTS_MAX]; size_t transport_count; size_t transport_current; getdns_tls_authentication_t tls_auth_min; getdns_eventloop_event event; getdns_tcp_state tcp; uint16_t query_id; int edns_maximum_udp_payload_size; uint16_t max_udp_payload_size; size_t keepalive_sent; /* Network requests scheduled to write after me */ struct getdns_network_req *write_queue_tail; /* Some fields to record info for return_call_reporting */ uint64_t debug_start_time; uint64_t debug_end_time; size_t debug_tls_auth_status; size_t debug_udp; /* When more space is needed for the wire_data response than is * available in wire_data[], it will be allocated seperately. * response will then not point to wire_data anymore. */ uint8_t *query; uint8_t *opt; /* offset of OPT RR in query */ /* each network_req has a set of base options that are * specific to the query, which are static and included when * the network_req is created. When the query is sent out to * a given upstream, some additional options are added that * are specific to the upstream. There can be at most * GETDNS_MAXIMUM_UPSTREAM_OPTION_SPACE bytes of * upstream-specific options. * use _getdns_network_req_clear_upstream_options() and * _getdns_network_req_add_upstream_option() to fiddle with the */ size_t base_query_option_sz; size_t response_len; uint8_t *response; size_t wire_data_sz; uint8_t wire_data[]; } getdns_network_req; /** * dns request - manages a number of network requests and * the initial data passed to getdns_general */ typedef struct getdns_dns_req { /* For storage in context->outbound_requests */ _getdns_rbnode_t node; /* name */ uint8_t name[256]; size_t name_len; getdns_append_name_t append_name; const uint8_t *suffix; size_t suffix_len; int suffix_appended; uint16_t request_class; /* canceled flag */ int canceled; /* context that owns the request */ struct getdns_context *context; /* request extensions */ int dnssec_return_status; int dnssec_return_only_secure; int dnssec_return_validation_chain; #ifdef DNSSEC_ROADBLOCK_AVOIDANCE int dnssec_roadblock_avoidance; int avoid_dnssec_roadblocks; #endif int edns_cookies; int edns_client_subnet_private; uint16_t tls_query_padding_blocksize; int return_call_reporting; int add_warning_for_bad_dns; /* Internally used by return_validation_chain */ int dnssec_ok_checking_disabled; /* internally scheduled request */ internal_cb_t internal_cb; /* event loop */ getdns_eventloop *loop; /* callback data */ getdns_callback_t user_callback; void *user_pointer; /* the transaction id */ getdns_transaction_t trans_id; /* for scheduling timeouts when using libunbound */ getdns_eventloop_event timeout; /* mem funcs */ struct mem_funcs my_mf; /* Stuff for stub resolving */ struct getdns_upstreams *upstreams; /* network requests for this dns request. * The array is terminated with NULL. * * Memory for these netreqs has been allocated by the same malloc * operation that reserved space for this getdns_dns_req. * They will thus be freed as part of the desctruction of this struct, * and do not need to be freed seperately. */ getdns_network_req *netreqs[]; } getdns_dns_req; #define GETDNS_XMALLOC(obj, type, count) \ ((obj).mf_arg == MF_PLAIN \ ? ((type *)(*(obj).mf.pln.malloc)( (count)*sizeof(type))) \ : ((type *)(*(obj).mf.ext.malloc)((obj).mf_arg, (count)*sizeof(type))) \ ) #define GETDNS_XREALLOC(obj, ptr, type, count) \ ((obj).mf_arg == MF_PLAIN \ ? ((type *)(*(obj).mf.pln.realloc)( (ptr), (count)*sizeof(type))) \ : ((type *)(*(obj).mf.ext.realloc)( (obj).mf_arg \ , (ptr), (count)*sizeof(type))) \ ) #define GETDNS_FREE(obj, ptr) \ ((obj).mf_arg == MF_PLAIN \ ? ((*(obj).mf.pln.free)( (ptr))) \ : ((*(obj).mf.ext.free)((obj).mf_arg, (ptr))) \ ) #define GETDNS_NULL_FREE(obj, ptr) \ do { \ if (!(ptr)) \ break; \ if ((obj).mf_arg == MF_PLAIN) \ (*(obj).mf.pln.free)( (ptr)); \ else \ (*(obj).mf.ext.free)((obj).mf_arg, (ptr)); \ (ptr) = NULL; \ } while (0); #define GETDNS_MALLOC(obj, type) GETDNS_XMALLOC(obj, type, 1) #define GETDNS_REALLOC(obj, ptr, type) GETDNS_XREALLOC(obj, ptr, type, 1); /* utility methods */ extern getdns_dict *dnssec_ok_checking_disabled; extern getdns_dict *dnssec_ok_checking_disabled_roadblock_avoidance; extern getdns_dict *dnssec_ok_checking_disabled_avoid_roadblocks; /* dns request utils */ getdns_dns_req *_getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop, const char *name, uint16_t request_type, getdns_dict *extensions); void _getdns_dns_req_free(getdns_dns_req * req); /* network request utils */ getdns_return_t _getdns_network_req_add_upstream_option(getdns_network_req * req, uint16_t code, uint16_t sz, const void* data); void _getdns_network_req_clear_upstream_options(getdns_network_req * req); /* Adds TSIG signature (if needed) and returns query length */ size_t _getdns_network_req_add_tsig(getdns_network_req *req); void _getdns_network_validate_tsig(getdns_network_req *req); void _getdns_netreq_reinit(getdns_network_req *netreq); #endif /* types-internal.h */ getdns-0.9.0/src/dict.h0000664000175100017510000000550312641212403011612 00000000000000/** * * /brief getdns dict data type management functions * * */ /* * Copyright (c) 2013, NLnet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _GETDNS_DICT_H_ #define _GETDNS_DICT_H_ #include "getdns/getdns.h" #include "util/rbtree.h" #include "types-internal.h" /** * this structure represents a single item in a dictionary type */ struct getdns_dict_item { _getdns_rbnode_t node; getdns_item i; }; /** * getdns dictionary data type * Use helper functions getdns_dict_* to manipulate and iterate dictionaries * dict is implemented using the t*() functions for manipulating binary search * trees in the std library. The internal implementation may change so the * application should stick to the helper functions. */ struct getdns_dict { _getdns_rbtree_t root; struct mem_funcs mf; }; inline static getdns_dict *_getdns_dict_create_with_mf(struct mem_funcs *mf) { return getdns_dict_create_with_extended_memory_functions( mf->mf_arg, mf->mf.ext.malloc, mf->mf.ext.realloc, mf->mf.ext.free); } getdns_return_t _getdns_dict_find( const getdns_dict *dict, const char *key, getdns_item **item); getdns_return_t _getdns_dict_find_and_add( getdns_dict *dict, const char *key, getdns_item **item); /* Return 1 (true) if bindata can be interpreted as an * uncompressed dname. */ int _getdns_bindata_is_dname(getdns_bindata *bindata); #endif /* dict.h */ getdns-0.9.0/src/test/0000775000175100017510000000000012641212403011552 500000000000000getdns-0.9.0/src/test/check_getdns_libevent.h0000664000175100017510000000324612641212403016161 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_EVENT2_EVENT_H #include #else # ifndef u_char # define u_char unsigned char # endif #include #endif getdns-0.9.0/src/test/testmessages.h0000664000175100017510000000451212641212403014354 00000000000000/** * \file * \brief display messages to support unit testing */ /* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef TESTMESSAGES_H #define TESTMESSAGES_H 1 /** * call at the start of a test program to display start message */ void tstmsg_prog_begin(char *prognm); /** * call at the end of a test program to display end message */ void tstmsg_prog_end(); /** * call at the start of a test case (after test_prog_begin) * to display case start message */ void tstmsg_case_begin(char *casenm); /** * call at the end of a test case (after test_prog_begin/test_case_begin) * to display case end message */ void tstmsg_case_end(); /** * call to display message regarding the current test case * to display case end message * TODO: add macro to automatically output source file line */ void tstmsg_case_msg(char *msg); #endif /* testmessages.h */ getdns-0.9.0/src/test/check_getdns_hostname.h0000664000175100017510000004312012641212403016162 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_hostname_h_ #define _check_getdns_hostname_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ H O S T N A M E * * * ************************************************************************** */ START_TEST (getdns_hostname_1) { /* * context = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; getdns_transaction_t transaction_id = 0; DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_hostname(context, address, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()"); DICT_DESTROY(address); } END_TEST START_TEST (getdns_hostname_2) { /* * address = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, NULL, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_3) { /* * dict in address does not contain getdns_bindata * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); DICT_CREATE(address); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_4) { /* * dict in address does not contain two names * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *) "IPv4" }; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_5) { /* * dict in address contains names other than adddress_type * and address_data. * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_int(address, "not_address_type", 100), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(address, "not_address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_6) { /* * dict in address contains names address_type * and address_data but data type is not bindata * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_int(address, "address_type", 100), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_int(address, "address_data", 200), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_7) { /* * dict in address contains invalid address_type * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv5" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_8) { /* * dict in address contains invalid address_data * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 5, (void *)"\x08\x08\x08\x08\x08" }; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_9) { /* * callbackfn = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, NULL, &transaction_id, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_10) { /* * dict in address has resolvable IPv4 address * expect: response with correct hostname */ void verify_getdns_hostname_10(struct extracted_response *ex_response); struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, verify_getdns_hostname_10, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST void verify_getdns_hostname_10(struct extracted_response *ex_response) { assert_noerror(ex_response); assert_ptr_in_answer(ex_response); } START_TEST (getdns_hostname_11) { /* * dict in address has unresolvable IPv4 address * expect: response with no hostname */ void verify_getdns_hostname_11(struct extracted_response *ex_response); struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x01\x01\x01\x01" }; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, verify_getdns_hostname_11, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST void verify_getdns_hostname_11(struct extracted_response *ex_response) { assert_nxdomain(ex_response); assert_nodata(ex_response); assert_soa_in_authority(ex_response); } START_TEST (getdns_hostname_12) { /* * dict in address has resolvable IPv6 address * expect: response with correct hostname */ void verify_getdns_hostname_12(struct extracted_response *ex_response); struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv6" }; struct getdns_bindata address_data = { 16, (void *)"\x2a\x04\xb9\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x37" }; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_timeout(context, 10000), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()"); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, verify_getdns_hostname_12, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST void verify_getdns_hostname_12(struct extracted_response *ex_response) { assert_noerror(ex_response); assert_ptr_in_answer(ex_response); } START_TEST (getdns_hostname_13) { /* * dict in address has unresolvable IPv4 address * expect: response with no hostname */ void verify_getdns_hostname_13(struct extracted_response *ex_response); struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv6" }; struct getdns_bindata address_data = { 16, (void *)"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" }; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, verify_getdns_hostname_13, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST void verify_getdns_hostname_13(struct extracted_response *ex_response) { assert_nxdomain(ex_response); assert_nodata(ex_response); assert_soa_in_authority(ex_response); } Suite * getdns_hostname_suite (void) { Suite *s = suite_create ("getdns_hostname()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_hostname_1); tcase_add_test(tc_neg, getdns_hostname_2); tcase_add_test(tc_neg, getdns_hostname_3); tcase_add_test(tc_neg, getdns_hostname_4); tcase_add_test(tc_neg, getdns_hostname_5); tcase_add_test(tc_neg, getdns_hostname_6); tcase_add_test(tc_neg, getdns_hostname_7); tcase_add_test(tc_neg, getdns_hostname_8); tcase_add_test(tc_neg, getdns_hostname_9); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_set_timeout(tc_pos, 10.0); tcase_add_test(tc_pos, getdns_hostname_10); tcase_add_test(tc_pos, getdns_hostname_11); tcase_add_test(tc_pos, getdns_hostname_12); tcase_add_test(tc_pos, getdns_hostname_13); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_dict_set_dict.h0000664000175100017510000001773612641212403017163 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_dict_set_dict_h_ #define _check_getdns_dict_set_dict_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ S E T _ D I C T * * * ************************************************************************** */ START_TEST (getdns_dict_set_dict_1) { /* * this_dict = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_dict *child_dict = NULL; DICT_CREATE(child_dict); ASSERT_RC(getdns_dict_set_dict(this_dict, "dict", child_dict), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_dict()"); DICT_DESTROY(child_dict); } END_TEST START_TEST (getdns_dict_set_dict_2) { /* * name= NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_dict *child_dict = NULL; DICT_CREATE(this_dict); DICT_CREATE(child_dict); ASSERT_RC(getdns_dict_set_dict(this_dict, NULL, child_dict), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_dict()"); DICT_DESTROY(this_dict); DICT_DESTROY(child_dict); } END_TEST START_TEST (getdns_dict_set_dict_3) { /* * child_dict = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_dict *child_dict = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_dict(this_dict, "dict", child_dict), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_dict()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_set_dict_4) { /* * name already exists in dict * Create a dict * Create a second dict containing name = "int" with value = 100 * Add the second dict to the first dict as name = "dict" * Create a third dict containing name = "int" with value = 101 * Add the third dict to the first dict as name = "dict" * Call getdns_dict_get_dict() against the first dict with name = "dict" * Call getdns_dict_get_int() against the retrieved dict for name = "int" * expect: GETDNS_RETURN_GOOD (all functions) * retrieved int should = 101 */ struct getdns_dict *first_dict = NULL; struct getdns_dict *second_dict = NULL; struct getdns_dict *third_dict = NULL; struct getdns_dict *answer = NULL; uint32_t retrieved_int; DICT_CREATE(first_dict); DICT_CREATE(second_dict); ASSERT_RC(getdns_dict_set_int(second_dict, "int", 100), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_dict(first_dict, "dict", second_dict), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); DICT_CREATE(third_dict); ASSERT_RC(getdns_dict_set_int(third_dict, "int", 101), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_dict(first_dict, "dict", third_dict), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_get_dict(first_dict, "dict", &answer), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_dict()"); ASSERT_RC(getdns_dict_get_int(answer, "int", &retrieved_int), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()"); ck_assert_msg(retrieved_int == 101, "Exepected retrieved int == 101, got: %d", retrieved_int); DICT_DESTROY(first_dict); DICT_DESTROY(second_dict); DICT_DESTROY(third_dict); } END_TEST START_TEST (getdns_dict_set_dict_5) { /* * name already exists in dict, changing data type * Create a dict * Create a list * Set list value at index 0 to int 100 * Add the list to the dict as name = "list" * Create a second dict * Add an int to the second dict with name = "int", value = 101 * Add the second dict to the first dict as name = "list" * Call getdns_dict_get_dict to retrieve the second dict * Call getdns_dict_get_int with name = "int" * expect: GETDNS_RETURN_GOOD (all functions) * retrieved int should = 101 */ struct getdns_dict *this_dict = NULL; struct getdns_list *list = NULL; struct getdns_dict *second_dict = NULL; struct getdns_dict *answer = NULL; uint32_t retrieved_int; DICT_CREATE(this_dict); LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, 0, 100), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_dict_set_list(this_dict, "list", list), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); DICT_CREATE(second_dict); ASSERT_RC(getdns_dict_set_int(second_dict, "int", 101), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_dict(this_dict, "list", second_dict), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_get_dict(this_dict, "list", &answer), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_dict()"); ASSERT_RC(getdns_dict_get_int(answer, "int", &retrieved_int), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()"); ck_assert_msg(retrieved_int == 101, "Exepected retrieved int == 101, got: %d", retrieved_int); DICT_DESTROY(this_dict); LIST_DESTROY(list); DICT_DESTROY(second_dict); } END_TEST Suite * getdns_dict_set_dict_suite (void) { Suite *s = suite_create ("getdns_dict_set_dict()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_dict_set_dict_1); tcase_add_test(tc_neg, getdns_dict_set_dict_2); tcase_add_test(tc_neg, getdns_dict_set_dict_3); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_dict_set_dict_4); tcase_add_test(tc_pos, getdns_dict_set_dict_5); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_list_get_dict.h0000664000175100017510000001365312641212403017171 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_list_get_dict_h_ #define _check_getdns_list_get_dict_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ L I S T _ G E T _ D I C T * * * ************************************************************************** */ START_TEST (getdns_list_get_dict_1) { /* * list = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; struct getdns_dict *answer = NULL; ASSERT_RC(getdns_list_get_dict(list, index, &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_dict()"); } END_TEST START_TEST (getdns_list_get_dict_2) { /* * index is out of range * Create a list, add an dict to it, and then attempt * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; struct getdns_dict *answer = NULL; LIST_CREATE(list); DICT_CREATE(answer); ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); index++; ASSERT_RC(getdns_list_get_dict(list, index, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_dict()"); LIST_DESTROY(list); DICT_DESTROY(answer); } END_TEST START_TEST (getdns_list_get_dict_3) { /* * data type at index is not dict * create a list * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED */ struct getdns_list *list = NULL; struct getdns_dict *answer = NULL; size_t index = 0; LIST_CREATE(list); DICT_CREATE(answer); ASSERT_RC(getdns_list_set_int(list, index, 10), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_get_dict(list, index, &answer), GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_dict()"); LIST_DESTROY(list); DICT_DESTROY(answer); } END_TEST START_TEST (getdns_list_get_dict_4) { /* * answer = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; ASSERT_RC(getdns_list_get_dict(list, index, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_dict()"); } END_TEST START_TEST (getdns_list_get_dict_5) { /* * create a list * Create a dict with one int (name = "ten", value = 10) * Call getdns_dict_get_list() with name = "ten" * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED */ struct getdns_dict *dict = NULL; size_t index = 0; struct getdns_dict *answer = NULL; struct getdns_list *list = NULL; uint32_t value; LIST_CREATE(list); DICT_CREATE(dict); ASSERT_RC(getdns_dict_set_int(dict, "ten", 10), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_list_set_dict(list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_list_get_dict(list, index, &answer), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_dict()"); ASSERT_RC(getdns_dict_get_int(answer, "ten", &value), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()"); ck_assert_msg(value == 10, "Expected retrieved int == 10, got: %d", value); LIST_DESTROY(list); DICT_DESTROY(dict); } END_TEST Suite * getdns_list_get_dict_suite (void) { Suite *s = suite_create ("getdns_list_get_dict()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_list_get_dict_1); tcase_add_test(tc_neg, getdns_list_get_dict_2); tcase_add_test(tc_neg, getdns_list_get_dict_3); tcase_add_test(tc_neg, getdns_list_get_dict_4); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_list_get_dict_5); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_convert_alabel_to_ulabel.h0000664000175100017510000001002412641212403021347 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_convert_alabel_to_ulabel_h_ #define _check_getdns_convert_alabel_to_ulabel_h_ /* ************************************************************************************* * * * T E S T S F O R G E T D N S _ C O N V E R T _ A L A B E L _ T O _ U L A B E L * * * ************************************************************************************* */ START_TEST (getdns_convert_alabel_to_ulabel_1) { /* * alabel = NULL * expect: GETDNS_RETURN_GENERIC_ERROR */ char *alabel = NULL; ck_assert_msg( getdns_convert_alabel_to_ulabel( alabel ) == 0, "Was not expecting %d from getdns_convert_alabel_to_ulabel()", getdns_convert_alabel_to_ulabel( alabel ) ); } END_TEST START_TEST (getdns_convert_alabel_to_ulabel_2) { /* * alabel = invalid characters * expect: GETDNS_RETURN_GENERIC_ERROR */ char *alabel = "#$%_"; ck_assert_msg(strcmp( getdns_convert_alabel_to_ulabel( alabel ), "#$%_" ) == 0, "Was not expecting %s from getdns_convert_alabel_to_ulabel()", getdns_convert_alabel_to_ulabel( alabel ) ); } END_TEST START_TEST (getdns_convert_alabel_to_ulabel_3) { /* * alabel = valid characters (ace must begin with prefix "xn--" and be followed by a valid puny algorithm output; length limited to 59 chars) * expect: GETDNS_RETURN_GOOD */ char *alabel = "xn--caf-dma"; ck_assert_msg(strcmp( getdns_convert_alabel_to_ulabel( alabel ), "café" ) == 0, "Was not expecting %s from getdns_convert_alabel_to_ulabel()", getdns_convert_alabel_to_ulabel( alabel ) ); } END_TEST Suite * getdns_convert_alabel_to_ulabel_suite (void) { Suite *s = suite_create ("getdns_convert_alabel_to_ulabel()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_convert_alabel_to_ulabel_1); tcase_add_test(tc_neg, getdns_convert_alabel_to_ulabel_2); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_convert_alabel_to_ulabel_3); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_common.h0000664000175100017510000002067212641212403015643 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_common_h_ #define _check_getdns_common_h_ #include "getdns/getdns.h" #include "getdns/getdns_extra.h" #define TRUE 1 #define FALSE 0 #define MAXLEN 200 extern int callback_called; extern int callback_completed; extern int callback_canceled; extern uint16_t expected_changed_item; struct extracted_response { uint32_t top_answer_type; struct getdns_bindata *top_canonical_name; struct getdns_list *just_address_answers; struct getdns_list *replies_full; struct getdns_list *replies_tree; struct getdns_dict *replies_tree_sub_dict; struct getdns_list *additional; struct getdns_list *answer; uint32_t answer_type; struct getdns_list *authority; struct getdns_bindata *canonical_name; struct getdns_dict *header; struct getdns_dict *question; uint32_t status; }; /* * The ASSERT_RC macro is used to assert * whether the return code from the last * getdns API call is what was expected. */ #define ASSERT_RC(rc, expected_rc, prefix) \ { \ uint32_t evaluated_rc = rc; \ ck_assert_msg((uint32_t) evaluated_rc == (uint32_t) expected_rc, \ "%s: expecting %s: %d, but received: %d: %s", \ prefix, #expected_rc, expected_rc, evaluated_rc, getdns_get_errorstr_by_id((uint16_t)evaluated_rc)); \ } /* * The CONTEXT_CREATE macro is used to * create a context and assert the proper * return code is returned. */ #define CONTEXT_CREATE(set_from_os) \ ASSERT_RC(getdns_context_create(&context, set_from_os), \ GETDNS_RETURN_GOOD, \ "Return code from getdns_context_create()"); /* * The CONTEXT_FREE macro is used to * destroy the current context. */ #define CONTEXT_DESTROY \ getdns_context_destroy(context); /* * The EVENT_BASE_CREATE macro is used to * create an event base and put it in the * context. */ #define EVENT_BASE_CREATE eventloop = create_event_base(context); /* * The RUN_EVENT_LOOP macro calls the event loop. */ #define RUN_EVENT_LOOP run_event_loop(context, eventloop); /* * The LIST_CREATE macro simply creates a * list and verifies the returned pointer * is not NULL. */ #define LIST_CREATE(list) \ list = getdns_list_create(); \ ck_assert_msg(list != NULL, \ "NULL pointer returned by getdns_list_create()"); /* * The LIST_DESTROY macro destroys a list. */ #define LIST_DESTROY(list) getdns_list_destroy(list); /* * The DICT_CREATE macro simply creates a * dict and verifies the returned pointer * is not NULL. */ #define DICT_CREATE(dict) \ dict = getdns_dict_create(); \ ck_assert_msg(dict != NULL, \ "NULL pointer returned by getdns_dict_create()"); /* * The DICT_DESTROY macro destroys a dict. */ #define DICT_DESTROY(dict) getdns_dict_destroy(dict); /* * The process_response macro declares the * variables needed to house the response and * calls the function that extracts it. */ #define EXTRACT_RESPONSE \ struct extracted_response ex_response; \ extract_response(response, &ex_response); // // FUNCTION DECLARATIONS // #define EXTRACT_LOCAL_RESPONSE \ struct extracted_response ex_response; \ extract_local_response(response, &ex_response); // // FUNCTION DECLARATIONS // /* * extract_response extracts all of the various information * a test may want to look at from the response. */ void extract_response(struct getdns_dict *response, struct extracted_response *ex_response); /* * extract__local_response extracts all of the various information * a test may want to look at from the response for a minimal, local. */ void extract_local_response(struct getdns_dict *response, struct extracted_response *ex_response); /* * assert_noerror asserts that the rcode is 0. */ void assert_noerror(struct extracted_response *ex_response); /* * assert_nodata asserts that ancount in the header and the * of the answer section (list) are both zero. */ void assert_nodata(struct extracted_response *ex_response); /* * assert_address_records_in_answer asserts that ancount in * the header * is >= 1, ancount is equal to the length * of "answer", and that all of * the records in the * answer section are A and/or AAAA resource records based * on the value of the a/aaaa arguments. */ void assert_address_in_answer(struct extracted_response *ex_response, int a, int aaaa); /* * assert_address_in_just_address_answers asserts that * just_address_answers contains at least one address. */ void assert_address_in_just_address_answers(struct extracted_response *ex_response); /* * assert_nxdomain asserts that an NXDOMAIN response was * was returned for the DNS query meaning rcode == 3. */ void assert_nxdomain(struct extracted_response *ex_response); /* * assert_soa_in_authority asserts that a SOA record was * returned in the authority sections. */ void assert_soa_in_authority(struct extracted_response *ex_response); /* * assert_ptr_in_answer asserts that a PTR record was * returned in the answer sections. */ void assert_ptr_in_answer(struct extracted_response *ex_response); void destroy_callbackfn(struct getdns_context *context, getdns_callback_type_t callback_type, struct getdns_dict *response, void *userarg, getdns_transaction_t transaction_id); /* * callbackfn is the callback function given to all * asynchronous query tests. It is expected to only * be called for positive tests and will verify the * response that is returned. */ void callbackfn(struct getdns_context *context, getdns_callback_type_t callback_type, struct getdns_dict *response, void *userarg, getdns_transaction_t transaction_id); /* * update_callbackfn is the callback function given to * getdns_context_set_context_update_callback tests. */ void update_callbackfn(struct getdns_context *context, getdns_context_code_t changed_item); /* run the event loop */ void run_event_loop(struct getdns_context *context, void* eventloop); void* create_event_base(struct getdns_context* context); #endif getdns-0.9.0/src/test/check_getdns_dict_set_bindata.h0000664000175100017510000001615712641212403017636 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_dict_set_bindata_h_ #define _check_getdns_dict_set_bindata_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ S E T _ B I N D A T A * * * ************************************************************************** */ START_TEST (getdns_dict_set_bindata_1) { /* * this_dict = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; ASSERT_RC(getdns_dict_set_bindata(this_dict, "key", &bindata), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_bindata()"); } END_TEST START_TEST (getdns_dict_set_bindata_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_bindata(this_dict, NULL, &bindata), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_bindata()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_set_bindata_3) { /* * child_bindata = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_bindata()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_set_bindata_4) { /* * name already exists in dict * Create a dict * Add bindata to the dict (name = "bindata", value = { 8, "bindata" }) * Add bindata to the dict (name = "bindata", value = { 15, "second_bindata" }) * Call getdns_dict_get_bindata() with name = "bindata" * expect: GETDNS_RETURN_GOOD (all functions) * bindata retrieved = "second_bindata" */ struct getdns_dict *this_dict = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; struct getdns_bindata second_bindata = { 15, (void *)"second_bindata" }; struct getdns_bindata *retrieved_bindata = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &second_bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_get_bindata(this_dict, "bindata", &retrieved_bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_bindata()"); ck_assert_msg(retrieved_bindata->size, second_bindata.size, "Expected retrieved bindata size == %d, got: %d", second_bindata.size, retrieved_bindata->size); ck_assert_msg(strcmp((char *)retrieved_bindata->data, (char *)second_bindata.data) == 0, "Expected retrieved bindata to be \"%s\", got: \"%s\"", (char *)second_bindata.data, (char *)retrieved_bindata->data); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_set_bindata_5) { /* * name already exists in dict, changing data type * Create a dict * Add an int to the dict (name = "int", value = 100) * Add bindata to the dict (name = "int", value = { 8, "bindata" }) * Call getdns_dict_get_bindata() against the dict with name = "int" * expect: GETDNS_RETURN_GOOD (all functions) * retrieved bindata should == "bindata" */ struct getdns_dict *this_dict = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; struct getdns_bindata *retrieved_bindata = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "int", 100), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(this_dict, "int", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_get_bindata(this_dict, "int", &retrieved_bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_bindata()"); ck_assert_msg(retrieved_bindata->size == bindata.size, "Expected retrieved bindata size == %d, got: %d", bindata.size, retrieved_bindata->size); ck_assert_msg(strcmp((char *)retrieved_bindata->data, (char *)bindata.data) == 0, "Expected bindata data to be \"%s\", got: \"%s\"", (char *)bindata.data, (char *)retrieved_bindata->data); DICT_DESTROY(this_dict); } END_TEST Suite * getdns_dict_set_bindata_suite (void) { Suite *s = suite_create ("getdns_dict_set_bindata()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_dict_set_bindata_1); tcase_add_test(tc_neg, getdns_dict_set_bindata_2); tcase_add_test(tc_neg, getdns_dict_set_bindata_3); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_dict_set_bindata_4); tcase_add_test(tc_pos, getdns_dict_set_bindata_5); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_libev.c0000664000175100017510000000463112641212403015444 00000000000000/** * \file * \brief Public interfaces to getdns, include in your application to use getdns API. * * This source was taken from the original pseudo-implementation by * Paul Hoffman. */ /* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "check_getdns_eventloop.h" #include "getdns/getdns_ext_libev.h" #ifdef HAVE_LIBEV_EV_H #include #else #include #endif #include #include "check_getdns_common.h" void run_event_loop_impl(struct getdns_context* context, void* eventloop) { struct ev_loop* loop = (struct ev_loop*) eventloop; ev_run(loop, 0); } void* create_eventloop_impl(struct getdns_context* context) { struct ev_loop* result = ev_default_loop(0); ck_assert_msg(result != NULL, "EV loop creation failed"); ASSERT_RC(getdns_extension_set_libev_loop(context, result), GETDNS_RETURN_GOOD, "Return code from getdns_extension_set_libev_loop()"); return result; } getdns-0.9.0/src/test/check_getdns_dict_get_dict.h0000664000175100017510000002160512641212403017135 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_dict_get_dict_h_ #define _check_getdns_dict_get_dict_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ G E T _ D I C T * * * ************************************************************************** */ START_TEST (getdns_dict_get_dict_1) { /* * this_dict = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_dict *answer = NULL; ASSERT_RC(getdns_dict_get_dict(this_dict, "key", &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_dict()"); } END_TEST START_TEST (getdns_dict_get_dict_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_dict *second_dict = NULL; struct getdns_dict *answer = NULL; DICT_CREATE(this_dict); DICT_CREATE(second_dict); ASSERT_RC(getdns_dict_set_dict(this_dict, "dict", second_dict), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_get_dict(this_dict, NULL, &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_dict()"); DICT_DESTROY(this_dict); DICT_DESTROY(second_dict); } END_TEST START_TEST (getdns_dict_get_dict_3) { /* * name does not exist in dict * Create a dict * Create a second dict with three ints ("ten" = 10, "eleven" = 11, "twelve" = 12) * Add the second dict to the first dict as name = "numbers" * Call getdns_dict_get_dict() against the first dict with name = "letters" * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME */ struct getdns_dict *this_dict = NULL; struct getdns_dict *second_dict = NULL; char *keys[3] = { "ten", "eleven", "twelve" }; uint32_t values[3] = { 10, 11, 12 }; int i; struct getdns_dict *answer = NULL; DICT_CREATE(this_dict); DICT_CREATE(second_dict); for(i = 0; i < 3; i++) { ASSERT_RC(getdns_dict_set_int(second_dict, keys[i], values[i]), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); } ASSERT_RC(getdns_dict_set_dict(this_dict, "numbers", second_dict), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_get_dict(this_dict, "letters", &answer), GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_dict_get_dict()"); DICT_DESTROY(this_dict); DICT_DESTROY(second_dict); } END_TEST START_TEST (getdns_dict_get_dict_4) { /* * data type at name is not a dict * Create a dict with one int (name = "ten", value = 10) * Call getdns_dict_get_dict() with name = "ten" * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED */ struct getdns_dict *this_dict = NULL; struct getdns_dict *answer = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_dict(this_dict, "ten", &answer), GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_dict_get_dict()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_dict_5) { /* * answer = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_dict *second_dict = NULL; DICT_CREATE(this_dict); DICT_CREATE(second_dict); ASSERT_RC(getdns_dict_set_dict(this_dict, "dict", second_dict), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_get_dict(this_dict, "dict", NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_dict()"); DICT_DESTROY(this_dict); DICT_DESTROY(second_dict); } END_TEST START_TEST (getdns_dict_get_dict_6) { /* * successful get dict * Create a dict * Create a second dict with three ints ("ten" = 10, "eleven" = 11, "twelve" = 12) * Add the second dict to the first dict as name = "numbers" * Call getdns_dict_get_dict() against the first dict for name = "numbers" * Call getdns_dict_get_names() against the retrieved "numbers" dict to get a list of names * Call getdns_list_get_length() against the returned list to set a loop counter * Iterate through the names in the list and add the int value from each key to sum * expect: sum == 33 */ struct getdns_dict *this_dict = NULL; struct getdns_dict *second_dict = NULL; char *keys[3] = { "ten", "eleven", "twelve" }; uint32_t values[3] = { 10, 11, 12 }; size_t i; uint32_t sum_of_values = 0; struct getdns_dict *answer = NULL; struct getdns_list *names = NULL; size_t length; struct getdns_bindata *bindata = NULL; uint32_t value; uint32_t sum = 0; DICT_CREATE(this_dict); DICT_CREATE(second_dict); for(i = 0; i < 3; i++) { ASSERT_RC(getdns_dict_set_int(second_dict, keys[i], values[i]), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); sum_of_values += values[i]; } ASSERT_RC(getdns_dict_set_dict(this_dict, "numbers", second_dict), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_get_dict(this_dict, "numbers", &answer), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_dict()"); ASSERT_RC(getdns_dict_get_names(answer, &names), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_names()"); ASSERT_RC(getdns_list_get_length(names, &length), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()"); for(i = 0; i < length; i++) { ASSERT_RC(getdns_list_get_bindata(names, i, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_bindata()"); ASSERT_RC(getdns_dict_get_int(answer, (char *)bindata->data, &value), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()"); sum += value; } ck_assert_msg(sum == sum_of_values, "Sum of int values in dict should == %d, got: %d", sum_of_values, sum); LIST_DESTROY(names); DICT_DESTROY(this_dict); DICT_DESTROY(second_dict); } END_TEST Suite * getdns_dict_get_dict_suite (void) { Suite *s = suite_create ("getdns_dict_get_dict()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_dict_get_dict_1); tcase_add_test(tc_neg, getdns_dict_get_dict_2); tcase_add_test(tc_neg, getdns_dict_get_dict_3); tcase_add_test(tc_neg, getdns_dict_get_dict_4); tcase_add_test(tc_neg, getdns_dict_get_dict_5); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_dict_get_dict_6); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_dict_destroy.h0000664000175100017510000002473412641212403017052 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_dict_destroy_h_ #define _check_getdns_dict_destroy_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ D E S T R O Y * * * ************************************************************************** */ START_TEST (getdns_dict_destroy_1) { /* * this_dict = NULL * expect: nothing */ struct getdns_dict *this_dict = NULL; DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_destroy_2) { /* * build a complex dict and then destroy it * * dict1-> "int" = 1 * -> "bindata" = { 8, "bindata" } * -> "dict" = dict2->"int" = 2 * -> "bindata" = { 8, "bindata" } * -> "dict" = dict3 -> "int" = 3 * -> "bindata" = { 8, "bindata" } * -> "dict" = dict4 -> "int" = 4 * -> "list" = list1 0: int = 5 * -> "list" = list2 0: int = 6 * 1: bindata = { 8, "bindata" } * 2: dict = dict5 -> "bindata" = { 8, "bindata" } * 3: list = list3 0: bindata = { 8, "bindata" } * -> "list" = list4 0: int = 6 * 1: bindata = { 8, "bindata" } * 2: dict6 -> "int" = 8 * -> "bindata" = { 8, "bindata" } * -> "dict" = dict7 -> "int" = 9 * -> "list" = list5 0: int = 10 * 3: list6 0: int = 11 * 1: bindata = { 8, "bindata" } * 2: dict8 -> "bindata" = { 8, "bindata" } * 3: list7 0: bindata = { 8, "bindata" } * * expect: nothing */ struct getdns_bindata bindata = { 8, (void *)"bindata" }; struct getdns_list *list7; struct getdns_dict *dict8; struct getdns_list *list6; struct getdns_list *list5; struct getdns_dict *dict7; struct getdns_dict *dict6; struct getdns_list *list4; struct getdns_list *list3; struct getdns_dict *dict5; struct getdns_list *list2; struct getdns_list *list1; struct getdns_dict *dict4; struct getdns_dict *dict3; struct getdns_dict *dict2; struct getdns_dict *dict1; /* * Build it backwards, with the deepest elements first. */ LIST_CREATE(list7); ASSERT_RC(getdns_list_set_bindata(list7, 0, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); DICT_CREATE(dict8); ASSERT_RC(getdns_dict_set_bindata(dict8, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); LIST_CREATE(list6); ASSERT_RC(getdns_list_set_int(list6, 0, 11), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_set_bindata(list6, 1, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()"); ASSERT_RC(getdns_list_set_dict(list6, 2, dict8), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_list_set_list(list6, 3, list7), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()"); LIST_CREATE(list5); ASSERT_RC(getdns_list_set_int(list5, 0, 10), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); DICT_CREATE(dict7); ASSERT_RC(getdns_dict_set_int(dict7, "int", 9), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); DICT_CREATE(dict6); ASSERT_RC(getdns_dict_set_int(dict6, "int", 8), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(dict6, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_dict(dict6, "dict", dict7), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_set_list(dict6, "list", list5), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); LIST_CREATE(list4); ASSERT_RC(getdns_list_set_int(list4, 0, 7), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_set_bindata(list4, 1, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()"); ASSERT_RC(getdns_list_set_dict(list4, 2, dict6), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_list_set_list(list4, 3, list5), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()"); LIST_CREATE(list3); ASSERT_RC(getdns_list_set_bindata(list3, 0, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()"); DICT_CREATE(dict5); ASSERT_RC(getdns_dict_set_bindata(dict5, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); LIST_CREATE(list2); ASSERT_RC(getdns_list_set_int(list2, 0, 6), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_set_bindata(list2, 1, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()"); ASSERT_RC(getdns_list_set_dict(list2, 2, dict5), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_list_set_list(list2, 3, list3), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()"); LIST_CREATE(list1); ASSERT_RC(getdns_list_set_int(list1, 0, 5), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); DICT_CREATE(dict4); ASSERT_RC(getdns_dict_set_int(dict4, "int", 4), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); DICT_CREATE(dict3); ASSERT_RC(getdns_dict_set_int(dict3, "int", 3), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(dict3, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_dict(dict3, "dict", dict4), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_set_list(dict3, "list", list1), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); DICT_CREATE(dict2); ASSERT_RC(getdns_dict_set_int(dict2, "int", 2), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(dict2, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_dict(dict2, "dict", dict3), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_set_list(dict2, "list", list2), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); DICT_CREATE(dict1); ASSERT_RC(getdns_dict_set_int(dict1, "int", 1), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(dict1, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_dict(dict1, "dict", dict2), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_set_list(dict1, "list", list4), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); /* * Destroy all of the sub-dicts and sub-lists */ LIST_DESTROY(list7); DICT_DESTROY(dict8); LIST_DESTROY(list6); LIST_DESTROY(list5); DICT_DESTROY(dict7); DICT_DESTROY(dict6); LIST_DESTROY(list4); LIST_DESTROY(list3); DICT_DESTROY(dict5); LIST_DESTROY(list2); LIST_DESTROY(list1); DICT_DESTROY(dict4); DICT_DESTROY(dict3); DICT_DESTROY(dict2); /* * And now destroy the mother of all ints, bindata, dicts, and lists */ DICT_DESTROY(dict1); } END_TEST Suite * getdns_dict_destroy_suite (void) { Suite *s = suite_create ("getdns_dict_destroy()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_dict_destroy_1); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_dict_destroy_2); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_list_get_length.h0000664000175100017510000001107512641212403017523 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_list_get_length_h_ #define _check_getdns_list_get_length_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ L I S T _ G E T _ L E N G T H * * * ************************************************************************** */ START_TEST (getdns_list_get_length_1) { /* * list = NULL * expect = GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t length; ASSERT_RC(getdns_list_get_length(list, &length), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_length()"); } END_TEST START_TEST (getdns_list_get_length_2) { /* * answer = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; LIST_CREATE(list); ASSERT_RC(getdns_list_get_length(list, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_length()"); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_length_3) { /* * Create a list, add 3 ints to it, get the length. * expect: GETDNS_RETURN_GOOD * length = 3 */ struct getdns_list *list = NULL; size_t i; size_t length; LIST_CREATE(list); for(i = 0; i < 3; i++) { ASSERT_RC(getdns_list_set_int(list, i, i), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); } ASSERT_RC(getdns_list_get_length(list, &length), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()"); ck_assert_msg(length == 3, "Expected length == 3, got %d", length); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_length_4) { /* * Create a list (empty) and get the length * expect: GETDNS_RETURN_GOOD * length = 3 */ struct getdns_list *list = NULL; size_t length; LIST_CREATE(list); ASSERT_RC(getdns_list_get_length(list, &length), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()"); ck_assert_msg(length == 0, "Expected length == 3, got %d", length); LIST_DESTROY(list); } END_TEST Suite * getdns_list_get_length_suite (void) { Suite *s = suite_create ("getdns_list_get_length()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_list_get_length_1); tcase_add_test(tc_neg, getdns_list_get_length_2); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_list_get_length_3); tcase_add_test(tc_pos, getdns_list_get_length_4); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_context_set_upstream_recursive_servers.h0000664000175100017510000004235312641212403024472 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_context_set_upstream_recursive_servers_h_ #define _check_getdns_context_set_upstream_recursive_servers_h_ /* ****************************************************************************************** * * * T E S T S F O R G E T D N S _ C O N T E X T _ S E T _ S T U B _ R E S O L U T I O N * * * ****************************************************************************************** */ START_TEST (getdns_context_set_upstream_recursive_servers_1) { /* * context is NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_list *upstream_list = NULL; LIST_CREATE(upstream_list); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_upstream_recursive_servers()"); LIST_DESTROY(upstream_list); } END_TEST START_TEST (getdns_context_set_upstream_recursive_servers_2) { /* * upstream_list is NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_upstream_recursive_servers()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_upstream_recursive_servers_3) { /* * create upstream_list * create context * a dict in upstream_list does not contain getdns_bindata */ struct getdns_context *context = NULL; struct getdns_list *upstream_list = NULL; struct getdns_dict *dict = NULL; size_t index = 0; CONTEXT_CREATE(TRUE); LIST_CREATE(upstream_list); DICT_CREATE(dict); ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list), GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()"); CONTEXT_DESTROY; LIST_DESTROY(upstream_list); DICT_DESTROY(dict); } END_TEST START_TEST (getdns_context_set_upstream_recursive_servers_4) { /* * create upstream_list * create context * a dict in upstream_list does not contain two names */ struct getdns_context *context = NULL; struct getdns_list *upstream_list = NULL; struct getdns_dict *dict = NULL; struct getdns_bindata address_type = { 5, (void *) "IPv4" }; size_t index = 0; CONTEXT_CREATE(TRUE); LIST_CREATE(upstream_list); DICT_CREATE(dict); ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list), GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()"); CONTEXT_DESTROY; LIST_DESTROY(upstream_list); DICT_DESTROY(dict); } END_TEST START_TEST (getdns_context_set_upstream_recursive_servers_5) { /* * create upstream_list * create context * a dict in upstream_list contains names other than address_type , address_data, and port */ struct getdns_context *context = NULL; struct getdns_list *upstream_list = NULL; struct getdns_dict *dict = NULL; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; size_t index = 0; CONTEXT_CREATE(TRUE); LIST_CREATE(upstream_list); DICT_CREATE(dict); ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_dict_set_int(dict, "not_address_type", 100), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(dict, "not_address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list), GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()"); CONTEXT_DESTROY; LIST_DESTROY(upstream_list); DICT_DESTROY(dict); } END_TEST START_TEST (getdns_context_set_upstream_recursive_servers_6) { /* * create upstream_list * create context * a dict in upstream_list contains invalid address_ type (not “IPv4” or “IPv6”) */ struct getdns_context *context = NULL; struct getdns_list *upstream_list = NULL; struct getdns_dict *dict = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv5" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; size_t index = 0; CONTEXT_CREATE(TRUE); LIST_CREATE(upstream_list); DICT_CREATE(dict); ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list), GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()"); CONTEXT_DESTROY; LIST_DESTROY(upstream_list); DICT_DESTROY(dict); } END_TEST START_TEST (getdns_context_set_upstream_recursive_servers_7) { /* * create upstream_list * create context * a dict in upstream_list contains named address_type and address_data but the data type isn’t bindata */ struct getdns_context *context = NULL; struct getdns_list *upstream_list = NULL; struct getdns_dict *dict = NULL; size_t index = 0; CONTEXT_CREATE(TRUE); LIST_CREATE(upstream_list); DICT_CREATE(dict); ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_dict_set_int(dict, "address_type", 100), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_int(dict, "address_data", 200), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list), GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()"); CONTEXT_DESTROY; LIST_DESTROY(upstream_list); DICT_DESTROY(dict); } END_TEST START_TEST (getdns_context_set_upstream_recursive_servers_8) { /* * create upstream_list * create context * a dict in upstream_list contains invalid address_data */ struct getdns_context *context = NULL; struct getdns_list *upstream_list = NULL; struct getdns_dict *dict = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv5" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; size_t index = 0; CONTEXT_CREATE(TRUE); LIST_CREATE(upstream_list); DICT_CREATE(dict); ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list), GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()"); CONTEXT_DESTROY; LIST_DESTROY(upstream_list); DICT_DESTROY(dict); } END_TEST START_TEST (getdns_context_set_upstream_recursive_servers_9) { /* * create context * Call getdns_list_create() to create a list * Call getdns_dict_create() to create a list * Create bindata containing “IPv4” */ struct getdns_context *context = NULL; struct getdns_list *upstream_list = NULL; struct getdns_dict *dict = NULL; struct getdns_dict *response = NULL; struct getdns_bindata address_type = { 4, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; size_t index = 0; CONTEXT_CREATE(TRUE); LIST_CREATE(upstream_list); DICT_CREATE(dict); ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_upstream_recursive_servers()"); ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); EXTRACT_RESPONSE; assert_noerror(&ex_response); assert_address_in_answer(&ex_response, TRUE, FALSE); CONTEXT_DESTROY; LIST_DESTROY(upstream_list); DICT_DESTROY(dict); DICT_DESTROY(response); } END_TEST /* This test disabled because travis does not support IPv6 in their * container based infrastructure! */ #if 0 START_TEST (getdns_context_set_upstream_recursive_servers_10) { /* * create context * Call getdns_list_create() to create a list * Call getdns_dict_create() to create a list * Create bindata containing “IPv6” */ struct getdns_context *context = NULL; struct getdns_list *upstream_list = NULL; struct getdns_dict *dict = NULL; struct getdns_dict *response = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv6" }; struct getdns_bindata address_data = { 16, (void *)"\x26\x20\x00\x74\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01" }; size_t index = 0; CONTEXT_CREATE(TRUE); LIST_CREATE(upstream_list); DICT_CREATE(dict); ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_upstream_recursive_servers()"); ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); EXTRACT_RESPONSE; assert_noerror(&ex_response); assert_address_in_answer(&ex_response, TRUE, FALSE); CONTEXT_DESTROY; LIST_DESTROY(upstream_list); DICT_DESTROY(dict); DICT_DESTROY(response); } END_TEST #endif START_TEST (getdns_context_set_upstream_recursive_servers_11) { /* * create context * Call getdns_list_create() to create a list * Call getdns_dict_create() to create a list * Create bindata containing “IPv4” */ struct getdns_context *context = NULL; struct getdns_list *upstream_list = NULL; struct getdns_dict *dict = NULL; struct getdns_dict *response = NULL; struct getdns_bindata address_type = { 4, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; struct getdns_bindata port = { 3, (void *)"53" }; size_t index = 0; CONTEXT_CREATE(TRUE); LIST_CREATE(upstream_list); DICT_CREATE(dict); ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(dict, "53", &port), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_upstream_recursive_servers()"); ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); EXTRACT_RESPONSE; printf("the resp is %s\n", getdns_pretty_print_dict(response)); assert_noerror(&ex_response); assert_address_in_answer(&ex_response, TRUE, FALSE); CONTEXT_DESTROY; LIST_DESTROY(upstream_list); DICT_DESTROY(dict); DICT_DESTROY(response); } END_TEST Suite * getdns_context_set_upstream_recursive_servers_suite (void) { Suite *s = suite_create ("getdns_context_set_upstream_recursive_servers()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_1); tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_2); tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_3); tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_4); tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_5); tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_6); tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_7); tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_8); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_context_set_upstream_recursive_servers_9); /***** tcase_add_test(tc_pos, getdns_context_set_upstream_recursive_servers_10); *****/ tcase_add_test(tc_pos, getdns_context_set_upstream_recursive_servers_11); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_context_set_dns_transport.h0000664000175100017510000001524512641212403021672 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_context_set_dns_transport_h_ #define _check_getdns_context_set_dns_transport_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ C O N T E X T _ S E T _ C O N T E X T _ U P D A T E _ C A L L B A C K * * * ************************************************************************** */ START_TEST (getdns_context_set_dns_transport_1) { /* * context is NULL * expect: GETDNS_RETURN_BAD_CONTEXT */ struct getdns_context *context = NULL; uint16_t value = 302; ASSERT_RC(getdns_context_set_dns_transport(context, value), GETDNS_RETURN_BAD_CONTEXT, "Return code from getdns_context_set_dns_transport()"); } END_TEST START_TEST (getdns_context_set_dns_transport_2) { /* * value is an undefined transport value * expect: GETDNS_RETURN_CONTEXT_UPDATE_FAIL */ struct getdns_context *context = NULL; //uint16_t value = 233; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_dns_transport(context, 233), GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_dns_transport()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_dns_transport_3) { /* * Call getdns_context_set_dns_transport() with value = GETDNS_TRANSPORT_UDP_ONLY * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * getdns_context_set_resolution_type() to GETDNS_RESOLUTION_STUB * expect: GETDNS_CONTEXT_CODE_RESOLUTION_TYPE */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; uint32_t ancount; uint32_t arcount; uint32_t nscount; uint32_t tcp_ancount; uint32_t tcp_arcount; uint32_t tcp_nscount; int udp_sum; int tcp_sum; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_UDP_ONLY), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()"); ASSERT_RC(getdns_general_sync(context, "google.com", 255, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); EXTRACT_RESPONSE; ASSERT_RC(getdns_dict_get_int(ex_response.header, "ancount", &ancount), GETDNS_RETURN_GOOD, "Failed to extract \"nscount\""); ASSERT_RC(getdns_dict_get_int(ex_response.header, "arcount", &arcount), GETDNS_RETURN_GOOD, "Failed to extract \"nscount\""); ASSERT_RC(getdns_dict_get_int(ex_response.header, "nscount", &nscount), GETDNS_RETURN_GOOD, "Failed to extract \"nscount\""); printf("the resp is %s\n", getdns_pretty_print_dict(response)); printf("the ancount is %d\n", ancount); printf("the arcount is %d\n", arcount); printf("the nscount is %d\n", nscount); udp_sum = ancount + arcount + nscount; printf("the udp_sum is %d\n", udp_sum); //tcp count ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_TCP_ONLY), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()"); ASSERT_RC(getdns_general_sync(context, "google.com", 255, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); struct extracted_response ex_response1; extract_response(response, &ex_response1); ASSERT_RC(getdns_dict_get_int(ex_response1.header, "ancount", &tcp_ancount), GETDNS_RETURN_GOOD, "Failed to extract \"nscount\""); ASSERT_RC(getdns_dict_get_int(ex_response1.header, "arcount", &tcp_arcount), GETDNS_RETURN_GOOD, "Failed to extract \"nscount\""); ASSERT_RC(getdns_dict_get_int(ex_response1.header, "nscount", &tcp_nscount), GETDNS_RETURN_GOOD, "Failed to extract \"nscount\""); printf("the resp is %s\n", getdns_pretty_print_dict(response)); printf("the tcp_ancount is %d\n", tcp_ancount); printf("the tcp_arcount is %d\n", tcp_arcount); printf("the tcp_nscount is %d\n", tcp_nscount); tcp_sum = tcp_ancount + tcp_arcount + tcp_nscount; printf("the tcp_sum is %d\n", udp_sum); CONTEXT_DESTROY; } END_TEST Suite * getdns_context_set_dns_transport_suite (void) { Suite *s = suite_create ("getdns_context_set_dns_transport()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_context_set_dns_transport_1); tcase_add_test(tc_neg, getdns_context_set_dns_transport_2); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_context_set_dns_transport_3); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/testscript.sh0000775000175100017510000000566212641212403014246 00000000000000#!/bin/sh # Copyright (c) 2013, Verisign, Inc., NLNet Labs # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the names of the copyright holders nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # run $1 > $2 and exit on failure to execute runit () { echo -n "Test $1:" ./$1 > $2 if test $? -ne 0; then echo " failed (execution failed)" exit 1 fi } # check output files $1 and $2, exit on failure diffit () { if diff $1 $2; then echo " OK" else echo " failed (differences above)" exit 1 fi } # check output of program $1, known_good must be in $1.good checkoutput () { runit $1 output diffit output $1.good } # filter out TTL and bindata stuff from $1 to $2 filterout () { sed -e '/"ttl"/d' -e '/"ipv4_address"/d' -e '/"ipv6_address"/d' -e '/"rdata_raw"/d' -e '/$2 } # like checkoutput but removes addresses and TTLs and bindata # this makes the test almost useless, but it tests runtime lookup # and the structure of the answer format, against the live internet. checkpacket () { runit $1 output cp $1.good output.good filterout output output2 filterout output.good output2.good diffit output2 output2.good } echo "./check_getdns" ./check_getdns if test $? -ne 0; then echo " failed (unit test execution failed)" exit 1 fi checkoutput tests_dict checkoutput tests_list # the packets are too different to compare for people #checkpacket tests_stub_async #checkpacket tests_stub_sync runit tests_stub_async output echo " exitcode-OK" runit tests_stub_sync output echo " exitcode-OK" runit tests_dnssec output echo " exitcode-OK" rm -f output output.good output2 output2.good exit 0 getdns-0.9.0/src/test/check_getdns_dict_get_data_type.h0000664000175100017510000002174312641212403020167 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_dict_get_data_type_h_ #define _check_getdns_dict_get_data_type_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ G E T _ D A T A _ T Y P E * * * ************************************************************************** */ START_TEST (getdns_dict_get_data_type_1) { /* * this_dict = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; getdns_data_type answer; ASSERT_RC(getdns_dict_get_data_type(this_dict, "key", &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_data_type()"); } END_TEST START_TEST (getdns_dict_get_data_type_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; getdns_data_type answer; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_data_type(this_dict, NULL, &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_data_type()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_data_type_3) { /* * name does not exist in dict * Create a dict with three keys ("ten" = 10, "eleven" = 11, "twelve" = 12) * Call getdns_dict_get_data_type() with name = "nine" * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME */ struct getdns_dict *this_dict = NULL; char *keys[3] = { "ten", "eleven", "twelve" }; uint32_t values[3] = { 10, 11, 12 }; int i; getdns_data_type answer; DICT_CREATE(this_dict); for(i = 0; i < 3; i++) { ASSERT_RC(getdns_dict_set_int(this_dict, keys[i], values[i]), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); } ASSERT_RC(getdns_dict_get_data_type(this_dict, "nine", &answer), GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_dict_get_names()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_data_type_4) { /* * answer = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_data_type(this_dict, "ten", NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_names()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_data_type_5) { /* * data type is dict * Create a dict * Create a second dict and add it to the first as name = "dict" * Call getdns_dict_get_data_type() for name = "dict" * expect: GETDNS_RETURN_GOOD * retrieved answer should = t_dict */ struct getdns_dict *this_dict = NULL; struct getdns_dict *second_dict = NULL; getdns_data_type answer; DICT_CREATE(this_dict); DICT_CREATE(second_dict); ASSERT_RC(getdns_dict_set_dict(this_dict, "dict", second_dict), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_get_data_type(this_dict, "dict", &answer), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_data_type()"); ck_assert_msg(answer == t_dict, "Expected answer = t_dict (%d), got: %d", t_dict, answer); DICT_DESTROY(this_dict); DICT_DESTROY(second_dict); } END_TEST START_TEST (getdns_dict_get_data_type_6) { /* * data type is list * Create a dict * Create a list and add it to the dict as name = "list" * Call getdns_dict_get_data_type() for name = "list" * expect: GETDNS_RETURN_GOOD * retrieved answer should = t_list */ struct getdns_dict *this_dict = NULL; struct getdns_list *list = NULL; getdns_data_type answer; DICT_CREATE(this_dict); LIST_CREATE(list); ASSERT_RC(getdns_dict_set_list(this_dict, "list", list), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); ASSERT_RC(getdns_dict_get_data_type(this_dict, "list", &answer), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_data_type()"); ck_assert_msg(answer == t_list, "Expected answer = t_list (%d), got: %d", t_list, answer); DICT_DESTROY(this_dict); LIST_DESTROY(list); } END_TEST START_TEST (getdns_dict_get_data_type_7) { /* * data type is bindata * Create a dict * Create some bindata and add it to the dict as name = "bindata" * Call getdns_dict_get_data_type() for name = "bindata" * expect: GETDNS_RETURN_GOOD * retrieved answer should = t_bindata */ struct getdns_dict *this_dict = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; getdns_data_type answer; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_get_data_type(this_dict, "bindata", &answer), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_data_type()"); ck_assert_msg(answer == t_bindata, "Expected answer = t_bindata (%d), got: %d", t_bindata, answer); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_data_type_8) { /* * data type is int * Create a dict * Add an int to the dict as name = "int" * Call getdns_dict_get_data_type() for name = "int" * expect: GETDNS_RETURN_GOOD * retrieved answer should = t_int */ struct getdns_dict *this_dict = NULL; getdns_data_type answer; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "int", 100), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_data_type(this_dict, "int", &answer), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_data_type()"); ck_assert_msg(answer == t_int, "Expected answer = t_int (%d), got: %d", t_int, answer); DICT_DESTROY(this_dict); } END_TEST Suite * getdns_dict_get_data_type_suite (void) { Suite *s = suite_create ("getdns_dict_get_data_type()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_dict_get_data_type_1); tcase_add_test(tc_neg, getdns_dict_get_data_type_2); tcase_add_test(tc_neg, getdns_dict_get_data_type_3); tcase_add_test(tc_neg, getdns_dict_get_data_type_4); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_dict_get_data_type_5); tcase_add_test(tc_pos, getdns_dict_get_data_type_6); tcase_add_test(tc_pos, getdns_dict_get_data_type_7); tcase_add_test(tc_pos, getdns_dict_get_data_type_8); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_general.h0000664000175100017510000003336612641212403015774 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_general_h_ #define _check_getdns_general_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ G E M E R A L * * * ************************************************************************** */ START_TEST (getdns_general_1) { /* * context = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; getdns_transaction_t transaction_id = 0; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general()"); } END_TEST START_TEST (getdns_general_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, NULL, GETDNS_RRTYPE_A, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_3) { /* * name = invalid domain (too many octets) * expect: GETDNS_RETURN_BAD_DOMAIN_NAME */ struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com"; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_A, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_4) { /* * name = invalid domain (label too long) * expect: GETDNS_RETURN_BAD_DOMAIN_NAME */ struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com"; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_A, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_5) { /* * callbackfn = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL, NULL, &transaction_id, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_6) { /* * name = "google.com" * request_type = 0 (minimum valid RRTYPE) * expect: NOERROR/NODATA response: * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ void verify_getdns_general_6(struct extracted_response *ex_response); struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", 0, NULL, verify_getdns_general_6, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST void verify_getdns_general_6(struct extracted_response *ex_response) { assert_noerror(ex_response); assert_nodata(ex_response); } START_TEST (getdns_general_7) { /* * name = "google.com" * request_type = 65279 (maximum unassigned RRTYPE) * expect: NOERROR/NODATA response: * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ void verify_getdns_general_7(struct extracted_response *ex_response); struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", 65279, NULL, verify_getdns_general_7, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST void verify_getdns_general_7(struct extracted_response *ex_response) { assert_noerror(ex_response); assert_nodata(ex_response); } START_TEST (getdns_general_8) { /* * name = "google.com" * request_type = GETDNS_RRTYPE_A * expect: NOERROR response with A records * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount >= 1 (number of records in ANSWER section) * and equals number of A records ("type": 1) in "answer" list */ void verify_getdns_general_8(struct extracted_response *ex_response); struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL, verify_getdns_general_8, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST void verify_getdns_general_8(struct extracted_response *ex_response) { assert_noerror(ex_response); assert_address_in_answer(ex_response, TRUE, FALSE); } START_TEST (getdns_general_9) { /* * name = "google.com" * request_type = GETDNS_RRTYPE_AAAA * expect: NOERROR response with AAAA records * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount >= 1 (number of records in ANSWER section) * and equals number of AAAA records ("type": 28) in "answer" list */ void verify_getdns_general_9(struct extracted_response *ex_response); struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_AAAA, NULL, verify_getdns_general_9, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST void verify_getdns_general_9(struct extracted_response *ex_response) { assert_noerror(ex_response); assert_address_in_answer(ex_response, FALSE, TRUE); } START_TEST (getdns_general_10) { /* * name = "thisdomainsurelydoesntexist.com" * request_type = GETDNS_RRTYPE_TXT` * expect: NXDOMAIN response with SOA record * status = GETDNS_RESPSTATUS_GOOD * rcode = 3 * ancount = 0 (number of records in ANSWER section) * nscount = 1 (number of records in AUTHORITY section) * and SOA record ("type": 6) present in "authority" list */ void verify_getdns_general_10(struct extracted_response *ex_response); struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; const char *name = "thisdomainsurelydoesntexist.com"; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_TXT, NULL, verify_getdns_general_10, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST void verify_getdns_general_10(struct extracted_response *ex_response) { assert_nxdomain(ex_response); assert_nodata(ex_response); assert_soa_in_authority(ex_response); } START_TEST (getdns_general_11) { /* * name = "willem.getdnsapi.net" and unbound zone * request_type = GETDNS_RRTYPE_MX * expect: NOERROR/NODATA response: * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ void verify_getdns_general_11(struct extracted_response *ex_response); struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "willem.getdnsapi.net", GETDNS_RRTYPE_MX, NULL, verify_getdns_general_11, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST void verify_getdns_general_11(struct extracted_response *ex_response) { assert_noerror(ex_response); assert_nodata(ex_response); } START_TEST (getdns_general_12) { /* * name = "google.com" need to swap this out for max domain name length with max lable length` * request_type = GETDNS_RRTYPE_A * expect: NOERROR response with A records * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount >= 1 (number of records in ANSWER section) * and equals number of A records ("type": 1) in "answer" list */ void verify_getdns_general_12(struct extracted_response *ex_response); struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL, verify_getdns_general_12, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST void verify_getdns_general_12(struct extracted_response *ex_response) { assert_noerror(ex_response); assert_address_in_answer(ex_response, TRUE, FALSE); } Suite * getdns_general_suite (void) { Suite *s = suite_create ("getdns_general()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_general_1); tcase_add_test(tc_neg, getdns_general_2); tcase_add_test(tc_neg, getdns_general_3); tcase_add_test(tc_neg, getdns_general_4); tcase_add_test(tc_neg, getdns_general_5); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_general_6); tcase_add_test(tc_pos, getdns_general_7); tcase_add_test(tc_pos, getdns_general_8); tcase_add_test(tc_pos, getdns_general_9); tcase_add_test(tc_pos, getdns_general_10); tcase_add_test(tc_pos, getdns_general_11); tcase_add_test(tc_pos, getdns_general_12); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_hostname_sync.h0000664000175100017510000003757112641212403017233 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_hostname_sync_h_ #define _check_getdns_hostname_sync_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ H O S T N A M E _ S Y N C * * * ************************************************************************** */ START_TEST (getdns_hostname_sync_1) { /* * context = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; struct getdns_dict *response = NULL; DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname_sync()"); DICT_DESTROY(address); } END_TEST START_TEST (getdns_hostname_sync_2) { /* * address = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_hostname_sync(context, NULL, NULL, &response), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname_sync()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_sync_3) { /* * response = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_hostname_sync(context, address, NULL, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname_sync()"); DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_sync_4) { /* * dict in address does not contain getdns_bindata * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response), GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname_sync()"); DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_sync_5) { /* * dict in address does not contain two names * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *) "IPv4" }; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response), GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname_sync()"); DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_sync_6) { /* * dict in address contains names other than adddress_type * and address_data. * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_int(address, "not_address_type", 100), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(address, "not_address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response), GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname_sync()"); DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_sync_7) { /* * dict in address contains names address_type * and address_data but data type is not bindata * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_int(address, "address_type", 100), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_int(address, "address_data", 200), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response), GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_hostname_sync()"); DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_sync_8) { /* * dict in address contains invalid address_type * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv5" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname_sync()"); DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_sync_9) { /* * dict in address contains invalid address_data * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 5, (void *)"\x08\x08\x08\x08\x08" }; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname_sync()"); DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_sync_10) { /* * dict in address has resolvable IPv4 address * expect: response with correct hostnam */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_hostname_sync()"); EXTRACT_RESPONSE; assert_noerror(&ex_response); assert_ptr_in_answer(&ex_response); DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_sync_11) { /* * dict in address has unresolvable IPv4 address * expect: response with no hostname */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x01\x01\x01\x01" }; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_hostname_sync()"); EXTRACT_RESPONSE; assert_nxdomain(&ex_response); assert_nodata(&ex_response); assert_soa_in_authority(&ex_response); DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_sync_12) { /* * dict in address has resolvable IPv6 address * expect: response with correct hostnam */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv6" }; struct getdns_bindata address_data = { 16, (void *)"\x2a\x04\xb9\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x37" }; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_timeout(context, 10000), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()"); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_hostname_sync()"); EXTRACT_RESPONSE; assert_noerror(&ex_response); assert_ptr_in_answer(&ex_response); DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_hostname_sync_13) { /* * dict in address has unresolvable IPv6 address * expect: response with no hostname */ struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv6" }; struct getdns_bindata address_data = { 16, (void *)"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" }; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_hostname_sync()"); EXTRACT_RESPONSE; assert_nxdomain(&ex_response); assert_nodata(&ex_response); assert_soa_in_authority(&ex_response); DICT_DESTROY(address); CONTEXT_DESTROY; } END_TEST Suite * getdns_hostname_sync_suite (void) { Suite *s = suite_create ("getdns_hostname_sync()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_hostname_sync_1); tcase_add_test(tc_neg, getdns_hostname_sync_2); tcase_add_test(tc_neg, getdns_hostname_sync_3); tcase_add_test(tc_neg, getdns_hostname_sync_4); tcase_add_test(tc_neg, getdns_hostname_sync_5); tcase_add_test(tc_neg, getdns_hostname_sync_6); tcase_add_test(tc_neg, getdns_hostname_sync_7); tcase_add_test(tc_neg, getdns_hostname_sync_8); tcase_add_test(tc_neg, getdns_hostname_sync_9); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_set_timeout(tc_pos, 10.0); tcase_add_test(tc_pos, getdns_hostname_sync_10); tcase_add_test(tc_pos, getdns_hostname_sync_11); tcase_add_test(tc_pos, getdns_hostname_sync_12); tcase_add_test(tc_pos, getdns_hostname_sync_13); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/Makefile.in0000664000175100017510000003451012641212403013542 00000000000000# # @configure_input@ # # Copyright (c) 2013, Verisign, Inc., NLNet Labs # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the names of the copyright holders nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package = @PACKAGE_NAME@ version = @PACKAGE_VERSION@ tarname = @PACKAGE_TARNAME@ distdir = $(tarname)-$(version) prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ INSTALL = @INSTALL@ LIBTOOL = ../../libtool srcdir = @srcdir@ have_libevent = @have_libevent@ have_libuv = @have_libuv@ have_libev = @have_libev@ NOLIBCHECK = @NOLIBCHECK@ NOLIBLDNS = @NOLIBLDNS@ EXTENSION_LIBEVENT_EXT_LIBS=@EXTENSION_LIBEVENT_EXT_LIBS@ EXTENSION_LIBEVENT_LDFLAGS=@EXTENSION_LIBEVENT_LDFLAGS@ EXTENSION_LIBUV_EXT_LIBS=@EXTENSION_LIBUV_EXT_LIBS@ EXTENSION_LIBUV_LDFLAGS=@EXTENSION_LIBUV_LDFLAGS@ EXTENSION_LIBEV_EXT_LIBS=@EXTENSION_LIBEV_EXT_LIBS@ EXTENSION_LIBEV_LDFLAGS=@EXTENSION_LIBEV_LDFLAGS@ CHECK_GETDNS=@CHECK_GETDNS@ CHECK_UV_PROG=@CHECK_UV_PROG@ CHECK_EVENT_PROG=@CHECK_EVENT_PROG@ CHECK_EV_PROG=@CHECK_EV_PROG@ CC=@CC@ CFLAGS=-I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@ @CPPFLAGS@ LDFLAGS=-L.. @LDFLAGS@ LDLIBS=../libgetdns.la @LIBS@ CHECK_LIBS=@CHECK_LIBS@ CHECK_CFLAGS=@CHECK_CFLAGS@ LDNS_LIBS=@LDNS_LIBS@ LDNS_CFLAGS=@LDNS_CFLAGS@ LDNS_LDFLAGS=@LDNS_LDFLAGS@ CHECK_OBJS=check_getdns_common.lo check_getdns_context_set_timeout.lo \ check_getdns.lo check_getdns_transport.lo ALL_OBJS=$(CHECK_OBJS) check_getdns_libevent.lo check_getdns_libev.lo \ check_getdns_selectloop.lo getdns_query.lo scratchpad.lo \ testmessages.lo tests_dict.lo tests_list.lo tests_namespaces.lo \ tests_stub_async.lo tests_stub_sync.lo NON_C99_OBJS=check_getdns_libuv.lo PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync getdns_query $(CHECK_GETDNS) $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG) .SUFFIXES: .c .o .a .lo .h .c.o: $(CC) $(CFLAGS) -c $< -o $@ .c.lo: $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< -o $@ default: all all: $(PROGRAMS) $(ALL_OBJS): $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(LDNS_CFLAGS) -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 $@ tests_dict: tests_dict.lo testmessages.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(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 tests_namespaces: tests_namespaces.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(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 tests_stub_sync: tests_stub_sync.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(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 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) $(LDNS_CFLAGS) $(LDNS_LDFLAGS) $(LDNS_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) $(LDNS_CFLAGS) $(LDNS_LDFLAGS) $(LDNS_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) $(LDNS_CFLAGS) $(LDNS_LDFLAGS) $(LDNS_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) $(LDNS_CFLAGS) $(LDNS_LDFLAGS) $(LDNS_LIBS) ../libgetdns_ext_ev.la $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) getdns_query: getdns_query.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ getdns_query.lo $(LDFLAGS) $(LDLIBS) scratchpad: scratchpad.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ scratchpad.lo $(LDFLAGS) $(LDLIBS) scratchpad.lo: scratchpad.c $(srcdir)/scratchpad.c: scratchpad.template.c [ ! -f $(srcdir)/scratchpad.c ] && cp -p $(srcdir)/scratchpad.template.c $(srcdir)/scratchpad.c || true install: getdns_query $(INSTALL) -m 755 -d $(DESTDIR)$(bindir) $(LIBTOOL) --mode=install cp getdns_query $(DESTDIR)$(bindir) uninstall: $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bindir)/getdns_query nolibcheck: @echo "***" @echo "*** Cannot run unit tests, because they could not be compiled," @echo "*** because libcheck was not found or usable at configure time." @echo "*** To compile and run unit tests make sure libcheck is available" @echo "*** and usable during configuration" @echo "***" @false nolibldns: @echo "***" @echo "*** Cannot run unit tests, because they could not be compiled," @echo "*** because libldns was not found or usable at configure time." @echo "*** To compile and run unit tests make sure libldns is available" @echo "*** and usable during configuration" @echo "***" @false test: $(NOLIBCHECK) $(NOLIBLDNS) all (cd $(srcdir)/../.. && find . -type f -executable -and \( -name "*.[ch]" -or -name "*.html" -or -name "*.in" -or -name "*.good" -or -name "*.ac" \) | awk 'BEGIN{e=0}{print("ERROR! Executable bit found on", $$0);e=1}END{exit(e)}') ./$(CHECK_GETDNS) if test $(have_libevent) = 1 ; then ./$(CHECK_EVENT_PROG) ; fi if test $(have_libev) = 1 ; then ./$(CHECK_EV_PROG) ; fi if test $(have_libuv) = 1 ; then ./$(CHECK_UV_PROG) ; fi @echo "All tests OK" clean: rm -f *.o *.lo $(PROGRAMS) scratchpad rm -rf .libs rm -f check_getdns.log distclean : clean rm -f scratchpad.c rm -f Makefile config.status config.log rm -f check_getdns_uv.core check_getdns.core check_getdns_event.core rm -Rf autom4te.cache $(distdir): FORCE mkdir -p $(distdir)/src cp configure.ac $(distdir) cp configure $(distdir) cp Makefile.in $(distdir) cp src/Makefile.in $(distdir)/src distcheck: $(distdir).tar.gz gzip -cd $(distdir).tar.gz | tar xvf - cd $(distdir) && ./configure cd $(distdir) && $(MAKE) all cd $(distdir) && $(MAKE) check cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall @remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \ if test "$${remaining}" -ne 0; then echo "@@@ $${remaining} file(s) remaining in stage directory!"; \ exit 1; \ fi cd $(distdir) && $(MAKE) clean rm -rf $(distdir) @echo "*** Package $(distdir).tar.gz is ready for distribution" Makefile: $(srcdir)/Makefile.in ../../config.status cd ../.. && ./config.status src/test/Makefile configure.status: configure cd ../.. && ./config.status --recheck depend: (cd $(srcdir) ; awk 'BEGIN{P=1}{if(P)print}/^# Dependencies/{P=0}' Makefile.in > Makefile.in.new ) (blddir=`pwd`; cd $(srcdir) ; gcc -MM -I. -I.. -I"$$blddir"/.. *.c | \ sed -e "s? $$blddir/? ?g" \ -e 's? \([a-z_-]*\)\.\([ch]\)? $$(srcdir)/\1.\2?g' \ -e 's? \$$(srcdir)/config\.h? ../config.h?g' \ -e 's? $$(srcdir)/\.\./getdns/getdns_extra\.h? ../getdns/getdns_extra.h?g' \ -e 's? \.\./getdns/getdns_ext_libevent\.h? $$(srcdir)/../getdns/getdns_ext_libevent.h?g' \ -e 's? \.\./getdns/getdns_ext_libev\.h? $$(srcdir)/../getdns/getdns_ext_libev.h?g' \ -e 's? \.\./getdns/getdns_ext_libuv\.h? $$(srcdir)/../getdns/getdns_ext_libuv.h?g' \ -e 's? \.\./debug\.h? $$(srcdir)/../debug.h?g' \ -e 's!\(.*\)\.o[ :]*!\1.lo \1.o: !g' >> Makefile.in.new ) (cd $(srcdir) ; diff Makefile.in.new Makefile.in && rm Makefile.in.new \ || mv Makefile.in.new Makefile.in ) .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_general.h \ $(srcdir)/check_getdns_general_sync.h $(srcdir)/check_getdns_address.h \ $(srcdir)/check_getdns_address_sync.h $(srcdir)/check_getdns_hostname.h \ $(srcdir)/check_getdns_hostname_sync.h $(srcdir)/check_getdns_context_create.h \ $(srcdir)/check_getdns_context_destroy.h $(srcdir)/check_getdns_cancel_callback.h \ $(srcdir)/check_getdns_list_get_length.h $(srcdir)/check_getdns_list_get_data_type.h \ $(srcdir)/check_getdns_list_get_dict.h $(srcdir)/check_getdns_list_get_list.h \ $(srcdir)/check_getdns_list_get_int.h $(srcdir)/check_getdns_list_get_bindata.h \ $(srcdir)/check_getdns_dict_get_names.h $(srcdir)/check_getdns_dict_get_data_type.h \ $(srcdir)/check_getdns_dict_get_dict.h $(srcdir)/check_getdns_dict_get_list.h \ $(srcdir)/check_getdns_dict_get_bindata.h $(srcdir)/check_getdns_dict_get_int.h \ $(srcdir)/check_getdns_dict_destroy.h $(srcdir)/check_getdns_dict_set_dict.h \ $(srcdir)/check_getdns_dict_set_list.h $(srcdir)/check_getdns_dict_set_bindata.h \ $(srcdir)/check_getdns_dict_set_int.h $(srcdir)/check_getdns_convert_ulabel_to_alabel.h \ $(srcdir)/check_getdns_convert_alabel_to_ulabel.h $(srcdir)/check_getdns_pretty_print_dict.h \ $(srcdir)/check_getdns_display_ip_address.h \ $(srcdir)/check_getdns_context_set_context_update_callback.h \ $(srcdir)/check_getdns_context_set_timeout.h \ $(srcdir)/check_getdns_context_set_upstream_recursive_servers.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 \ $(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 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 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 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 check_getdns_selectloop.lo check_getdns_selectloop.o: $(srcdir)/check_getdns_selectloop.c \ $(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 \ ../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 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 \ ../getdns/getdns_extra.h getdns-0.9.0/src/test/tests_list.c0000664000175100017510000003155212641212403014041 00000000000000/** * \file * unit tests for getdns_list helper routines, these should be used to * perform regression tests, output must be unchanged from canonical output * stored with the sources */ /* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include "testmessages.h" #include "getdns/getdns.h" #define TSTMSGBUF 80 #define GETDNS_LIST_BLOCKSZ 10 /* TODO: might want a separate unit test for _getdns_list_copy() - right now the code gets covered as a result of other tests */ /*---------------------------------------- tst_bindatasetget */ /** * test the list get and set routines */ void tst_bindatasetget(void) { char msg[TSTMSGBUF]; size_t index = 0; getdns_return_t retval; struct getdns_list *list = NULL; struct getdns_bindata *new_bindata = NULL; struct getdns_bindata *ans_bindata = NULL; tstmsg_case_begin("tst_bindatasetget"); list = getdns_list_create(); /* test get function against empty list and with bogus params */ tstmsg_case_msg("getdns_list_get_bindata() empty list"); retval = getdns_list_get_bindata(NULL, index, &ans_bindata); snprintf(msg, sizeof(msg), "getdns_list_get_bindata(NULL, index, &ans_bindata),retval = %d", retval); tstmsg_case_msg(msg); retval = getdns_list_get_bindata(list, index, NULL); snprintf(msg, sizeof(msg), "getdns_list_get_bindata(list, index, NULL),retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_get_bindata(list, 0, &ans_bindata)"); retval = getdns_list_get_bindata(list, 0, &ans_bindata); snprintf(msg, sizeof(msg), "getdns_list_get_bindata,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_get_bindata(list, 1, &ans_bindata)"); retval = getdns_list_get_bindata(list, 1, &ans_bindata); snprintf(msg, sizeof(msg), "getdns_list_get_bindata,retval = %d", retval); tstmsg_case_msg(msg); /* test set function against empty list with bogus params */ tstmsg_case_msg("getdns_list_set_bindata(list, -1, ans_bindata)"); retval = getdns_list_set_bindata(list, -1, NULL); snprintf(msg, sizeof(msg), "getdns_list_set_bindata,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_set_bindata(list, 1, ans_bindata)"); retval = getdns_list_set_bindata(list, 1, NULL); snprintf(msg, sizeof(msg), "getdns_list_set_bindata,retval = %d", retval); tstmsg_case_msg(msg); /* test set and get legitimate use case */ new_bindata = (struct getdns_bindata *) malloc(sizeof(struct getdns_bindata)); new_bindata->size = strlen("foobar") + 1; new_bindata->data = (uint8_t *) "foobar"; getdns_list_set_bindata(list, index, new_bindata); retval = getdns_list_get_bindata(list, index, &ans_bindata); snprintf(msg, sizeof(msg), "getdns_list_set/get_bindata,retval = %d, bindata->data = %d,%s", retval, (int) ans_bindata->size, (char *) ans_bindata->data); tstmsg_case_msg(msg); getdns_list_destroy(list); tstmsg_case_end(); return; } /* tst_bindatasetget */ /*---------------------------------------- tst_dictsetget */ /** * test the dict get and set routines */ void tst_dictsetget(void) { char msg[TSTMSGBUF]; size_t index = 0; uint32_t ans_int; getdns_return_t retval; struct getdns_list *list = NULL; struct getdns_dict *dict = NULL; struct getdns_dict *ansdict = NULL; tstmsg_case_begin("tst_dictsetget"); list = getdns_list_create(); dict = getdns_dict_create(); /* test dict get function against empty list and with bogus params */ tstmsg_case_msg("getdns_list_get_dict() empty list"); retval = getdns_list_get_dict(NULL, index, &dict); snprintf(msg, sizeof(msg), "getdns_list_get_dict(NULL, index, &dict),retval = %d", retval); tstmsg_case_msg(msg); retval = getdns_list_get_dict(list, index, NULL); snprintf(msg, sizeof(msg), "getdns_list_get_dict(list, index, NULL),retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_get_dict(list, 0, &dict)"); retval = getdns_list_get_dict(list, 0, &dict); snprintf(msg, sizeof(msg), "getdns_list_get_dict,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_get_dict(list, 1, &dict)"); retval = getdns_list_get_dict(list, 1, &dict); snprintf(msg, sizeof(msg), "getdns_list_get_dict,retval = %d", retval); tstmsg_case_msg(msg); /* test int set function against empty list with bogus params */ tstmsg_case_msg("getdns_list_set_dict(list, 0, dict)"); retval = getdns_list_set_dict(list, -1, dict); snprintf(msg, sizeof(msg), "getdns_list_set_dict,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_set_dict(list, 1, dict)"); retval = getdns_list_set_dict(list, 1, dict); snprintf(msg, sizeof(msg), "getdns_list_set_dict,retval = %d", retval); tstmsg_case_msg(msg); /* test set and get legitimate use case */ getdns_dict_set_int(dict, "foo", 42); getdns_list_set_dict(list, index, dict); retval = getdns_list_get_dict(list, index, &ansdict); getdns_dict_get_int(ansdict, "foo", &ans_int); snprintf(msg, sizeof(msg), "getdns_list_set/get_dict,retval=%d, ans=%d", retval, ans_int); tstmsg_case_msg(msg); getdns_dict_destroy(dict); getdns_list_destroy(list); tstmsg_case_end(); return; } /* tst_dictsetget */ /*---------------------------------------- tst_listsetget */ /** * test the list get and set routines */ void tst_listsetget(void) { char msg[TSTMSGBUF]; size_t index = 0; getdns_return_t retval; uint32_t ans_int; struct getdns_list *list = NULL; struct getdns_list *new_list = NULL; struct getdns_list *ans_list = NULL; tstmsg_case_begin("tst_listsetget"); list = getdns_list_create(); /* test get function against empty list and with bogus params */ tstmsg_case_msg("getdns_list_get_list() empty list"); retval = getdns_list_get_list(NULL, index, &ans_list); snprintf(msg, sizeof(msg), "getdns_list_get_list(NULL, index, &ans_list),retval = %d", retval); tstmsg_case_msg(msg); retval = getdns_list_get_list(list, index, NULL); snprintf(msg, sizeof(msg), "getdns_list_get_list(list, index, NULL),retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_get_list(list, 0, &ans_list)"); retval = getdns_list_get_list(list, 0, &ans_list); snprintf(msg, sizeof(msg), "getdns_list_get_list,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_get_list(list, 1, &ans_list)"); retval = getdns_list_get_list(list, 1, &ans_list); snprintf(msg, sizeof(msg), "getdns_list_get_list,retval = %d", retval); tstmsg_case_msg(msg); /* test set function against empty list with bogus params */ tstmsg_case_msg("getdns_list_set_list(list, -1, ans_list)"); retval = getdns_list_set_list(list, -1, NULL); snprintf(msg, sizeof(msg), "getdns_list_set_list,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_set_list(list, 1, ans_list)"); retval = getdns_list_set_list(list, 1, NULL); snprintf(msg, sizeof(msg), "getdns_list_set_list,retval = %d", retval); tstmsg_case_msg(msg); /* test set and get legitimate use case */ new_list = getdns_list_create(); getdns_list_set_int(new_list, index, 42); getdns_list_set_list(list, index, new_list); retval = getdns_list_get_list(list, index, &ans_list); getdns_list_get_int(ans_list, 0, &ans_int); snprintf(msg, sizeof(msg), "getdns_list_set/get_list,retval = %d, ans[0] = %d", retval, ans_int); tstmsg_case_msg(msg); getdns_list_destroy(new_list); getdns_list_destroy(list); tstmsg_case_end(); return; } /* tst_listsetget */ /*---------------------------------------- tst_intsetget */ /** * test the int get and set routines */ void tst_intsetget(void) { char msg[TSTMSGBUF]; size_t index = 0; uint32_t ans_int; getdns_return_t retval; struct getdns_list *list = NULL; tstmsg_case_begin("tst_intsetget"); list = getdns_list_create(); /* test int get function against empty list and with bogus params */ tstmsg_case_msg("getdns_list_get_int() empty list"); retval = getdns_list_get_int(NULL, index, &ans_int); snprintf(msg, sizeof(msg), "getdns_list_get_int(NULL, index, &ans_int),retval = %d", retval); tstmsg_case_msg(msg); retval = getdns_list_get_int(list, index, NULL); snprintf(msg, sizeof(msg), "getdns_list_get_int(list, index, NULL),retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_get_int(list, 0, &ans_int)"); retval = getdns_list_get_int(list, 0, &ans_int); snprintf(msg, sizeof(msg), "getdns_list_get_int,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_get_int(list, 1, &ans_int)"); retval = getdns_list_get_int(list, 1, &ans_int); snprintf(msg, sizeof(msg), "getdns_list_get_int,retval = %d", retval); tstmsg_case_msg(msg); /* test int set function against empty list with bogus params */ tstmsg_case_msg("getdns_list_set_int(list, -1, ans_int)"); retval = getdns_list_set_int(list, -1, ans_int); snprintf(msg, sizeof(msg), "getdns_list_set_int,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_set_int(list, 1, ans_int)"); retval = getdns_list_set_int(list, 1, ans_int); snprintf(msg, sizeof(msg), "getdns_list_set_int,retval = %d", retval); tstmsg_case_msg(msg); /* test set and get legitimate use case */ getdns_list_set_int(list, index, 42); retval = getdns_list_get_int(list, index, &ans_int); snprintf(msg, sizeof(msg), "getdns_list_set/get_int,retval = %d, ans = %d", retval, ans_int); tstmsg_case_msg(msg); getdns_list_destroy(list); tstmsg_case_end(); return; } /* tst_intsetget */ /*---------------------------------------- tst_create */ /** * test the create, destroy and allocation functions */ void tst_create(void) { char msg[TSTMSGBUF]; size_t index; int i; getdns_return_t retval; struct getdns_list *list = NULL; /* make sure we can do a simple create/destroy first */ tstmsg_case_begin("tst_create"); tstmsg_case_msg("getdns_list_create"); list = getdns_list_create(); if (list != NULL) { tstmsg_case_msg("getdns_list_destroy(list)"); getdns_list_destroy(list); } tstmsg_case_msg("getdns_list_destroy(NULL)"); getdns_list_destroy(NULL); /* add items until we force it to allocate more storage */ tstmsg_case_msg("getdns_list_set_int(list, i) past block size"); list = getdns_list_create(); for (i = 0; i < GETDNS_LIST_BLOCKSZ + 2; i++) { retval = getdns_list_set_int(list, i, i); if (retval != GETDNS_RETURN_GOOD) { snprintf(msg, sizeof(msg), "getdns_list_set_int,i=%d,retval = %d", i, retval); tstmsg_case_msg(msg); } } tstmsg_case_msg("getdns_list_get_length(list)"); retval = getdns_list_get_length(list, &index); snprintf(msg, sizeof(msg), "list length = %d", (int) index); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_list_get_length()"); retval = getdns_list_get_length(NULL, &index); snprintf(msg, sizeof(msg), "NUll, %i, retval = %d", (int)index, retval); tstmsg_case_msg(msg); retval = getdns_list_get_length(NULL, NULL); snprintf(msg, sizeof(msg), "NUll, NULL, retval = %d", retval); tstmsg_case_msg(msg); retval = getdns_list_get_length(list, NULL); snprintf(msg, sizeof(msg), "list, NULL, retval = %d", retval); tstmsg_case_msg(msg); getdns_list_destroy(list); tstmsg_case_end(); return; } /* tst_create */ /*---------------------------------------- main */ /** * runs unit tests against list management routines */ int main(int argc, char *argv[]) { tstmsg_prog_begin("tests_list"); tst_create(); tst_bindatasetget(); tst_dictsetget(); tst_intsetget(); tst_listsetget(); tstmsg_prog_end(); return 0; } /* main */ /* end tests_list.c */ getdns-0.9.0/src/test/check_getdns_address_sync.h0000664000175100017510000001470012641212403017027 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_address_sync_h_ #define _check_getdns_address_sync_h_ /* ************************************************************** * * * T E S T S F O R G E T D N S _ A D D R E S S _ S Y N C * * * ************************************************************** */ START_TEST (getdns_address_sync_1) { /* * context = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; ASSERT_RC(getdns_address_sync(context, "google.com", NULL, &response), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address_sync()"); } END_TEST START_TEST (getdns_address_sync_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_address_sync(context, NULL, NULL, &response), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address_sync()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_address_sync_3) { /* * name = NULL * expect: GETDNS_RETURN_BAD_DOMAIN_NAME */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com"; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_address_sync(context, name, NULL, &response), GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_address_sync()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_address_sync_4) { /* * name = "google.com" * status = GETDNS_RETURN_GOOD * rcode = 0 */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_address_sync(context, "google.com", NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()"); EXTRACT_RESPONSE; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_address_sync_5) { /* * name = "localhost" * expect: NOERROR response: * expect: GETDNS_RETURN_GOOD * rcode = 0 todo: investigate that proper search order is set for resolution (is local being checked) todo: create zonefile with exact count * ancount = tbd (number of records in ANSWER section) */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_address_sync(context, "localhost", NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()"); EXTRACT_LOCAL_RESPONSE; /* TODO: create reduced forms of these tests for local responses*/ //assert_noerror( &ex_response); //assert_address_in_answer(&ex_response, TRUE, TRUE); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_address_sync_6) { /* * name = "willem.getdnsapi.net" need to replace this with domain from unbound zone * expect: NOERROR/NODATA response: * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_address_sync(context, "willem.getdnsapi.net", NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()"); EXTRACT_RESPONSE; assert_noerror(&ex_response); //assert_soa_in_authority(&ex_response); CONTEXT_DESTROY; } END_TEST Suite * getdns_address_sync_suite (void) { Suite *s = suite_create ("getdns_address_sync()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_address_sync_1); tcase_add_test(tc_neg, getdns_address_sync_2); tcase_add_test(tc_neg, getdns_address_sync_3); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_address_sync_4); tcase_add_test(tc_pos, getdns_address_sync_5); tcase_add_test(tc_pos, getdns_address_sync_6); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_context_create.h0000664000175100017510000000721012641212403017353 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_context_create_h_ #define _check_getdns_context_create_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ C O N T E X T _ C R E A T E * * * ************************************************************************** */ START_TEST (getdns_context_create_1) { /* * context = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ ASSERT_RC(getdns_context_create(NULL, TRUE), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_create()"); } END_TEST START_TEST (getdns_context_create_2) { /* * set_from_os = TRUE * expect: context initialized with operating system info * GETDNS_RETURN_GOOD */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); // TODO: Do something here to verify set_from_os = TRUE CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_create_3) { /* * set_from_os = FALSE * expect: context is not initialized with operating system info * GETDNS_RETURN_GOOD */ struct getdns_context *context = NULL; CONTEXT_CREATE(FALSE); // TODO: Do something here to verify set_from_os = TRUE CONTEXT_DESTROY; } END_TEST Suite * getdns_context_create_suite (void) { Suite *s = suite_create ("getdns_context_create()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_context_create_1); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_context_create_2); tcase_add_test(tc_pos, getdns_context_create_3); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_list_get_data_type.h0000664000175100017510000002115212641212403020211 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_list_get_data_type_h_ #define _check_getdns_list_get_data_type_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ L I S T _ G E T _ D A T A _ T Y P E * * * ************************************************************************** */ START_TEST (getdns_list_get_data_type_1) { /* * list = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; getdns_data_type answer; ASSERT_RC(getdns_list_get_data_type(list, index, &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_data_type()"); } END_TEST START_TEST (getdns_list_get_data_type_2) { /* * index is out of range * Create a list, add an int to it, and then attempt * to get the data type at index 1 * expect: GETDNS_RETURN_NO_SUCH_LIST_ITEM */ struct getdns_list *list = NULL; size_t index = 0; getdns_data_type answer; LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); index++; ASSERT_RC(getdns_list_get_data_type(list, index, &answer), GETDNS_RETURN_NO_SUCH_LIST_ITEM, "Return code from getdns_list_get_data_type()"); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_data_type_3) { /* * answer = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_get_data_type(list, index, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_data_type()"); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_data_type_4) { /* * Create a list (empty) and attempt to get the * data type at index 0. * expect: GETDNS_RETURN_NO_SUCH_LIST_ITEM */ struct getdns_list *list = NULL; size_t index = 0; getdns_data_type answer; LIST_CREATE(list); ASSERT_RC(getdns_list_get_data_type(list, index, &answer), GETDNS_RETURN_NO_SUCH_LIST_ITEM, "Return code from getdns_list_get_data_type()"); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_data_type_5) { /* * Create a list, create a dict, set list value at index 0 * to the dict, and then get the data type at index 0. * data type at index 0. * expect: GETDNS_RETURN_GOOD * answer = t_dict (retrieved data type) */ struct getdns_list *list = NULL; struct getdns_dict *dict = NULL; size_t index = 0; getdns_data_type answer; LIST_CREATE(list); DICT_CREATE(dict); ASSERT_RC(getdns_list_set_dict(list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_list_get_data_type(list, index, &answer), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()"); ck_assert_msg(answer == t_dict, "Wrong data type, expected t_dict: %d, got %d", t_dict, answer); LIST_DESTROY(list); DICT_DESTROY(dict); } END_TEST START_TEST (getdns_list_get_data_type_6) { /* * Create a list, create a second list, set list value at * index 0 to the second list, and then get the data type * at index 0. * expect: GETDNS_RETURN_GOOD * answer = t_list (retrieved data type) */ struct getdns_list *list1 = NULL; struct getdns_list *list2 = NULL; size_t index = 0; getdns_data_type answer; LIST_CREATE(list1); LIST_CREATE(list2); ASSERT_RC(getdns_list_set_list(list1, index, list2), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()"); ASSERT_RC(getdns_list_get_data_type(list1, index, &answer), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()"); ck_assert_msg(answer == t_list, "Wrong data type, expected t_list: %d, got %d", t_list, answer); LIST_DESTROY(list1); LIST_DESTROY(list2); } END_TEST START_TEST (getdns_list_get_data_type_7) { /* * Create a list, create some bindata, set list value at * index 0 to the bindata, and then get the data type at * index 0. * expect: GETDNS_RETURN_GOOD * answer = t_bindata (retrieved data type) */ struct getdns_list *list = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; size_t index = 0; getdns_data_type answer; LIST_CREATE(list); ASSERT_RC(getdns_list_set_bindata(list, index, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()"); ASSERT_RC(getdns_list_get_data_type(list, index, &answer), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()"); ck_assert_msg(answer == t_bindata, "Wrong data type, expected t_bindata: %d, got %d", t_bindata, answer); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_data_type_8) { /* * Create a list, set list value at index 0 to 100 (int), * and then get the data type at index 0. * expect: GETDNS_RETURN_GOOD * answer = t_int (retrieved data type) */ struct getdns_list *list = NULL; size_t index = 0; getdns_data_type answer; LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, index, 100), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_get_data_type(list, index, &answer), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()"); ck_assert_msg(answer == t_int, "Wrong data type, expected t_int: %d, got %d", t_int, answer); LIST_DESTROY(list); } END_TEST Suite * getdns_list_get_data_type_suite (void) { Suite *s = suite_create ("getdns_list_get_data_type()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_list_get_data_type_1); tcase_add_test(tc_neg, getdns_list_get_data_type_2); tcase_add_test(tc_neg, getdns_list_get_data_type_3); tcase_add_test(tc_neg, getdns_list_get_data_type_4); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_list_get_data_type_5); tcase_add_test(tc_pos, getdns_list_get_data_type_6); tcase_add_test(tc_pos, getdns_list_get_data_type_7); tcase_add_test(tc_pos, getdns_list_get_data_type_8); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/tests_stub_sync.good0000664000175100017510000002313312641212403015601 00000000000000The packet { "answer_type": GETDNS_NAMETYPE_DNS, "canonical_name": , "just_address_answers": [ { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": } ], "replies_full": [ , ], "replies_tree": [ { "additional": [], "answer": [ { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A } ], "answer_type": GETDNS_NAMETYPE_DNS, "authority": [], "canonical_name": , "header": { "aa": 0, "ad": 0, "ancount": 5, "arcount": 0, "cd": 0, "id": 45440, "nscount": 0, "opcode": GETDNS_OPCODE_QUERY, "qdcount": 1, "qr": 1, "ra": 1, "rcode": GETDNS_RCODE_NOERROR, "rd": 1, "tc": 0, "z": 0 }, "question": { "qclass": GETDNS_RRCLASS_IN, "qname": , "qtype": GETDNS_RRTYPE_A } }, { "additional": [], "answer": [ { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv6_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_AAAA } ], "answer_type": GETDNS_NAMETYPE_DNS, "authority": [], "canonical_name": , "header": { "aa": 0, "ad": 0, "ancount": 1, "arcount": 0, "cd": 0, "id": 60320, "nscount": 0, "opcode": GETDNS_OPCODE_QUERY, "qdcount": 1, "qr": 1, "ra": 1, "rcode": GETDNS_RCODE_NOERROR, "rd": 1, "tc": 0, "z": 0 }, "question": { "qclass": GETDNS_RRCLASS_IN, "qname": , "qtype": GETDNS_RRTYPE_AAAA } } ], "status": GETDNS_RESPSTATUS_GOOD } The packet { "answer_type": GETDNS_NAMETYPE_DNS, "canonical_name": , "just_address_answers": [], "replies_full": [ ], "replies_tree": [ { "additional": [ { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 85567, "type": GETDNS_RRTYPE_A } ], "answer": [ { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "port": 5222, "priority": 10, "rdata_raw": , "target": , "weight": 0 }, "ttl": 6367, "type": GETDNS_RRTYPE_SRV } ], "answer_type": GETDNS_NAMETYPE_DNS, "authority": [ { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "nsdname": , "rdata_raw": }, "ttl": 85567, "type": GETDNS_RRTYPE_NS }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "nsdname": , "rdata_raw": }, "ttl": 85567, "type": GETDNS_RRTYPE_NS } ], "canonical_name": , "header": { "aa": 0, "ad": 0, "ancount": 1, "arcount": 1, "cd": 0, "id": 44399, "nscount": 2, "opcode": GETDNS_OPCODE_QUERY, "qdcount": 1, "qr": 1, "ra": 1, "rcode": GETDNS_RCODE_NOERROR, "rd": 1, "tc": 0, "z": 0 }, "question": { "qclass": GETDNS_RRCLASS_IN, "qname": , "qtype": GETDNS_RRTYPE_SRV } } ], "status": GETDNS_RESPSTATUS_GOOD } The packet { "answer_type": GETDNS_NAMETYPE_DNS, "canonical_name": , "just_address_answers": [ { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": } ], "replies_full": [ ], "replies_tree": [ { "additional": [], "answer": [ { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A } ], "answer_type": GETDNS_NAMETYPE_DNS, "authority": [], "canonical_name": , "header": { "aa": 0, "ad": 0, "ancount": 5, "arcount": 0, "cd": 0, "id": 28460, "nscount": 0, "opcode": GETDNS_OPCODE_QUERY, "qdcount": 1, "qr": 1, "ra": 1, "rcode": GETDNS_RCODE_NOERROR, "rd": 1, "tc": 0, "z": 0 }, "question": { "qclass": GETDNS_RRCLASS_IN, "qname": , "qtype": GETDNS_RRTYPE_A } } ], "status": GETDNS_RESPSTATUS_GOOD } getdns-0.9.0/src/test/check_getdns_context_set_timeout.h0000664000175100017510000000327612641212403020461 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_context_set_timeout_h_ #define _check_getdns_context_set_timeout_h_ #include Suite * getdns_context_set_timeout_suite (void); #endif getdns-0.9.0/src/test/check_getdns_dict_get_int.h0000664000175100017510000001475012641212403017007 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_dict_get_int_h_ #define _check_getdns_dict_get_int_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ G E T _ I N T * * * ************************************************************************** */ START_TEST (getdns_dict_get_int_1) { /* * this_dict = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; uint32_t answer; ASSERT_RC(getdns_dict_get_int(this_dict, "key", &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_int()"); } END_TEST START_TEST (getdns_dict_get_int_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; uint32_t answer; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "int", 10), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_int(this_dict, NULL, &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_int()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_int_3) { /* * name does not exist in dict * Create a dict with one int (name = "ten", value = 10) * Call getdns_dict_get_int() against the dict with name = "nine" * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME */ struct getdns_dict *this_dict = NULL; uint32_t answer; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_int(this_dict, "nine", &answer), GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_dict_get_int()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_int_4) { /* * data type at name is not int * Create a dict * Create some bindata containing "bindata" and add it to the dict with name = "bindata" * Call getdns_dict_get_int() with name = "bindata" * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED */ struct getdns_dict *this_dict = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; uint32_t answer; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_get_int(this_dict, "bindata", &answer), GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_dict_get_int()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_int_5) { /* * answer = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "int", 10), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_int(this_dict, "int", NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_int()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_int_6) { /* * successful get int * Create a dict with one int (name = "ten", value = 10) * Call getdns_dict_get_int() against the dict with name = "ten" * expect: GETDNS_RETURN_GOOD * int retrievedshould == 10 * */ struct getdns_dict *this_dict = NULL; uint32_t answer; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_int(this_dict, "ten", &answer), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()"); ck_assert_msg(answer == 10, "Expected retrieve int == 10, got: %d", answer); DICT_DESTROY(this_dict); } END_TEST Suite * getdns_dict_get_int_suite (void) { Suite *s = suite_create ("getdns_dict_get_int()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_dict_get_int_1); tcase_add_test(tc_neg, getdns_dict_get_int_2); tcase_add_test(tc_neg, getdns_dict_get_int_3); tcase_add_test(tc_neg, getdns_dict_get_int_4); tcase_add_test(tc_neg, getdns_dict_get_int_5); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_dict_get_int_6); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_common.c0000664000175100017510000003553112641212403015636 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include "getdns/getdns.h" #include "config.h" #include "check_getdns_common.h" #include "check_getdns_eventloop.h" #include #include int callback_called = 0; int callback_completed = 0; int callback_canceled = 0; uint16_t expected_changed_item = 0; int event_loop_type = 0; /* * extract_response extracts all of the various information * a test may want to look at from the response. */ void extract_response(struct getdns_dict *response, struct extracted_response *ex_response) { int have_answer_type = 0; ck_assert_msg(response != NULL, "Response should not be NULL"); /* fprintf(stderr, "%s\n", getdns_pretty_print_dict(response)); */ /* answer_type is optional. See spec section 4: * "The top level of replies_tree can optionally have the following names: * canonical_name (a bindata), intermediate_aliases (a list), * answer_ipv4_address (a bindata), answer_ipv6_address (a bindata), * and answer_type (an int)." * * If it is absent, do not try to decompose the replies_tree, because the * answer most likely came not from DNS. */ have_answer_type = getdns_dict_get_int(response, "answer_type", &ex_response->top_answer_type) == GETDNS_RETURN_GOOD; ASSERT_RC(getdns_dict_get_bindata(response, "canonical_name", &ex_response->top_canonical_name), GETDNS_RETURN_GOOD, "Failed to extract \"top canonical_name\""); /* just_address_answers have to appear only on getdns_address calls */ ex_response->just_address_answers = NULL; (void)getdns_dict_get_list(response, "just_address_answers", &ex_response->just_address_answers); ASSERT_RC(getdns_dict_get_list(response, "replies_full", &ex_response->replies_full), GETDNS_RETURN_GOOD, "Failed to extract \"replies_full\""); ck_assert_msg(ex_response->replies_full != NULL, "replies_full should not be NULL"); ASSERT_RC(getdns_dict_get_list(response, "replies_tree", &ex_response->replies_tree), GETDNS_RETURN_GOOD, "Failed to extract \"replies_tree\""); ck_assert_msg(ex_response->replies_tree != NULL, "replies_tree should not be NULL"); ASSERT_RC(getdns_dict_get_int(response, "status", &ex_response->status), GETDNS_RETURN_GOOD, "Failed to extract \"status\""); if (!have_answer_type || ex_response->top_answer_type != GETDNS_NAMETYPE_DNS) { ex_response->replies_tree_sub_dict = NULL; ex_response->additional = NULL; ex_response->answer = NULL; ex_response->answer_type = 0; ex_response->authority = NULL; ex_response->canonical_name = NULL; ex_response->header = NULL; ex_response->question = NULL; return; } ASSERT_RC(getdns_list_get_dict(ex_response->replies_tree, 0, &ex_response->replies_tree_sub_dict), GETDNS_RETURN_GOOD, "Failed to extract \"replies_tree[0]\""); ck_assert_msg(ex_response->replies_tree_sub_dict != NULL, "replies_tree[0] dict should not be NULL"); ASSERT_RC(getdns_dict_get_list(ex_response->replies_tree_sub_dict, "additional", &ex_response->additional), GETDNS_RETURN_GOOD, "Failed to extract \"additional\""); ck_assert_msg(ex_response->additional != NULL, "additional should not be NULL"); ASSERT_RC(getdns_dict_get_list(ex_response->replies_tree_sub_dict, "answer", &ex_response->answer), GETDNS_RETURN_GOOD, "Failed to extract \"answer\""); ck_assert_msg(ex_response->answer != NULL, "answer should not be NULL"); ASSERT_RC(getdns_dict_get_int(ex_response->replies_tree_sub_dict, "answer_type", &ex_response->answer_type), GETDNS_RETURN_GOOD, "Failed to extract \"answer_type\""); ASSERT_RC(getdns_dict_get_list(ex_response->replies_tree_sub_dict, "authority", &ex_response->authority), GETDNS_RETURN_GOOD, "Failed to extract \"authority\""); ck_assert_msg(ex_response->authority != NULL, "authority should not be NULL"); ASSERT_RC(getdns_dict_get_bindata(ex_response->replies_tree_sub_dict, "canonical_name", &ex_response->canonical_name), GETDNS_RETURN_GOOD, "Failed to extract \"canonical_name\""); ASSERT_RC(getdns_dict_get_dict(ex_response->replies_tree_sub_dict, "header", &ex_response->header), GETDNS_RETURN_GOOD, "Failed to extract \"header\""); ck_assert_msg(ex_response->header != NULL, "header should not be NULL"); ASSERT_RC(getdns_dict_get_dict(ex_response->replies_tree_sub_dict, "question", &ex_response->question), GETDNS_RETURN_GOOD, "Failed to extract \"question\""); ck_assert_msg(ex_response->question != NULL, "question should not be NULL"); } /* * extract_response extracts all of the various information * a test may want to look at from the response. */ void extract_local_response(struct getdns_dict *response, struct extracted_response *ex_response) { ck_assert_msg(response != NULL, "Response should not be NULL"); ASSERT_RC(getdns_dict_get_bindata(response, "canonical_name", &ex_response->top_canonical_name), GETDNS_RETURN_GOOD, "Failed to extract \"top canonical_name\""); /* just_address_answers have to appear only on getdns_address calls */ ex_response->just_address_answers = NULL; (void)getdns_dict_get_list(response, "just_address_answers", &ex_response->just_address_answers); ASSERT_RC(getdns_dict_get_int(response, "status", &ex_response->status), GETDNS_RETURN_GOOD, "Failed to extract \"status\""); } /* * assert_noerror asserts that the rcode is 0 */ void assert_noerror(struct extracted_response *ex_response) { uint32_t rcode; ASSERT_RC(ex_response->status, GETDNS_RESPSTATUS_GOOD, "Unexpected value for \"status\""); ASSERT_RC(getdns_dict_get_int(ex_response->header, "rcode", &rcode), GETDNS_RETURN_GOOD, "Failed to extract \"rcode\""); ck_assert_msg(rcode == 0, "Expected rcode == 0, got %d", rcode); } /* * assert_nodata asserts that ancount in the header and the * of the answer section (list) are both zero. */ void assert_nodata(struct extracted_response *ex_response) { uint32_t ancount; size_t length; ASSERT_RC(getdns_dict_get_int(ex_response->header, "ancount", &ancount), GETDNS_RETURN_GOOD, "Failed to extract \"ancount\""); ck_assert_msg(ancount == 0, "Expected ancount == 0, got %d", ancount); ASSERT_RC(getdns_list_get_length(ex_response->answer, &length), GETDNS_RETURN_GOOD, "Failed to extract \"answer\" length"); ck_assert_msg(length == 0, "Expected \"answer\" length == 0, got %d", length); } /* * assert_address_records_in_answer asserts that ancount in the header * is >= 1, ancount is equal to the length of "answer", and that all of * the records in the answer section are A and/or AAAA resource records * based on the value of the a/aaaa arguments. */ void assert_address_in_answer(struct extracted_response *ex_response, int a, int aaaa) { uint32_t ancount; size_t length; struct getdns_dict *rr_dict; uint32_t type; uint32_t address_records = 0; size_t i; ASSERT_RC(getdns_dict_get_int(ex_response->header, "ancount", &ancount), GETDNS_RETURN_GOOD, "Failed to extract \"ancount\""); ck_assert_msg(ancount >= 1, "Expected ancount >= 1, got %d", ancount); ASSERT_RC(getdns_list_get_length(ex_response->answer, &length), GETDNS_RETURN_GOOD, "Failed to extract \"answer\" length"); ck_assert_msg(length == ancount, "Expected \"answer\" length == ancount: %d, got %d", ancount, length); for(i = 0; i < length; i++) { ASSERT_RC(getdns_list_get_dict(ex_response->answer, i, &rr_dict), GETDNS_RETURN_GOOD, "Failed to extract \"answer\" record"); ASSERT_RC(getdns_dict_get_int(rr_dict, "type", &type), GETDNS_RETURN_GOOD, "Failed to extract \"type\" from answer record"); switch (type) { case GETDNS_RRTYPE_A: if(a && type == GETDNS_RRTYPE_A) address_records++; case GETDNS_RRTYPE_AAAA: if(aaaa && type == GETDNS_RRTYPE_AAAA) address_records++; } } ck_assert_msg(ancount == address_records, "ancount: %d address records mismatch: %d", ancount, address_records); } /* * assert_address_in_just_address_answers asserts that just_address_answers * contains at least one address. */ void assert_address_in_just_address_answers(struct extracted_response *ex_response) { size_t length; ASSERT_RC(getdns_list_get_length(ex_response->just_address_answers, &length), GETDNS_RETURN_GOOD, "Failed to extract \"just_address_answers\" length"); ck_assert_msg(length > 0, "Expected \"just_address_answers\" length > 0, got %d", length); } /* * assert_nxdomain asserts that an NXDOMAIN response was * was returned for the DNS query meaning: * rcode == 3 */ void assert_nxdomain(struct extracted_response *ex_response) { uint32_t rcode; ASSERT_RC(ex_response->status, GETDNS_RESPSTATUS_NO_NAME, "Unexpected value for \"status\""); ASSERT_RC(getdns_dict_get_int(ex_response->header, "rcode", &rcode), GETDNS_RETURN_GOOD, "Failed to extract \"rcode\""); ck_assert_msg(rcode == 3, "Expected rcode == 0, got %d", rcode); } /* * assert_soa_in_authority asserts that a SOA record was * returned in the authority sections. */ void assert_soa_in_authority(struct extracted_response *ex_response) { uint32_t nscount; size_t length; struct getdns_dict *rr_dict; uint32_t type; uint32_t soa_records = 0; size_t i; ASSERT_RC(getdns_dict_get_int(ex_response->header, "nscount", &nscount), GETDNS_RETURN_GOOD, "Failed to extract \"nscount\""); ck_assert_msg(nscount >= 1, "Expected nscount >= 1, got %d", nscount); ASSERT_RC(getdns_list_get_length(ex_response->authority, &length), GETDNS_RETURN_GOOD, "Failed to extract \"authority\" length"); ck_assert_msg(length == nscount, "Expected \"authority\" length == nscount: %d, got %d", nscount, length); for(i = 0; i < length; i++) { ASSERT_RC(getdns_list_get_dict(ex_response->authority, i, &rr_dict), GETDNS_RETURN_GOOD, "Failed to extract \"authority\" record"); ASSERT_RC(getdns_dict_get_int(rr_dict, "type", &type), GETDNS_RETURN_GOOD, "Failed to extract \"type\" from authority record"); if(type == GETDNS_RRTYPE_SOA) soa_records++; } ck_assert_msg(soa_records == 1, "Expected to find one SOA record in authority section, got %d", soa_records); } /* * assert_ptr_in_answer asserts that a PTR record was * returned in the answer sections. */ void assert_ptr_in_answer(struct extracted_response *ex_response) { uint32_t ancount; size_t length; struct getdns_dict *rr_dict; uint32_t type; uint32_t ptr_records = 0; size_t i; ASSERT_RC(getdns_dict_get_int(ex_response->header, "ancount", &ancount), GETDNS_RETURN_GOOD, "Failed to extract \"nscount\""); ck_assert_msg(ancount >= 1, "Expected ancount >= 1, got %d", ancount); ASSERT_RC(getdns_list_get_length(ex_response->answer, &length), GETDNS_RETURN_GOOD, "Failed to extract \"answer\" length"); ck_assert_msg(length == ancount, "Expected \"answer\" length == ancount: %d, got %d", ancount, length); for(i = 0; i < length; i++) { ASSERT_RC(getdns_list_get_dict(ex_response->answer, i, &rr_dict), GETDNS_RETURN_GOOD, "Failed to extract \"answer\" record"); ASSERT_RC(getdns_dict_get_int(rr_dict, "type", &type), GETDNS_RETURN_GOOD, "Failed to extract \"type\" from answer record"); if(type == GETDNS_RRTYPE_PTR) ptr_records++; } ck_assert_msg(ptr_records > 0, "Answer did not contain any PTR records"); } void destroy_callbackfn(struct getdns_context *context, getdns_callback_type_t callback_type, struct getdns_dict *response, void *userarg, getdns_transaction_t transaction_id) { int* flag = (int*)userarg; *flag = 1; getdns_dict_destroy(response); getdns_context_destroy(context); } /* * callbackfn is the callback function given to all * asynchronous query tests. It is expected to only * be called for positive tests and will verify the * response that is returned. */ void callbackfn(struct getdns_context *context, getdns_callback_type_t callback_type, struct getdns_dict *response, void *userarg, getdns_transaction_t transaction_id) { typedef void (*fn_ptr)(struct extracted_response *ex_response); fn_ptr fn = userarg; /* * If userarg is NULL, either a negative test case * erroneously reached the query state, or the value * in userarg (verification function) was somehow * lost in transit. */ ck_assert_msg(userarg != NULL, "Callback called with NULL userarg"); /* * We expect the callback type to be COMPLETE. */ ASSERT_RC(callback_type, GETDNS_CALLBACK_COMPLETE, "Callback type"); /* printf("DICT:\n%s\n", getdns_pretty_print_dict(response)); */ /* * Extract the response. */ EXTRACT_RESPONSE; /* * Call the response verification function that * was passed via userarg. */ fn(&ex_response); } /* * update_callbackfn is expected to only * be called for positive tests and will verify the * response that is returned. */ void update_callbackfn(struct getdns_context *context, getdns_context_code_t changed_item) { ck_assert_msg(changed_item == expected_changed_item, "Expected changed_item == %d, got %d", changed_item, expected_changed_item); } void run_event_loop(struct getdns_context* context, void* eventloop) { run_event_loop_impl(context, eventloop); } void* create_event_base(struct getdns_context* context) { return create_eventloop_impl(context); } getdns-0.9.0/src/test/scratchpad.template.c0000664000175100017510000000061112641212403015562 00000000000000#include #include #include int main() { getdns_return_t r; getdns_context *ctx = NULL; if ((r = getdns_context_create(&ctx, 1))) fprintf(stderr, "Could not create context"); if (ctx) getdns_context_destroy(ctx); if (r) { fprintf(stderr, ": %s\n", getdns_get_errorstr_by_id(r)); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } getdns-0.9.0/src/test/check_getdns_dict_get_names.h0000664000175100017510000001216412641212403017315 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_dict_get_names_h_ #define _check_getdns_dict_get_names_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ G E T _ N A M E S * * * ************************************************************************** */ START_TEST (getdns_dict_get_names_1) { /* * this_dict = NULL * expect = GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_list *answer = NULL; ASSERT_RC(getdns_dict_get_names(this_dict, &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_names()"); } END_TEST START_TEST (getdns_dict_get_names_2) { /* * answer = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_get_names(this_dict, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_names()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_names_3) { /* * Create a dict with three keys ("ten" = 10, "eleven" = 11, "twelve" = 12) * Call getdns_dict_get_names() * Iterate through list and append names together in a single string * expect: string == "teneleventwelve" */ struct getdns_dict *this_dict = NULL; struct getdns_list *answer = NULL; char *keys[3] = { "ten", "eleven", "twelve" }; uint32_t values[3] = { 10, 11, 12 }; int i; size_t length; struct getdns_bindata *key = NULL; char string_buffer[20] = ""; DICT_CREATE(this_dict); for(i = 0; i < 3; i++) { ASSERT_RC(getdns_dict_set_int(this_dict, keys[i], values[i]), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); } ASSERT_RC(getdns_dict_get_names(this_dict, &answer), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_names()"); ASSERT_RC(getdns_list_get_length(answer, &length), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()"); ck_assert_msg(length == 3, "Expected length == 3, got %d", length); for(i = 0; i < length; i++) { ASSERT_RC(getdns_list_get_bindata(answer, i, &key), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_bindata()"); /* concatenate strings, if enough buffer space */ if(strlen(string_buffer) + strlen((char*)key->data) + 1 < sizeof(string_buffer)) { memmove(string_buffer+strlen(string_buffer), key->data, strlen((char*)key->data)+1); } } ck_assert_msg(strcmp(string_buffer, "elevententwelve") == 0, "Expected concatenated names to be \"elevententwelve\", got \"%s\"", string_buffer); LIST_DESTROY(answer); DICT_DESTROY(this_dict); } END_TEST Suite * getdns_dict_get_names_suite (void) { Suite *s = suite_create ("getdns_dict_get_names()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_dict_get_names_1); tcase_add_test(tc_neg, getdns_dict_get_names_2); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_dict_get_names_3); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/tests_namespaces.good0000664000175100017510000002245412641212403015714 00000000000000The packet { "canonical_name": , "just_address_answers": [ { "address_data": , "address_type": }, { "address_data": , "address_type": } ], "replies_full": [], "replies_tree": [], "status": GETDNS_RESPSTATUS_GOOD } The packet { "answer_type": GETDNS_NAMETYPE_DNS, "canonical_name": , "just_address_answers": [ { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": }, { "address_data": , "address_type": } ], "replies_full": [ , ], "replies_tree": [ { "additional": [], "answer": [ { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_A } ], "answer_type": GETDNS_NAMETYPE_DNS, "authority": [], "canonical_name": , "header": { "aa": 0, "ad": 0, "ancount": 6, "arcount": 0, "cd": 0, "id": 55574, "nscount": 0, "opcode": GETDNS_OPCODE_QUERY, "qdcount": 1, "qr": 1, "ra": 1, "rcode": GETDNS_RCODE_NOERROR, "rd": 1, "tc": 0, "z": 0 }, "question": { "qclass": GETDNS_RRCLASS_IN, "qname": , "qtype": GETDNS_RRTYPE_A } }, { "additional": [], "answer": [ { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv6_address": , "rdata_raw": }, "ttl": 300, "type": GETDNS_RRTYPE_AAAA } ], "answer_type": GETDNS_NAMETYPE_DNS, "authority": [], "canonical_name": , "header": { "aa": 0, "ad": 0, "ancount": 1, "arcount": 0, "cd": 0, "id": 58601, "nscount": 0, "opcode": GETDNS_OPCODE_QUERY, "qdcount": 1, "qr": 1, "ra": 1, "rcode": GETDNS_RCODE_NOERROR, "rd": 1, "tc": 0, "z": 0 }, "question": { "qclass": GETDNS_RRCLASS_IN, "qname": , "qtype": GETDNS_RRTYPE_AAAA } } ], "status": GETDNS_RESPSTATUS_GOOD } The packet { "answer_type": GETDNS_NAMETYPE_DNS, "canonical_name": , "just_address_answers": [ { "address_data": , "address_type": } ], "replies_full": [ ], "replies_tree": [ { "additional": [], "answer": [ { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 86400, "type": GETDNS_RRTYPE_A } ], "answer_type": GETDNS_NAMETYPE_DNS, "authority": [], "canonical_name": , "header": { "aa": 1, "ad": 0, "ancount": 1, "arcount": 0, "cd": 0, "id": 21951, "nscount": 0, "opcode": GETDNS_OPCODE_QUERY, "qdcount": 1, "qr": 1, "ra": 1, "rcode": GETDNS_RCODE_NOERROR, "rd": 1, "tc": 0, "z": 0 }, "question": { "qclass": GETDNS_RRCLASS_IN, "qname": , "qtype": GETDNS_RRTYPE_A } } ], "status": GETDNS_RESPSTATUS_GOOD } The packet { "answer_type": GETDNS_NAMETYPE_DNS, "canonical_name": , "just_address_answers": [ { "address_data": , "address_type": }, { "address_data": , "address_type": } ], "replies_full": [ , ], "replies_tree": [ { "additional": [], "answer": [ { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv4_address": , "rdata_raw": }, "ttl": 86400, "type": GETDNS_RRTYPE_A } ], "answer_type": GETDNS_NAMETYPE_DNS, "authority": [], "canonical_name": , "header": { "aa": 1, "ad": 0, "ancount": 1, "arcount": 0, "cd": 0, "id": 36030, "nscount": 0, "opcode": GETDNS_OPCODE_QUERY, "qdcount": 1, "qr": 1, "ra": 1, "rcode": GETDNS_RCODE_NOERROR, "rd": 1, "tc": 0, "z": 0 }, "question": { "qclass": GETDNS_RRCLASS_IN, "qname": , "qtype": GETDNS_RRTYPE_A } }, { "additional": [], "answer": [ { "class": GETDNS_RRCLASS_IN, "name": , "rdata": { "ipv6_address": , "rdata_raw": }, "ttl": 10800, "type": GETDNS_RRTYPE_AAAA } ], "answer_type": GETDNS_NAMETYPE_DNS, "authority": [], "canonical_name": , "header": { "aa": 1, "ad": 0, "ancount": 1, "arcount": 0, "cd": 0, "id": 42580, "nscount": 0, "opcode": GETDNS_OPCODE_QUERY, "qdcount": 1, "qr": 1, "ra": 1, "rcode": GETDNS_RCODE_NOERROR, "rd": 1, "tc": 0, "z": 0 }, "question": { "qclass": GETDNS_RRCLASS_IN, "qname": , "qtype": GETDNS_RRTYPE_AAAA } } ], "status": GETDNS_RESPSTATUS_GOOD }getdns-0.9.0/src/test/check_getdns_list_get_bindata.h0000664000175100017510000001354412641212403017647 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_list_get_bindata_h_ #define _check_getdns_list_get_bindata_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ L I S T _ G E T _ N A M E * * * ************************************************************************** */ START_TEST (getdns_list_get_bindata_1) { /* * list = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; struct getdns_bindata *answer = NULL; ASSERT_RC(getdns_list_get_bindata(list, index, &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_names()"); } END_TEST START_TEST (getdns_list_get_bindata_2) { /* index is out of range * create a list and and set index 0 to an int with a value of 100 * Call getdns_get_list() for index 1 * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); index++; ASSERT_RC(getdns_list_get_bindata(list, index, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_bindata()"); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_bindata_3) { /* data type at index is not int * create a list and set index 0 to an int with a value of 100 * Call getdns_list_get_bindata() for index 0 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED */ struct getdns_list *list = NULL; size_t index = 0; struct getdns_bindata *answer = NULL; LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_get_bindata(list, index, &answer), GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_bindata()"); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_bindata_4) { /* answer is NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; ASSERT_RC(getdns_list_get_bindata(list, index, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_bindata()"); } END_TEST START_TEST (getdns_list_get_bindata_5) { /* * create a list * Create some bindata containing "bindata" and add it to the list with name = "bindata" * Set list value at index 0 via getdns_list_set_list() to the bindata * Call getdns_list_get_list() for index 0 * expect: GETDNS_RETURN_GOOD */ struct getdns_list *list = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; size_t index = 0; struct getdns_bindata *answer = NULL; LIST_CREATE(list); ASSERT_RC(getdns_list_set_bindata(list, index, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()"); ASSERT_RC(getdns_list_get_bindata(list, index, &answer), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_bindata()"); ck_assert_msg(strcmp((char *)answer->data, (char *)bindata.data) == 0, "Expected bindata data to be \"%s\", got: \"%s\"", (char *)bindata.data, (char *)answer->data); LIST_DESTROY(list); } END_TEST Suite * getdns_list_get_bindata_suite (void) { Suite *s = suite_create ("getdns_list_get_bindata()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_list_get_bindata_1); tcase_add_test(tc_neg, getdns_list_get_bindata_2); tcase_add_test(tc_neg, getdns_list_get_bindata_3); tcase_add_test(tc_neg, getdns_list_get_bindata_4); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_list_get_bindata_5); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_general_sync.h0000664000175100017510000002722112641212403017021 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_general_sync_h_ #define _check_getdns_general_sync_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ G E N E R A L _ S Y N C * * * ************************************************************************** */ START_TEST (getdns_general_sync_1) { /* * context = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general_sync()"); } END_TEST START_TEST (getdns_general_sync_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_general_sync(context, NULL, GETDNS_RRTYPE_A, NULL, &response), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general_sync()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_sync_3) { /* * name = invalid domain (too many octets) * expect: GETDNS_RETURN_BAD_DOMAIN_NAME */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com"; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_general_sync(context, name, GETDNS_RRTYPE_A, NULL, &response), GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general_sync()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_sync_4) { /* * name = invalid domain (label too long) * expect: GETDNS_RETURN_BAD_DOMAIN_NAME */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com"; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_general_sync(context, name, GETDNS_RRTYPE_A, NULL, &response), GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general_sync()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_sync_5) { /* * response = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general_sync()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_sync_6) { /* * name = "google.com" * request_type = 0 (minimum valid RRTYPE) * expect: NOERROR/NODATA response: * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_general_sync(context, "google.com", 0, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); EXTRACT_RESPONSE; assert_noerror(&ex_response); assert_nodata(&ex_response); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_sync_7) { /* * name = "google.com" * request_type = 65279 (maximum unassigned RRTYPE) * expect: NOERROR/NODATA response: * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_general_sync(context, "google.com", 65279, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); EXTRACT_RESPONSE; assert_noerror(&ex_response); assert_nodata(&ex_response); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_sync_8) { /* * name = "google.com" * request_type = GETDNS_RRTYPE_A * expect: NOERROR response with A records * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount >= 1 (number of records in ANSWER section) * and equals number of A records ("type": 1) in "answer" list */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); EXTRACT_RESPONSE; assert_noerror(&ex_response); assert_address_in_answer(&ex_response, TRUE, FALSE); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_sync_9) { /* * name = "google.com" * request_type = GETDNS_RRTYPE_AAAA * expect: NOERROR response with AAAA records * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount >= 1 (number of records in ANSWER section) * and equals number of AAAA records ("type": 28) in "answer" list */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_AAAA, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); EXTRACT_RESPONSE; assert_noerror(&ex_response); assert_address_in_answer(&ex_response, FALSE, TRUE); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_sync_10) { /* * name = "thisdomainsurelydoesntexist.com" * request_type = GETDNS_RRTYPE_TXT` * expect: NXDOMAIN response with SOA record * status = GETDNS_RESPSTATUS_GOOD * rcode = 3 * ancount = 0 (number of records in ANSWER section) * nscount = 1 (number of records in AUTHORITY section) * and SOA record ("type": 6) present in "authority" list */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; const char *name = "thisdomainsurelydoesntexist.com"; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_general_sync(context, name, GETDNS_RRTYPE_TXT, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); EXTRACT_RESPONSE; assert_nxdomain(&ex_response); assert_nodata(&ex_response); assert_soa_in_authority(&ex_response); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_sync_11) { /* * name = "willem.getdnsapi.net" an unbound zone (as in no MX) * request_type = GETDNS_RRTYPE_MX * expect: NOERROR/NODATA response: * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_general_sync(context, "willem.getdnsapi.net", GETDNS_RRTYPE_MX, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); EXTRACT_RESPONSE; assert_noerror(&ex_response); assert_nodata(&ex_response); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_general_sync_12) { /* * name = "google.com" need to swap this out for max domain name length with max lable length` * request_type = GETDNS_RRTYPE_A * expect: NOERROR response with A records * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount >= 1 (number of records in ANSWER section) * and equals number of A records ("type": 1) in "answer" list */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); EXTRACT_RESPONSE; assert_noerror(&ex_response); assert_address_in_answer(&ex_response, TRUE, FALSE); CONTEXT_DESTROY; } END_TEST Suite * getdns_general_sync_suite (void) { Suite *s = suite_create ("getdns_general_sync()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_general_sync_1); tcase_add_test(tc_neg, getdns_general_sync_2); tcase_add_test(tc_neg, getdns_general_sync_3); tcase_add_test(tc_neg, getdns_general_sync_4); tcase_add_test(tc_neg, getdns_general_sync_5); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_general_sync_6); tcase_add_test(tc_pos, getdns_general_sync_7); tcase_add_test(tc_pos, getdns_general_sync_8); tcase_add_test(tc_pos, getdns_general_sync_9); tcase_add_test(tc_pos, getdns_general_sync_10); tcase_add_test(tc_pos, getdns_general_sync_11); tcase_add_test(tc_pos, getdns_general_sync_12); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_eventloop.h0000664000175100017510000000404512641212403016362 00000000000000/** * \file * \brief Public interfaces to getdns, include in your application to use getdns API. * * This source was taken from the original pseudo-implementation by * Paul Hoffman. */ /* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* this is used to prevent header conflicts with libevent and libev */ #ifndef _check_getdns_eventloop_h_ #define _check_getdns_eventloop_h_ #include "config.h" #include "getdns/getdns.h" void run_event_loop_impl(struct getdns_context* context, void* eventloop); void* create_eventloop_impl(struct getdns_context* context); #endif getdns-0.9.0/src/test/check_getdns_transport.h0000664000175100017510000000324012641212403016377 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_transport_h_ #define _check_getdns_transport_h_ #include Suite * getdns_transport_suite (void); #endif getdns-0.9.0/src/test/check_getdns_service_sync.h0000664000175100017510000001362012641212403017042 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_service_sync_h_ #define _check_getdns_service_sync_h_ /* ************************************************************* * * * T E S T S F O R G E T D N S _ S E R V I C E _ S Y N C * * * ************************************************************* */ START_TEST (getdns_service_sync_1) { /* * context = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; ASSERT_RC(getdns_service_sync(context, "google.com", NULL, &response), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service_sync()"); } END_TEST START_TEST (getdns_service_sync_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_service_sync(context, NULL, NULL, &response), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service_sync()"); } END_TEST START_TEST (getdns_service_sync_3) { /* * name is invalid (domain name length > 255) * expect: GETDNS_RETURN_BAD_DOMAIN_NAME */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com"; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_service_sync(context, name, NULL, &response), GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_service_sync()"); } END_TEST START_TEST (getdns_service_sync_4) { /* * name is invalid (domain name label length > 63) * expect: GETDNS_RETURN_BAD_DOMAIN_NAME */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com"; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_service_sync(context, name, NULL, &response), GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_service_sync()"); } END_TEST START_TEST (getdns_service_sync_5) { /* * response is NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_service_sync(context, "google.com", NULL, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service_sync()"); } END_TEST START_TEST (getdns_service_sync_7) { /* * rname is (NXDOMAIN) * no extensions * expected: NXDOMAIN response (with SOA record) */ struct getdns_context *context = NULL; struct getdns_dict *response = NULL; const char *name = "labelsizeofsixtythreecharacterscom"; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_service_sync(context, name, NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_service_sync()"); EXTRACT_RESPONSE; assert_nxdomain(&ex_response); assert_nodata(&ex_response); assert_soa_in_authority(&ex_response); } END_TEST Suite * getdns_service_sync_suite (void) { Suite *s = suite_create ("getdns_service_sync()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_service_sync_1); tcase_add_test(tc_neg, getdns_service_sync_2); tcase_add_test(tc_neg, getdns_service_sync_3); tcase_add_test(tc_neg, getdns_service_sync_4); tcase_add_test(tc_neg, getdns_service_sync_5); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_service_sync_7); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/tests_list.good0000664000175100017510000001041012641212403014535 00000000000000TESTPROG tests_list START TESTCASE tests_list:tst_create BEGIN tests_list:tst_create: getdns_list_create tests_list:tst_create: getdns_list_destroy(list) tests_list:tst_create: getdns_list_destroy(NULL) tests_list:tst_create: getdns_list_set_int(list, i) past block size tests_list:tst_create: getdns_list_get_length(list) tests_list:tst_create: list length = 12 tests_list:tst_create: getdns_list_get_length() tests_list:tst_create: NUll, 12, retval = 311 tests_list:tst_create: NUll, NULL, retval = 311 tests_list:tst_create: list, NULL, retval = 311 TESTCASE tests_list:tst_create END TESTCASE tests_list:tst_bindatasetget BEGIN tests_list:tst_bindatasetget: getdns_list_get_bindata() empty list tests_list:tst_bindatasetget: getdns_list_get_bindata(NULL, index, &ans_bindata),retval = 311 tests_list:tst_bindatasetget: getdns_list_get_bindata(list, index, NULL),retval = 311 tests_list:tst_bindatasetget: getdns_list_get_bindata(list, 0, &ans_bindata) tests_list:tst_bindatasetget: getdns_list_get_bindata,retval = 304 tests_list:tst_bindatasetget: getdns_list_get_bindata(list, 1, &ans_bindata) tests_list:tst_bindatasetget: getdns_list_get_bindata,retval = 304 tests_list:tst_bindatasetget: getdns_list_set_bindata(list, -1, ans_bindata) tests_list:tst_bindatasetget: getdns_list_set_bindata,retval = 311 tests_list:tst_bindatasetget: getdns_list_set_bindata(list, 1, ans_bindata) tests_list:tst_bindatasetget: getdns_list_set_bindata,retval = 311 tests_list:tst_bindatasetget: getdns_list_set/get_bindata,retval = 0, bindata->data = 7,foobar TESTCASE tests_list:tst_bindatasetget END TESTCASE tests_list:tst_dictsetget BEGIN tests_list:tst_dictsetget: getdns_list_get_dict() empty list tests_list:tst_dictsetget: getdns_list_get_dict(NULL, index, &dict),retval = 311 tests_list:tst_dictsetget: getdns_list_get_dict(list, index, NULL),retval = 311 tests_list:tst_dictsetget: getdns_list_get_dict(list, 0, &dict) tests_list:tst_dictsetget: getdns_list_get_dict,retval = 304 tests_list:tst_dictsetget: getdns_list_get_dict(list, 1, &dict) tests_list:tst_dictsetget: getdns_list_get_dict,retval = 304 tests_list:tst_dictsetget: getdns_list_set_dict(list, 0, dict) tests_list:tst_dictsetget: getdns_list_set_dict,retval = 304 tests_list:tst_dictsetget: getdns_list_set_dict(list, 1, dict) tests_list:tst_dictsetget: getdns_list_set_dict,retval = 304 tests_list:tst_dictsetget: getdns_list_set/get_dict,retval=0, ans=42 TESTCASE tests_list:tst_dictsetget END TESTCASE tests_list:tst_intsetget BEGIN tests_list:tst_intsetget: getdns_list_get_int() empty list tests_list:tst_intsetget: getdns_list_get_int(NULL, index, &ans_int),retval = 311 tests_list:tst_intsetget: getdns_list_get_int(list, index, NULL),retval = 311 tests_list:tst_intsetget: getdns_list_get_int(list, 0, &ans_int) tests_list:tst_intsetget: getdns_list_get_int,retval = 304 tests_list:tst_intsetget: getdns_list_get_int(list, 1, &ans_int) tests_list:tst_intsetget: getdns_list_get_int,retval = 304 tests_list:tst_intsetget: getdns_list_set_int(list, -1, ans_int) tests_list:tst_intsetget: getdns_list_set_int,retval = 304 tests_list:tst_intsetget: getdns_list_set_int(list, 1, ans_int) tests_list:tst_intsetget: getdns_list_set_int,retval = 304 tests_list:tst_intsetget: getdns_list_set/get_int,retval = 0, ans = 42 TESTCASE tests_list:tst_intsetget END TESTCASE tests_list:tst_listsetget BEGIN tests_list:tst_listsetget: getdns_list_get_list() empty list tests_list:tst_listsetget: getdns_list_get_list(NULL, index, &ans_list),retval = 311 tests_list:tst_listsetget: getdns_list_get_list(list, index, NULL),retval = 311 tests_list:tst_listsetget: getdns_list_get_list(list, 0, &ans_list) tests_list:tst_listsetget: getdns_list_get_list,retval = 304 tests_list:tst_listsetget: getdns_list_get_list(list, 1, &ans_list) tests_list:tst_listsetget: getdns_list_get_list,retval = 304 tests_list:tst_listsetget: getdns_list_set_list(list, -1, ans_list) tests_list:tst_listsetget: getdns_list_set_list,retval = 311 tests_list:tst_listsetget: getdns_list_set_list(list, 1, ans_list) tests_list:tst_listsetget: getdns_list_set_list,retval = 311 tests_list:tst_listsetget: getdns_list_set/get_list,retval = 0, ans[0] = 42 TESTCASE tests_list:tst_listsetget END TESTPROG tests_list END getdns-0.9.0/src/test/check_getdns_address.h0000664000175100017510000002107312641212403015774 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_address_h_ #define _check_getdns_address_h_ /* *************************************************** * * * T E S T S F O R G E T D N S _ A D D R E S S * * * *************************************************** */ START_TEST (getdns_address_1) { /* * context = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; getdns_transaction_t transaction_id = 0; ASSERT_RC(getdns_address(context, "google.com", NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address()"); } END_TEST START_TEST (getdns_address_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, NULL, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_address_3) { /* * name = invalid domain (too many octets) * expect: GETDNS_RETURN_BAD_DOMAIN_NAME */ struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com"; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, name, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_address()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_address_4) { /* * name = invalid domain (label too long) * expect: GETDNS_RETURN_BAD_DOMAIN_NAME */ struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com"; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, name, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_address()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_address_5) { /* * callbackfn = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "google.com", NULL, NULL, &transaction_id, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_address_6) { /* * name = "google.com" * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 */ void verify_getdns_address_6(struct extracted_response *ex_response); struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "google.com", NULL, verify_getdns_address_6, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST void verify_getdns_address_6(struct extracted_response *ex_response) { assert_noerror(ex_response); //assert_soa_in_authority(ex_response); assert_address_in_answer(ex_response, TRUE, TRUE); } START_TEST (getdns_address_7) { /* * name = "localhost" name should be resolved from host file * expect: NOERROR/NODATA response: * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount = 1 (number of records in ANSWER section) */ void verify_getdns_address_7(struct extracted_response *ex_response); struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "localhost", NULL, verify_getdns_address_7, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST void verify_getdns_address_7(struct extracted_response *ex_response) { assert_address_in_just_address_answers(ex_response); } START_TEST (getdns_address_8) { /* * name = "hostnamedoesntexist" (name should not be resolved) * expect: NXDOMAIN response * status = GETDNS_RESPSTATUS_GOOD * rcode = 3 (NXDOMAIN) */ void verify_getdns_address_8(struct extracted_response *ex_response); struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "hostnamedoesntexist", NULL, verify_getdns_address_8, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST void verify_getdns_address_8(struct extracted_response *ex_response) { assert_nxdomain(ex_response); assert_nodata(ex_response); assert_soa_in_authority(ex_response); } Suite * getdns_address_suite (void) { Suite *s = suite_create ("getdns_address()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_address_1); tcase_add_test(tc_neg, getdns_address_2); tcase_add_test(tc_neg, getdns_address_3); tcase_add_test(tc_neg, getdns_address_4); tcase_add_test(tc_neg, getdns_address_5); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_address_6); tcase_add_test(tc_pos, getdns_address_7); tcase_add_test(tc_pos, getdns_address_8); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_list_get_list.h0000664000175100017510000001406712641212403017221 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_list_get_list_h_ #define _check_getdns_list_get_list_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ L I S T _ G E T _ L I S T * * * ************************************************************************** */ START_TEST (getdns_list_get_list_1) { /* * list = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; struct getdns_list *answer = NULL; ASSERT_RC(getdns_list_get_list(list, index, &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()"); } END_TEST START_TEST (getdns_list_get_list_2) { /* index is out of range * create a list and set index 0 to an int with a value of 100 * Call getdns_get_list() for index 1 * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); index++; ASSERT_RC(getdns_list_get_list(list,index,NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()"); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_list_3) { /* data type at index is not a list * create a list and set index 0 to an int with a value of 100 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED */ struct getdns_list *list = NULL; size_t index = 0; struct getdns_list *answer = NULL; LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_get_list(list, index, &answer), GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_list()"); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_list_4) { /* answer == NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; ASSERT_RC(getdns_list_get_list(list, index, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()"); } END_TEST START_TEST (getdns_list_get_list_5) { /* create a list. Also create a second list * Set list value at index 0 in the second list via getdns_list_set_int() to 45 * Set list value at index 0 in the first list via getdns_list_set_list() to the second list * Call getdns_list_get_list() for index 0 against the first list * Call getdns_list_get_int() for index 0 against retrieved list * expect: GETDNS_RETURN_GOOD */ struct getdns_list *list = NULL; struct getdns_list *second_list = NULL; size_t index = 0; struct getdns_list *answer = NULL; uint32_t value; LIST_CREATE(list); LIST_CREATE(second_list); ASSERT_RC(getdns_list_set_int(second_list, index, 45), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_set_list(list, index, second_list), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()"); ASSERT_RC(getdns_list_get_list(list, index, &answer), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_list()"); ASSERT_RC(getdns_list_get_int(answer, index, &value), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()"); ck_assert_msg(value == 45, "Expected retrieved int == 45, got: %d", value); LIST_DESTROY(list); LIST_DESTROY(second_list); } END_TEST Suite * getdns_list_get_list_suite (void) { Suite *s = suite_create ("getdns_list_get_list()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_list_get_list_1); tcase_add_test(tc_neg, getdns_list_get_list_2); tcase_add_test(tc_neg, getdns_list_get_list_3); tcase_add_test(tc_neg, getdns_list_get_list_4); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_list_get_list_5); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_context_destroy.h0000664000175100017510000002506112641212403017605 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_context_destroy_h_ #define _check_getdns_context_destroy_h_ #include /* ************************************************************************** * * * T E S T S F O R G E T D N S _ C O N T E X T _ D E S T R O Y * * * ************************************************************************** */ START_TEST (getdns_context_destroy_1) { /* * context = NULL * expect: nothing, no segmentation fault */ getdns_context_destroy(NULL); } END_TEST START_TEST (getdns_context_destroy_2) { /* * destroy called with valid context and no outstanding transactions * expect: nothing, context is freed */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_destroy_3) { /* * destroy called immediately following getdns_general * expect: callback should be called before getdns_context_destroy() returns */ void verify_getdns_context_destroy(struct extracted_response *ex_response); struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; callback_called = 0; /* Initialize counter */ CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL, verify_getdns_context_destroy, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called); } END_TEST START_TEST (getdns_context_destroy_4) { /* * destroy called immediately following getdns_address * expect: callback should be called before getdns_context_destroy() returns */ void verify_getdns_context_destroy(struct extracted_response *ex_response); struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; callback_called = 0; /* Initialize counter */ CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "google.com", NULL, verify_getdns_context_destroy, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called); } END_TEST START_TEST (getdns_context_destroy_5) { /* * destroy called immediately following getdns_address * expect: callback should be called before getdns_context_destroy() returns */ void verify_getdns_context_destroy(struct extracted_response *ex_response); struct getdns_context *context = NULL; void* eventloop = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; struct getdns_dict *address = NULL; getdns_transaction_t transaction_id = 0; callback_called = 0; /* Initialize counter */ CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; DICT_CREATE(address); ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata"); ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata"); ASSERT_RC(getdns_hostname(context, address, NULL, verify_getdns_context_destroy, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; DICT_DESTROY(address); CONTEXT_DESTROY; ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called); } END_TEST START_TEST (getdns_context_destroy_6) { /* * destroy called immediately following getdns_address * expect: callback should be called before getdns_context_destroy() returns */ void verify_getdns_context_destroy(struct extracted_response *ex_response); struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; callback_called = 0; /* Initialize counter */ CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_service(context, "google.com", NULL, verify_getdns_context_destroy, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_service()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called); } END_TEST START_TEST (getdns_context_destroy_7) { /* * destroy called immediately following getdns_address * expect: callback should be called before getdns_context_destroy() returns */ struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; int flag = 0; /* Initialize flag */ CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "google.com", NULL, &flag, &transaction_id, destroy_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; ck_assert_msg(flag == 1, "flag should == 1, got %d", flag); } END_TEST START_TEST (getdns_context_destroy_8) { /* * destroy called immediately following getdns_address * expect: callback should be called before getdns_context_destroy() returns */ struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; int flag = 0; /* Initialize flag */ CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "google.com", NULL, &flag, &transaction_id, destroy_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); getdns_cancel_callback(context, transaction_id); RUN_EVENT_LOOP; CONTEXT_DESTROY; ck_assert_msg(flag == 1, "flag should == 1, got %d", flag); } END_TEST START_TEST (getdns_context_destroy_9) { /* * destroy called immediately following getdns_address * expect: callback should be called before getdns_context_destroy() returns */ struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; int flag = 0; /* Initialize flag */ CONTEXT_CREATE(TRUE); // set timeout to something unreasonable getdns_context_set_timeout(context, 1); EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "google.com", NULL, &flag, &transaction_id, destroy_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); ASSERT_RC(getdns_address(context, "getdnsapi.net", NULL, &flag, &transaction_id, destroy_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; ck_assert_msg(flag == 1, "flag should == 1, got %d", flag); } END_TEST void verify_getdns_context_destroy(struct extracted_response *ex_response) { /* * Sleep for a second to make getdns_context_destroy() wait. */ sleep(1); /* * callback_called is a global and we increment it * here to show that the callback was called. */ callback_called++; } Suite * getdns_context_destroy_suite (void) { Suite *s = suite_create ("getdns_context_destroy()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_context_destroy_1); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_context_destroy_2); tcase_add_test(tc_pos, getdns_context_destroy_3); tcase_add_test(tc_pos, getdns_context_destroy_4); tcase_add_test(tc_pos, getdns_context_destroy_5); tcase_add_test(tc_pos, getdns_context_destroy_6); // raise aborts via assertion failures tcase_add_test_raise_signal(tc_pos, getdns_context_destroy_7, SIGABRT); tcase_add_test_raise_signal(tc_pos, getdns_context_destroy_8, SIGABRT); tcase_add_test_raise_signal(tc_pos, getdns_context_destroy_9, SIGABRT); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_dict_get_bindata.h0000664000175100017510000001633412641212403017617 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_dict_get_bindata_h_ #define _check_getdns_dict_get_bindata_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ G E T _ B I N D A T A * * * ************************************************************************** */ START_TEST (getdns_dict_get_bindata_1) { /* * this_dict = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_bindata *answer = NULL; ASSERT_RC(getdns_dict_get_bindata(this_dict, "key", &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_bindata()"); } END_TEST START_TEST (getdns_dict_get_bindata_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; struct getdns_bindata *answer = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_get_bindata(this_dict, NULL, &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_bindata()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_bindata_3) { /* * name does not exist in dict * Create a dict * Create some bindata containing "bindata" and add it to the dict with name = "bindata" * Call getdns_dict_get_bindata() against the first dict with name = "bindata1" * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME */ struct getdns_dict *this_dict = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; struct getdns_bindata *answer = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_get_bindata(this_dict, "bindata1", &answer), GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_dict_get_bindata()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_bindata_4) { /* * data type at name is not bindata * Create a dict with one int (name = "ten", value = 10) * Call getdns_dict_get_bindata() with name = "ten" * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED */ struct getdns_dict *this_dict = NULL; struct getdns_bindata *answer = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_bindata(this_dict, "ten", &answer), GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_dict_get_bindata()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_bindata_5) { /* * answer = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_get_bindata(this_dict, "bindata", NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_bindata()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_bindata_6) { /* * successful get bindata * Create a dict * Create some bindata containing "bindata" and add it to the dict with name = "bindata" * Call getdns_dict_get_bindata() against the first dict with name = "bindata" * expect: retrieved bindata should == "bindata" */ struct getdns_dict *this_dict = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; struct getdns_bindata *answer = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_get_bindata(this_dict, "bindata", &answer), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_bindata()"); ck_assert_msg(answer->size == bindata.size, "Expected bindata size == %d, got: %d", bindata.size, answer->size); ck_assert_msg(strcmp((char *)answer->data, (char *)bindata.data) == 0, "Expected bindata data to be \"%s\", got: \"%s\"", (char *)bindata.data, (char *)answer->data); DICT_DESTROY(this_dict); } END_TEST Suite * getdns_dict_get_bindata_suite (void) { Suite *s = suite_create ("getdns_dict_get_bindata()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_dict_get_bindata_1); tcase_add_test(tc_neg, getdns_dict_get_bindata_2); tcase_add_test(tc_neg, getdns_dict_get_bindata_3); tcase_add_test(tc_neg, getdns_dict_get_bindata_4); tcase_add_test(tc_neg, getdns_dict_get_bindata_5); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_dict_get_bindata_6); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/tests_stub_async.c0000664000175100017510000001510412641212403015233 00000000000000/** * \file * unit tests for getdns_dict helper routines, these should be used to * perform regression tests, output must be unchanged from canonical output * stored with the sources */ /* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include #include #include #include "testmessages.h" #include "getdns/getdns.h" #include "getdns/getdns_extra.h" #include #define TRANSPORT_UDP "udp" #define TRANSPORT_UDP_TCP "udp_tcp" #define TRANSPORT_TCP "tcp" #define TRANSPORT_PIPELINE "pipeline" #define TRANSPORT_TLS_KEEPOPEN "tls" #define TRANSPORT_TLS_TCP_KEEPOPEN "dns-over-tls" #define RESOLUTION_STUB "stub" #define RESOLUTION_REC "rec" /* Set up the callback function, which will also do the processing of the results */ void this_callbackfn(struct getdns_context *this_context, getdns_callback_type_t this_callback_type, struct getdns_dict *this_response, void *this_userarg, getdns_transaction_t this_transaction_id) { 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); free(res); } else if (this_callback_type == GETDNS_CALLBACK_CANCEL) fprintf(stderr, "The callback with ID %llu was cancelled. Exiting.\n", (unsigned long long)this_transaction_id); else fprintf(stderr, "The callback got a callback_type of %d. Exiting.\n", this_callback_type); getdns_dict_destroy(this_response); } int main(int argc, char** argv) { const char *transport = argc > 2 ? argv[2] : "udp_tcp"; const char *resolution = argc > 3 ? argv[3] : "stub"; /* Create the DNS context for this call */ struct getdns_context *this_context = NULL; getdns_return_t return_value = getdns_context_create(&this_context, 1); if (return_value != GETDNS_RETURN_GOOD) { fprintf(stderr, "Trying to create the context failed: %d", return_value); return (GETDNS_RETURN_GENERIC_ERROR); } if (strncmp(resolution, RESOLUTION_STUB, 4) == 0) getdns_context_set_resolution_type(this_context, GETDNS_RESOLUTION_STUB); else if (strncmp(resolution, RESOLUTION_REC, 4) != 0) { fprintf(stderr, "Invalid resolution %s, must be one of stub or rec\n", transport); exit(EXIT_FAILURE); } /* Order matters*/ if (strncmp(transport, TRANSPORT_TCP, 3) == 0) getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_TCP_ONLY); else if (strncmp(transport, TRANSPORT_UDP_TCP, 7) == 0) getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP); else if (strncmp(transport, TRANSPORT_UDP, 3) == 0) getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_UDP_ONLY); else if (strncmp(transport, TRANSPORT_PIPELINE, 8) == 0) getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN); else if (strncmp(transport, TRANSPORT_TLS_KEEPOPEN, 3) == 0) getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN); else if (strncmp(transport, TRANSPORT_TLS_TCP_KEEPOPEN, 12) == 0) getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN); else if (strncmp(transport, TRANSPORT_UDP_TCP, 3) != 0) { fprintf(stderr, "Invalid transport %s, must be one of udp, udp_tcp, tcp or pipeline\n", transport); exit(EXIT_FAILURE); } getdns_context_set_timeout(this_context, 5000); /* Create an event base and put it in the context using the unknown function name */ /* Set up the getdns call */ const char *this_name = argc > 1 ? argv[1] : "getdnsapi.net"; char *this_userarg = "somestring"; // Could add things here to help identify this call getdns_transaction_t this_transaction_id = 0; /* Make the call */ getdns_return_t dns_request_return = getdns_address(this_context, this_name, NULL, this_userarg, &this_transaction_id, this_callbackfn); if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME) { fprintf(stderr, "A bad domain name was used: %s. Exiting.", this_name); getdns_context_destroy(this_context); return (GETDNS_RETURN_GENERIC_ERROR); } else { getdns_context_run(this_context); } getdns_transport_t get_transport; return_value = getdns_context_get_dns_transport(this_context, &get_transport); if (return_value != GETDNS_RETURN_GOOD) { fprintf(stderr, "Trying to get transport type failed: %d\n", return_value); return (GETDNS_RETURN_GENERIC_ERROR); } fprintf(stderr, "Transport type is %d\n", get_transport); size_t transport_count = 0; getdns_transport_list_t *get_transport_list; return_value = getdns_context_get_dns_transport_list(this_context, &transport_count, &get_transport_list); if (return_value != GETDNS_RETURN_GOOD) { fprintf(stderr, "Trying to get transport type failed: %d\n", return_value); return (GETDNS_RETURN_GENERIC_ERROR); } for (size_t i = 0; i < transport_count; i++) { fprintf(stderr, "Transport %d is %d\n", (int)i, get_transport_list[i]); } free(get_transport_list); /* Clean up */ getdns_context_destroy(this_context); /* Assuming we get here, leave gracefully */ exit(EXIT_SUCCESS); } /* main */ /* tests_stub_async.c */ getdns-0.9.0/src/test/check_getdns_dict_set_list.h0000664000175100017510000001753012641212403017203 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_dict_set_list_h_ #define _check_getdns_dict_set_list_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ S E T _ L I S T * * * ************************************************************************** */ START_TEST (getdns_dict_set_list_1) { /* * this_dict = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_list *list = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_list(this_dict, "list", list), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_list()"); } END_TEST START_TEST (getdns_dict_set_list_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_list *list = NULL; DICT_CREATE(this_dict); LIST_CREATE(list); ASSERT_RC(getdns_dict_set_list(this_dict, NULL, list), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_list()"); DICT_DESTROY(this_dict); LIST_DESTROY(list); } END_TEST START_TEST (getdns_dict_set_list_3) { /* * child_list = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_list(this_dict, "list", NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_list()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_set_list_4) { /* * name already exists in dict * Create a dict * Create a list * Set list value at index 0 via getdns_list_set_int() to 100 * Add the list to the dict as name "list" * Create a second list * Set list value at index 0 in the second list to 101 * Add the second list to the dict using name "list" again * Call getdns_dict_get_list() against the dict with name = "list" * Call getdns_list_get_int() for index 0 against the retrieved list * expect: GETDNS_RETURN_GOOD (all functions) * retrieved int should = 101 */ struct getdns_dict *this_dict = NULL; struct getdns_list *first_list = NULL; struct getdns_list *second_list = NULL; struct getdns_list *retrieved_list = NULL; uint32_t value; DICT_CREATE(this_dict); LIST_CREATE(first_list); ASSERT_RC(getdns_list_set_int(first_list, 0, 100), GETDNS_RETURN_GOOD, "Return from getdns_list_set_int()"); ASSERT_RC(getdns_dict_set_list(this_dict, "list", first_list), GETDNS_RETURN_GOOD, "Return from getdns_list_set_list()"); LIST_CREATE(second_list); ASSERT_RC(getdns_list_set_int(second_list, 0, 101), GETDNS_RETURN_GOOD, "Return from getdns_list_set_int()"); ASSERT_RC(getdns_dict_set_list(this_dict, "list", second_list), GETDNS_RETURN_GOOD, "Return from getdns_list_set_list()"); ASSERT_RC(getdns_dict_get_list(this_dict, "list", &retrieved_list), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_list()"); ASSERT_RC(getdns_list_get_int(retrieved_list, 0, &value), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()"); ck_assert_msg(value == 101, "Expected int retrieved == 101, got: %d", value); DICT_DESTROY(this_dict); LIST_DESTROY(first_list); LIST_DESTROY(second_list); } END_TEST START_TEST (getdns_dict_set_list_5) { /* * name already exists in dict, changing data type * Create a dict * Create a second dict * Add an int to the second dict (name = "int", value = 100) * Add the second dict to the first dict as name "list" * Create a list * Set list value at index 0 in the list to 101 * Add the list to the first dict using name "list" again * Call getdns_dict_get_list() against the dict with name = "list" * Call getdns_list_get_int() for index 0 against the retrieved list * expect: GETDNS_RETURN_GOOD (all functions) * retrieved int should = 101 */ struct getdns_dict *first_dict = NULL; struct getdns_dict *second_dict = NULL; struct getdns_list *list = NULL; struct getdns_list *retrieved_list = NULL; uint32_t value; DICT_CREATE(first_dict); DICT_CREATE(second_dict); ASSERT_RC(getdns_dict_set_int(second_dict, "int", 100), GETDNS_RETURN_GOOD, "Return from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_dict(first_dict, "list", second_dict), GETDNS_RETURN_GOOD, "Return from getdns_dict_set_dict()"); LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, 0, 101), GETDNS_RETURN_GOOD, "Return from getdns_list_set_int()"); ASSERT_RC(getdns_dict_set_list(first_dict, "list", list), GETDNS_RETURN_GOOD, "Return from getdns_dict_set_list()"); ASSERT_RC(getdns_dict_get_list(first_dict, "list", &retrieved_list), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_list()"); ASSERT_RC(getdns_list_get_int(retrieved_list, 0, &value), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()"); ck_assert_msg(value == 101, "Expected int retrieved == 101, got: %d", value); DICT_DESTROY(first_dict); DICT_DESTROY(second_dict); LIST_DESTROY(list); } END_TEST Suite * getdns_dict_set_list_suite (void) { Suite *s = suite_create ("getdns_dict_set_list()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_dict_set_list_1); tcase_add_test(tc_neg, getdns_dict_set_list_2); tcase_add_test(tc_neg, getdns_dict_set_list_3); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_dict_set_list_4); tcase_add_test(tc_pos, getdns_dict_set_list_5); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_pretty_print_dict.h0000664000175100017510000002776312641212403020131 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_pretty_print_dict_h_ #define _check_getdns_pretty_print_dict_h_ static const char pretty_expected[] = "{\n" " \"bindata\": ,\n" " \"dict\":\n" " {\n" " \"bindata\": ,\n" " \"dict\":\n" " {\n" " \"bindata\": ,\n" " \"dict\":\n" " {\n" " \"int\": 4\n" " },\n" " \"int\": 3,\n" " \"list\":\n" " [\n" " 5\n" " ]\n" " },\n" " \"int\": 2,\n" " \"list\":\n" " [\n" " 6,\n" " ,\n" " {\n" " \"bindata\": \n" " },\n" " [\n" " \n" " ]\n" " ]\n" " },\n" " \"int\": 1,\n" " \"list\":\n" " [\n" " 7,\n" " ,\n" " {\n" " \"bindata\": ,\n" " \"dict\":\n" " {\n" " \"int\": 9\n" " },\n" " \"int\": 8,\n" " \"list\":\n" " [\n" " 10\n" " ]\n" " },\n" " [\n" " 11,\n" " ,\n" " {\n" " \"bindata\": \n" " },\n" " [\n" " \n" " ]\n" " ]\n" " ]\n" "}"; /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ D E S T R O Y * * * ************************************************************************** */ START_TEST (getdns_pretty_print_dict_1) { /* * this_dict = NULL * expect: nothing */ struct getdns_dict *some_dict = NULL; DICT_DESTROY(some_dict); } END_TEST START_TEST (getdns_pretty_print_dict_2) { /* * build a complex dict and then print it * * dict1-> "int" = 1 * -> "bindata" = { 8, "bindata" } * -> "dict" = dict2->"int" = 2 * -> "bindata" = { 8, "bindata" } * -> "dict" = dict3 -> "int" = 3 * -> "bindata" = { 8, "bindata" } * -> "dict" = dict4 -> "int" = 4 * -> "list" = list1 0: int = 5 * -> "list" = list2 0: int = 6 * 1: bindata = { 8, "bindata" } * 2: dict = dict5 -> "bindata" = { 8, "bindata" } * 3: list = list3 0: bindata = { 8, "bindata" } * -> "list" = list4 0: int = 7 * 1: bindata = { 8, "bindata" } * 2: dict6 -> "int" = 8 * -> "bindata" = { 8, "bindata" } * -> "dict" = dict7 -> "int" = 9 * -> "list" = list5 0: int = 10 * 3: list6 0: int = 11 * 1: bindata = { 8, "bindata" } * 2: dict8 -> "bindata" = { 8, "bindata" } * 3: list7 0: bindata = { 8, "bindata" } * * expect: string to accurately represent dict defined above */ struct getdns_bindata bindata = { 8, (void *)"bindata" }; struct getdns_list *list7; struct getdns_dict *dict8; struct getdns_list *list6; struct getdns_list *list5; struct getdns_dict *dict7; struct getdns_dict *dict6; struct getdns_list *list4; struct getdns_list *list3; struct getdns_dict *dict5; struct getdns_list *list2; struct getdns_list *list1; struct getdns_dict *dict4; struct getdns_dict *dict3; struct getdns_dict *dict2; struct getdns_dict *dict1; char *pretty = NULL; /* * Build it backwards, with the deepest elements first. */ LIST_CREATE(list7); ASSERT_RC(getdns_list_set_bindata(list7, 0, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); DICT_CREATE(dict8); ASSERT_RC(getdns_dict_set_bindata(dict8, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); LIST_CREATE(list6); ASSERT_RC(getdns_list_set_int(list6, 0, 11), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_set_bindata(list6, 1, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()"); ASSERT_RC(getdns_list_set_dict(list6, 2, dict8), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_list_set_list(list6, 3, list7), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()"); LIST_CREATE(list5); ASSERT_RC(getdns_list_set_int(list5, 0, 10), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); DICT_CREATE(dict7); ASSERT_RC(getdns_dict_set_int(dict7, "int", 9), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); DICT_CREATE(dict6); ASSERT_RC(getdns_dict_set_int(dict6, "int", 8), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(dict6, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_dict(dict6, "dict", dict7), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_set_list(dict6, "list", list5), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); LIST_CREATE(list4); ASSERT_RC(getdns_list_set_int(list4, 0, 7), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_set_bindata(list4, 1, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()"); ASSERT_RC(getdns_list_set_dict(list4, 2, dict6), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_list_set_list(list4, 3, list6), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()"); LIST_CREATE(list3); ASSERT_RC(getdns_list_set_bindata(list3, 0, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()"); DICT_CREATE(dict5); ASSERT_RC(getdns_dict_set_bindata(dict5, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); LIST_CREATE(list2); ASSERT_RC(getdns_list_set_int(list2, 0, 6), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_set_bindata(list2, 1, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()"); ASSERT_RC(getdns_list_set_dict(list2, 2, dict5), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_list_set_list(list2, 3, list3), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()"); LIST_CREATE(list1); ASSERT_RC(getdns_list_set_int(list1, 0, 5), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); DICT_CREATE(dict4); ASSERT_RC(getdns_dict_set_int(dict4, "int", 4), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); DICT_CREATE(dict3); ASSERT_RC(getdns_dict_set_int(dict3, "int", 3), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(dict3, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_dict(dict3, "dict", dict4), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_set_list(dict3, "list", list1), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); DICT_CREATE(dict2); ASSERT_RC(getdns_dict_set_int(dict2, "int", 2), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(dict2, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_dict(dict2, "dict", dict3), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_set_list(dict2, "list", list2), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); DICT_CREATE(dict1); ASSERT_RC(getdns_dict_set_int(dict1, "int", 1), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_bindata(dict1, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_dict(dict1, "dict", dict2), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()"); ASSERT_RC(getdns_dict_set_list(dict1, "list", list4), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); pretty = getdns_pretty_print_dict(dict1); ck_assert_msg(pretty != NULL, "NULL returned by getdns_pretty_print_dict()"); ck_assert_msg(strcmp(pretty_expected, pretty) == 0, "Expected:\n%s\ngot:\n%s\n", pretty_expected, pretty); /* * Destroy all of the sub-dicts and sub-lists */ LIST_DESTROY(list7); DICT_DESTROY(dict8); LIST_DESTROY(list6); LIST_DESTROY(list5); DICT_DESTROY(dict7); DICT_DESTROY(dict6); LIST_DESTROY(list4); LIST_DESTROY(list3); DICT_DESTROY(dict5); LIST_DESTROY(list2); LIST_DESTROY(list1); DICT_DESTROY(dict4); DICT_DESTROY(dict3); DICT_DESTROY(dict2); /* * And now destroy the mother of all ints, bindata, dicts, and lists */ DICT_DESTROY(dict1); } END_TEST Suite * getdns_pretty_print_dict_suite (void) { Suite *s = suite_create ("getdns_pretty_print_dict()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_pretty_print_dict_1); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_pretty_print_dict_2); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/tests_dict.good0000664000175100017510000001202512641212403014511 00000000000000TESTPROG tests_dict START TESTCASE tests_dict:tst_create BEGIN tests_dict:tst_create: getdns_dict_create tests_dict:tst_create: getdns_dict_destroy(dict) tests_dict:tst_create: getdns_dict_destroy(NULL) TESTCASE tests_dict:tst_create END TESTCASE tests_dict:tst_bindatasetget BEGIN tests_dict:tst_bindatasetget: getdns_dict_get_bindata() empty dict tests_dict:tst_bindatasetget: test 1: getdns_dict_get_bindata(NULL, key, &ans_bdata),retval = 311 tests_dict:tst_bindatasetget: test 2: getdns_dict_get_bindata(dict, key, NULL),retval = 311 tests_dict:tst_bindatasetget: getdns_dict_get_bindata(dict, NULL, &ans_bindata) tests_dict:tst_bindatasetget: test 3: getdns_dict_get_bindata,retval = 311 tests_dict:tst_bindatasetget: getdns_dict_get_bindata(dict, key, &ans_bdata) tests_dict:tst_bindatasetget: test 4: getdns_list_get_bindata,retval = 305 tests_dict:tst_bindatasetget: getdns_dict_set_bindata(dict, key, bindata) tests_dict:tst_bindatasetget: test 5: getdns_dict_set_bindata,retval=0,key=foo tests_dict:tst_bindatasetget: getdns_dict_get_bindata(dict, key, &ans_bdata) tests_dict:tst_bindatasetget: test 6: getdns_dict_get_bindata,retval=0,key=foo,data=foobar TESTCASE tests_dict:tst_bindatasetget END TESTCASE tests_dict:tst_dictsetget BEGIN tests_dict:tst_dictsetget: getdns_dict_get_dict() empty dict tests_dict:tst_dictsetget: test 7: getdns_dict_get_dict(NULL, key, &ansdict),retval = 311 tests_dict:tst_dictsetget: test 8: getdns_dict_get_dict(dict, key, NULL),retval = 311 tests_dict:tst_dictsetget: getdns_dict_get_dict(dict, NULL, &ansdict) tests_dict:tst_dictsetget: test 9: getdns_dict_get_dict,retval = 311 tests_dict:tst_dictsetget: getdns_dict_get_dict(dict, key, &ansdict) tests_dict:tst_dictsetget: test 10: getdns_list_get_dict,retval = 305 tests_dict:tst_dictsetget: getdns_dict_set_dict(dict, key, newdict) tests_dict:tst_dictsetget: test 11: getdns_dict_set_dict,retval=0,key=foo tests_dict:tst_dictsetget: getdns_dict_get_dict(dict, key, &ansdict) tests_dict:tst_dictsetget: test 12: getdns_dict_get_dict,retval=0,key=foo,int1=42,int2=52 TESTCASE tests_dict:tst_dictsetget END TESTCASE tests_dict:tst_intsetget BEGIN tests_dict:tst_intsetget: getdns_dict_get_int() empty dict tests_dict:tst_intsetget: test 19: getdns_dict_get_int(NULL, key, &ans_int),retval = 311 tests_dict:tst_intsetget: test 20: getdns_dict_get_int(dict, key, NULL),retval = 311 tests_dict:tst_intsetget: getdns_dict_get_int(dict, NULL, &ans_int) tests_dict:tst_intsetget: test 21: getdns_dict_get_int,retval = 311 tests_dict:tst_intsetget: getdns_dict_get_int(dict, key, &ans_int) tests_dict:tst_intsetget: test 22: getdns_list_get_int,retval = 305 tests_dict:tst_intsetget: getdns_dict_set_int(dict, key, newint) tests_dict:tst_intsetget: test 23: getdns_dict_set_int,retval=0,key=foo,int=42 tests_dict:tst_intsetget: getdns_dict_get_int(dict, key, &ans_int) tests_dict:tst_intsetget: test 24: getdns_dict_get_int,retval=0,key=foo,int=42 tests_dict:tst_intsetget: getdns_dict_set_int(dict, key, newint) tests_dict:tst_intsetget: test 25: getdns_dict_set_int,retval=0,key=bar,int=52 tests_dict:tst_intsetget: getdns_dict_get_int(dict, key, &ans_int) tests_dict:tst_intsetget: test 26: getdns_dict_get_int,retval=0,key=bar,int=52 tests_dict:tst_intsetget: getdns_dict_get_data_type(dict, key, &dtype) tests_dict:tst_intsetget: test 27: getdns_dict_get_data_type,retval=0,key=bar,dtype=2 TESTCASE tests_dict:tst_intsetget END TESTCASE tests_dict:tst_listsetget BEGIN tests_dict:tst_listsetget: getdns_dict_get_list() empty dict tests_dict:tst_listsetget: test 13: getdns_dict_get_list(NULL, key, &anslist),retval = 311 tests_dict:tst_listsetget: test 14: getdns_dict_get_list(dict, key, NULL),retval = 311 tests_dict:tst_listsetget: getdns_dict_get_list(dict, NULL, &anslist) tests_dict:tst_listsetget: test 15: getdns_dict_get_list,retval = 311 tests_dict:tst_listsetget: getdns_dict_get_list(dict, key, &anslist) tests_dict:tst_listsetget: test 16: getdns_list_get_list,retval = 305 tests_dict:tst_listsetget: getdns_dict_set_list(dict, key, newlist) tests_dict:tst_listsetget: test 17: getdns_dict_set_list,retval=0,key=foo tests_dict:tst_listsetget: getdns_dict_get_list(dict, key, &anslist) tests_dict:tst_listsetget: test 18: getdns_dict_get_list,retval=0,key=foo,int1=42,int2=52 TESTCASE tests_dict:tst_listsetget END TESTCASE tests_dict:tst_getnames BEGIN tests_dict:tst_getnames: getdns_dict_get_names(NULL, &list) tests_dict:tst_getnames: getdns_dict_get_names(dict, NULL) tests_dict:tst_getnames: getdns_dict_get_names(dict, &list), empty dictionary list item 0: NOTIMPLEMENTED list item 1: NOTIMPLEMENTED list item 2: NOTIMPLEMENTED list item 3: NOTIMPLEMENTEDTESTCASE tests_dict:tst_getnames END TESTCASE tests_dict:tst_copy BEGIN tests_dict:tst_copy: empty list cases tests_dict:tst_copy: dict1 populate { "bar": 52, "foo": 42, "quz": 62 } tests_dict:tst_copy: getdns_dict_copy(dict1, &dict2) { "bar": 52, "foo": 42, "quz": 62 } TESTCASE tests_dict:tst_copy END TESTPROG tests_dict END getdns-0.9.0/src/test/check_getdns_libevent.c0000664000175100017510000000461712641212403016157 00000000000000/** * \file * \brief Public interfaces to getdns, include in your application to use getdns API. * * This source was taken from the original pseudo-implementation by * Paul Hoffman. */ /* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "check_getdns_eventloop.h" #include "getdns/getdns_ext_libevent.h" #include "check_getdns_libevent.h" #include #include "check_getdns_common.h" void run_event_loop_impl(struct getdns_context* context, void* eventloop) { struct event_base* base = (struct event_base*) eventloop; event_base_dispatch(base); } void* create_eventloop_impl(struct getdns_context* context) { struct event_base* result = event_base_new(); ck_assert_msg(result != NULL, "Event base creation failed"); ASSERT_RC(getdns_extension_set_libevent_base(context, result), GETDNS_RETURN_GOOD, "Return code from getdns_extension_set_libevent_base()"); return result; } getdns-0.9.0/src/test/check_getdns_convert_ulabel_to_alabel.h0000664000175100017510000000773112641212403021362 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_convert_ulabel_to_alabel_h_ #define _check_getdns_convert_ulabel_to_alabel_h_ /* ************************************************************************************* * * * T E S T S F O R G E T D N S _ C O N V E R T _ U L A B E L _ T O _ A L A B E L * * * ************************************************************************************* */ START_TEST (getdns_convert_ulabel_to_alabel_1) { /* * ulabel = NULL * expect: GETDNS_RETURN_GENERIC_ERROR */ char *ulabel = NULL; ck_assert_msg(( getdns_convert_ulabel_to_alabel( ulabel ) == 0 ), "Was not expecting %d from getdns_convert_ulabel_to_alabel()", getdns_convert_ulabel_to_alabel( ulabel ) ); } END_TEST START_TEST (getdns_convert_ulabel_to_alabel_2) { /* * ulabel = invalid characters * expect: GETDNS_RETURN_GENERIC_ERROR */ char *ulabel = "#$%_"; ck_assert_msg(strcmp( getdns_convert_ulabel_to_alabel( ulabel ), "#$%_" ) == 0, "Was not expecting %s from getdns_convert_ulabel_to_alabel()", getdns_convert_ulabel_to_alabel( ulabel ) ); } END_TEST START_TEST (getdns_convert_ulabel_to_alabel_3) { /* * ulabel = valid characters ( _abc, -abc, -abc-, abc- and limited to 63 octets ) * expect: GETDNS_RETURN_GOOD */ char *ulabel = "café"; ck_assert_msg(strcmp( getdns_convert_ulabel_to_alabel( ulabel ), "xn--caf-dma" ) == 0, "Was not expecting %s from getdns_convert_ulabel_to_alabel()", getdns_convert_ulabel_to_alabel( ulabel ) ); } END_TEST Suite * getdns_convert_ulabel_to_alabel_suite (void) { Suite *s = suite_create ("getdns_convert_ulabel_to_alabel()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_convert_ulabel_to_alabel_1); tcase_add_test(tc_neg, getdns_convert_ulabel_to_alabel_2); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_convert_ulabel_to_alabel_3); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_dict_get_list.h0000664000175100017510000001641312641212403017166 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_dict_get_list_h_ #define _check_getdns_dict_get_list_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ G E T _ L I S T * * * ************************************************************************** */ START_TEST (getdns_dict_get_list_1) { /* * this_dict = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_list *answer = NULL; ASSERT_RC(getdns_dict_get_list(this_dict, "key", &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_list()"); } END_TEST START_TEST (getdns_dict_get_list_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_list *list = NULL; struct getdns_list *answer = NULL; DICT_CREATE(this_dict); LIST_CREATE(list); ASSERT_RC(getdns_dict_set_list(this_dict, "list", list), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); ASSERT_RC(getdns_dict_get_list(this_dict, NULL, &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_list()"); DICT_DESTROY(this_dict); LIST_DESTROY(list); } END_TEST START_TEST (getdns_dict_get_list_3) { /* * name does not exist in dict * Create a dict with three ints ("ten" = 10, "eleven" = 11, "twelve" = 12) * Call getdns_dict_get_list() against the first dict with name = "nine" * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME */ struct getdns_dict *this_dict = NULL; char *keys[3] = { "ten", "eleven", "twelve" }; uint32_t values[3] = { 10, 11, 12 }; int i; struct getdns_list *answer = NULL; DICT_CREATE(this_dict); for(i = 0; i < 3; i++) { ASSERT_RC(getdns_dict_set_int(this_dict, keys[i], values[i]), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); } ASSERT_RC(getdns_dict_get_list(this_dict, "nine", &answer), GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_dict_get_list()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_list_4) { /* * data type at name is not a list * Create a dict with one int (name = "ten", value = 10) * Call getdns_dict_get_list() with name = "ten" * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED */ struct getdns_dict *this_dict = NULL; struct getdns_list *answer = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_list(this_dict, "ten", &answer), GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_dict_get_list()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_get_list_5) { /* * answer = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; struct getdns_list *list = NULL; DICT_CREATE(this_dict); LIST_CREATE(list); ASSERT_RC(getdns_dict_set_list(this_dict, "list", list), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); ASSERT_RC(getdns_dict_get_list(this_dict, "list", NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_list()"); DICT_DESTROY(this_dict); LIST_DESTROY(list); } END_TEST START_TEST (getdns_dict_get_list_6) { /* * successful get list * Create a dict * Create a list and set index 0 to an int with a value of 100 * Add the list to the dict as name "list" * Call getdns_dict_get_list() against the dict for name = "list" * Call getdns_list_set_int() for index 0 * expect: int retrieved = 100 */ struct getdns_dict *this_dict = NULL; struct getdns_list *list = NULL; struct getdns_list *answer = NULL; uint32_t value; DICT_CREATE(this_dict); LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, 0, 100), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_dict_set_list(this_dict, "list", list), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()"); ASSERT_RC(getdns_dict_get_list(this_dict, "list", &answer), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_list()"); ASSERT_RC(getdns_list_get_int(answer, 0, &value), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()"); ck_assert_msg(value == 100, "Expected int retrieved == 100, got: %d", value); DICT_DESTROY(this_dict); LIST_DESTROY(list); } END_TEST Suite * getdns_dict_get_list_suite (void) { Suite *s = suite_create ("getdns_dict_get_list()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_dict_get_list_1); tcase_add_test(tc_neg, getdns_dict_get_list_2); tcase_add_test(tc_neg, getdns_dict_get_list_3); tcase_add_test(tc_neg, getdns_dict_get_list_4); tcase_add_test(tc_neg, getdns_dict_get_list_5); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_dict_get_list_6); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_context_set_context_update_callback.h0000664000175100017510000004452712641212403023641 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_context_set_context_update_callback_h_ #define _check_getdns_context_set_context_update_callback_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ C O N T E X T _ S E T _ C O N T E X T _ U P D A T E _ C A L L B A C K * * * ************************************************************************** */ START_TEST (getdns_context_set_context_update_callback_1) { /* * context is NULL * expect: GETDNS_RETURN_BAD_CONTEXT */ struct getdns_context *context = NULL; ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_context_update_callback()"); } END_TEST START_TEST (getdns_context_set_context_update_callback_2) { /* * value is NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_TIMEOUT; ASSERT_RC(getdns_context_set_timeout(context, 3), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()"); ASSERT_RC(getdns_context_set_context_update_callback(context, NULL), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_5) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * getdns_context_set_resolution_type() to GETDNS_RESOLUTION_STUB * expect: GETDNS_CONTEXT_CODE_RESOLUTION_TYPE */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_RESOLUTION_TYPE; ASSERT_RC(getdns_context_set_resolution_type(context, GETDNS_RESOLUTION_STUB), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_resolution_type()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_6) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_namespaces() to change the order and/or number of namespaces to be queried * expect: GETDNS_CONTEXT_CODE_NAMESPACES */ struct getdns_context *context = NULL; getdns_namespace_t namespace_arr[2] = {GETDNS_NAMESPACE_DNS, GETDNS_NAMESPACE_LOCALNAMES}; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_NAMESPACES; ASSERT_RC(getdns_context_set_namespaces(context, 2,namespace_arr), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_namespaces()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_7) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_dns_transport() to GETDNS_TRANSPORT_UDP_ONLY * expect: GETDNS_CONTEXT_CODE_DNS_TRANSPORT */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_DNS_TRANSPORT; ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_UDP_ONLY), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_8) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_limit_outstanding_queries() and set limit to 10 * expect: GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES; ASSERT_RC(getdns_context_set_limit_outstanding_queries(context, 10), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_limit_outstanding_queries()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_9) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_timeout() and set timeout to 3 seconds * expect: GETDNS_CONTEXT_CODE_TIMEOUT */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_TIMEOUT; ASSERT_RC(getdns_context_set_timeout(context, 3), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_10) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_follow_redirects() to GETDNS_REDIRECTS_DO_NOT_FOLLOW * expect: GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS; (void) getdns_context_set_follow_redirects(context, GETDNS_REDIRECTS_DO_NOT_FOLLOW); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_15) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_stub_resolution() providing where the API should send queries to * expect: GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS */ struct getdns_context *context = NULL; struct getdns_list *upstream_list = NULL; struct getdns_dict *dict = NULL; size_t index = 0; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; struct getdns_bindata address_data = { 4, (void *)"\x0A\x58\x1E\x52" }; CONTEXT_CREATE(TRUE); LIST_CREATE(upstream_list); DICT_CREATE(dict); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS; ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()"); ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_upstream_recursive_servers()"); CONTEXT_DESTROY; LIST_DESTROY(upstream_list); DICT_DESTROY(dict); } END_TEST START_TEST (getdns_context_set_context_update_callback_16) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_edns_maximum_udp_payload_size() setting max UDP payload to 512 * expect: GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE; ASSERT_RC(getdns_context_set_edns_maximum_udp_payload_size(context, 512), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_maximum_udp_payload_size()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_17) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_edns_extended_rcode() setting extended rcode to 1 * expect: GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE; ASSERT_RC(getdns_context_set_edns_extended_rcode(context, 1), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_extended_rcode()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_18) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_edns_version() setting edns version to 1 * expect: GETDNS_CONTEXT_CODE_EDNS_VERSION */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_EDNS_VERSION; ASSERT_RC(getdns_context_set_edns_version(context, 1), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_version()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_19) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_edns_do_bit() setting edns do bit to 1 * expect: GETDNS_CONTEXT_CODE_EDNS_DO_BIT */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_EDNS_DO_BIT; ASSERT_RC(getdns_context_set_edns_do_bit(context, 1), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_do_bit()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_20) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_edns_client_subnet_private() setting to 1 * expect: GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE; ASSERT_RC(getdns_context_set_edns_client_subnet_private(context, 1), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_client_subnet_private()"); CONTEXT_DESTROY; } END_TEST START_TEST (getdns_context_set_context_update_callback_21) { /* * Create a context by calling getdns_context_create() * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes * Call getdns_context_set_edns_client_subnet_private() setting to 1 * expect: GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE */ struct getdns_context *context = NULL; CONTEXT_CREATE(TRUE); ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()"); expected_changed_item = GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE; ASSERT_RC(getdns_context_set_tls_query_padding_blocksize(context, 1400), GETDNS_RETURN_GOOD, "Return code from getdns_context_set_tls_query_padding_blocksize()"); CONTEXT_DESTROY; } END_TEST Suite * getdns_context_set_context_update_callback_suite (void) { Suite *s = suite_create ("getdns_context_set_context_update_callback()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_context_set_context_update_callback_1); tcase_add_test(tc_neg, getdns_context_set_context_update_callback_2); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_5); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_6); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_7); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_8); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_9); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_10); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_15); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_16); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_17); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_18); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_19); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_20); tcase_add_test(tc_pos, getdns_context_set_context_update_callback_21); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/tests_dict.c0000664000175100017510000003477512641212403014023 00000000000000/** * \file * unit tests for getdns_dict helper routines, these should be used to * perform regression tests, output must be unchanged from canonical output * stored with the sources */ /* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include "testmessages.h" #include "getdns/getdns.h" #define TSTMSGBUF 80 /*---------------------------------------- tst_bindatasetget */ /** * test the bindata get and set routines */ void tst_bindatasetget(void) { char msg[TSTMSGBUF]; char key[20]; getdns_return_t retval; struct getdns_dict *dict = NULL; struct getdns_bindata *ans_bdata; struct getdns_bindata *bindata; tstmsg_case_begin("tst_bindatasetget"); dict = getdns_dict_create(); /* test int get function against empty dict and with bogus params */ strcpy(key, "foo"); tstmsg_case_msg("getdns_dict_get_bindata() empty dict"); retval = getdns_dict_get_bindata(NULL, key, &ans_bdata); snprintf(msg, sizeof(msg), "test 1: getdns_dict_get_bindata(NULL, key, &ans_bdata),retval = %d", retval); tstmsg_case_msg(msg); retval = getdns_dict_get_bindata(dict, key, NULL); snprintf(msg, sizeof(msg), "test 2: getdns_dict_get_bindata(dict, key, NULL),retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_bindata(dict, NULL, &ans_bindata)"); retval = getdns_dict_get_bindata(dict, NULL, &ans_bdata); snprintf(msg, sizeof(msg), "test 3: getdns_dict_get_bindata,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_bindata(dict, key, &ans_bdata)"); retval = getdns_dict_get_bindata(dict, key, &ans_bdata); snprintf(msg, sizeof(msg), "test 4: getdns_list_get_bindata,retval = %d", retval); tstmsg_case_msg(msg); getdns_dict_destroy(dict); /* TODO: test getdns_dict_set functions with bogus params */ /* test set and get legitimate use case */ dict = getdns_dict_create(); strcpy(key, "foo"); bindata = (struct getdns_bindata *) malloc(sizeof(struct getdns_bindata)); bindata->size = strlen("foobar") + 1; bindata->data = (void *) strdup("foobar"); tstmsg_case_msg("getdns_dict_set_bindata(dict, key, bindata)"); retval = getdns_dict_set_bindata(dict, key, bindata); snprintf(msg, sizeof(msg), "test 5: getdns_dict_set_bindata,retval=%d,key=%s", retval, key); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_bindata(dict, key, &ans_bdata)"); retval = getdns_dict_get_bindata(dict, key, &ans_bdata); snprintf(msg, sizeof(msg), "test 6: getdns_dict_get_bindata,retval=%d,key=%s,data=%s", retval, key, ans_bdata->data); tstmsg_case_msg(msg); getdns_dict_destroy(dict); free(bindata->data); free(bindata); tstmsg_case_end(); return; } /* tst_bindatasetget */ /*---------------------------------------- tst_dictsetget */ /** * test the dict get and set routines */ void tst_dictsetget(void) { char msg[TSTMSGBUF]; char key[20]; uint32_t int1; uint32_t int2; getdns_return_t retval; struct getdns_dict *newdict; struct getdns_dict *ansdict; struct getdns_dict *dict = NULL; tstmsg_case_begin("tst_dictsetget"); dict = getdns_dict_create(); /* test get function against empty list and with bogus params */ strcpy(key, "foo"); tstmsg_case_msg("getdns_dict_get_dict() empty dict"); retval = getdns_dict_get_dict(NULL, key, &ansdict); snprintf(msg, sizeof(msg), "test 7: getdns_dict_get_dict(NULL, key, &ansdict),retval = %d", retval); tstmsg_case_msg(msg); retval = getdns_dict_get_dict(dict, key, NULL); snprintf(msg, sizeof(msg), "test 8: getdns_dict_get_dict(dict, key, NULL),retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_dict(dict, NULL, &ansdict)"); retval = getdns_dict_get_dict(dict, NULL, &ansdict); snprintf(msg, sizeof(msg), "test 9: getdns_dict_get_dict,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_dict(dict, key, &ansdict)"); retval = getdns_dict_get_dict(dict, key, &ansdict); snprintf(msg, sizeof(msg), "test 10: getdns_list_get_dict,retval = %d", retval); tstmsg_case_msg(msg); getdns_dict_destroy(dict); /* TODO: test getdns_dict_set functions with bogus params */ /* test set and get legitimate use case */ dict = getdns_dict_create(); strcpy(key, "foo"); newdict = getdns_dict_create(); getdns_dict_set_int(newdict, "foo", 42); getdns_dict_set_int(newdict, "bar", 52); tstmsg_case_msg("getdns_dict_set_dict(dict, key, newdict)"); retval = getdns_dict_set_dict(dict, key, newdict); snprintf(msg, sizeof(msg), "test 11: getdns_dict_set_dict,retval=%d,key=%s", retval, key); tstmsg_case_msg(msg); getdns_dict_destroy(newdict); tstmsg_case_msg("getdns_dict_get_dict(dict, key, &ansdict)"); retval = getdns_dict_get_dict(dict, key, &ansdict); getdns_dict_get_int(ansdict, "foo", &int1); getdns_dict_get_int(ansdict, "bar", &int2); snprintf(msg, sizeof(msg), "test 12: getdns_dict_get_dict,retval=%d,key=%s,int1=%d,int2=%d", retval, key, int1, int2); tstmsg_case_msg(msg); getdns_dict_destroy(dict); tstmsg_case_end(); return; } /* tst_dictsetget */ /*---------------------------------------- tst_getnames */ /** * exercise the getdns_dict_get_names function */ void tst_getnames(void) { size_t index; size_t llen; uint32_t ansint; int i; getdns_return_t result; getdns_data_type dtype; struct getdns_dict *dict = NULL; struct getdns_list *list = NULL; tstmsg_case_begin("tst_getnames"); dict = getdns_dict_create(); /* degenerative use cases */ tstmsg_case_msg("getdns_dict_get_names(NULL, &list)"); getdns_dict_get_names(NULL, &list); getdns_list_destroy(list); tstmsg_case_msg("getdns_dict_get_names(dict, NULL)"); getdns_dict_get_names(dict, NULL); tstmsg_case_msg ("getdns_dict_get_names(dict, &list), empty dictionary"); getdns_dict_get_names(dict, &list); getdns_list_destroy(list); /* legit use case, add items out of order to exercise tree */ /* TODO: add elements of type dict, bindata, list to the dict */ i = 0; getdns_dict_set_int(dict, "foo", i++); getdns_dict_set_int(dict, "bar", i++); getdns_dict_set_int(dict, "quz", i++); getdns_dict_set_int(dict, "alpha", i++); getdns_dict_get_names(dict, &list); result = getdns_list_get_length(list, &llen); if (result != GETDNS_RETURN_GOOD) { tstmsg_case_msg ("getdns_list_get_length failed, exiting"); return; } if (llen != i) { tstmsg_case_msg ("getdns_list_get_length returned unreasonable length, exiting"); return; } for (index = 0; index < llen; index++) { getdns_list_get_data_type(list, index, &dtype); printf(" list item %d: ", (int) index); switch (dtype) { case t_bindata: printf("NOTIMPLEMENTED"); break; case t_dict: printf("NOTIMPLEMENTED"); break; case t_int: getdns_list_get_int(list, index, &ansint); printf("t_int, value=%d\n", ansint); break; case t_list: printf("NOTIMPLEMENTED"); break; default: printf("data type invalid"); break; } } getdns_dict_destroy(dict); getdns_list_destroy(list); tstmsg_case_end(); } /* tst_getnames */ /*---------------------------------------- tst_listsetget */ /** * test the list get and set routines */ void tst_listsetget(void) { char msg[TSTMSGBUF]; char key[20]; uint32_t int1; uint32_t int2; getdns_return_t retval; struct getdns_list *newlist; struct getdns_list *anslist; struct getdns_dict *dict = NULL; tstmsg_case_begin("tst_listsetget"); dict = getdns_dict_create(); /* test get function against empty list and with bogus params */ strcpy(key, "foo"); tstmsg_case_msg("getdns_dict_get_list() empty dict"); retval = getdns_dict_get_list(NULL, key, &anslist); snprintf(msg, sizeof(msg), "test 13: getdns_dict_get_list(NULL, key, &anslist),retval = %d", retval); tstmsg_case_msg(msg); retval = getdns_dict_get_list(dict, key, NULL); snprintf(msg, sizeof(msg), "test 14: getdns_dict_get_list(dict, key, NULL),retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_list(dict, NULL, &anslist)"); retval = getdns_dict_get_list(dict, NULL, &anslist); snprintf(msg, sizeof(msg), "test 15: getdns_dict_get_list,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_list(dict, key, &anslist)"); retval = getdns_dict_get_list(dict, key, &anslist); snprintf(msg, sizeof(msg), "test 16: getdns_list_get_list,retval = %d", retval); tstmsg_case_msg(msg); getdns_dict_destroy(dict); /* TODO: test getdns_dict_set functions with bogus params */ /* test set and get legitimate use case */ dict = getdns_dict_create(); strcpy(key, "foo"); newlist = getdns_list_create(); getdns_list_set_int(newlist, 0, 42); getdns_list_set_int(newlist, 1, 52); tstmsg_case_msg("getdns_dict_set_list(dict, key, newlist)"); retval = getdns_dict_set_list(dict, key, newlist); snprintf(msg, sizeof(msg), "test 17: getdns_dict_set_list,retval=%d,key=%s", retval, key); tstmsg_case_msg(msg); getdns_list_destroy(newlist); tstmsg_case_msg("getdns_dict_get_list(dict, key, &anslist)"); retval = getdns_dict_get_list(dict, key, &anslist); getdns_list_get_int(anslist, 0, &int1); getdns_list_get_int(anslist, 1, &int2); snprintf(msg, sizeof(msg), "test 18: getdns_dict_get_list,retval=%d,key=%s,int1=%d,int2=%d", retval, key, int1, int2); tstmsg_case_msg(msg); getdns_dict_destroy(dict); tstmsg_case_end(); return; } /* tst_listsetget */ /*---------------------------------------- tst_intsetget */ /** * test the int get and set routines */ void tst_intsetget(void) { char msg[TSTMSGBUF]; char key[20]; uint32_t ans_int; uint32_t newint; getdns_return_t retval; struct getdns_dict *dict = NULL; getdns_data_type dtype; tstmsg_case_begin("tst_intsetget"); dict = getdns_dict_create(); /* test int get function against empty list and with bogus params */ strcpy(key, "foo"); tstmsg_case_msg("getdns_dict_get_int() empty dict"); retval = getdns_dict_get_int(NULL, key, &ans_int); snprintf(msg, sizeof(msg), "test 19: getdns_dict_get_int(NULL, key, &ans_int),retval = %d", retval); tstmsg_case_msg(msg); retval = getdns_dict_get_int(dict, key, NULL); snprintf(msg, sizeof(msg), "test 20: getdns_dict_get_int(dict, key, NULL),retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_int(dict, NULL, &ans_int)"); retval = getdns_dict_get_int(dict, NULL, &ans_int); snprintf(msg, sizeof(msg), "test 21: getdns_dict_get_int,retval = %d", retval); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)"); retval = getdns_dict_get_int(dict, key, &ans_int); snprintf(msg, sizeof(msg), "test 22: getdns_list_get_int,retval = %d", retval); tstmsg_case_msg(msg); getdns_dict_destroy(dict); /* TODO: test getdns_dict_set functions with bogus params */ /* test set and get legitimate use case */ dict = getdns_dict_create(); strcpy(key, "foo"); newint = 42; tstmsg_case_msg("getdns_dict_set_int(dict, key, newint)"); retval = getdns_dict_set_int(dict, key, newint); snprintf(msg, sizeof(msg), "test 23: getdns_dict_set_int,retval=%d,key=%s,int=%d", retval, key, newint); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)"); retval = getdns_dict_get_int(dict, key, &ans_int); snprintf(msg, sizeof(msg), "test 24: getdns_dict_get_int,retval=%d,key=%s,int=%d", retval, key, ans_int); tstmsg_case_msg(msg); strcpy(key, "bar"); newint = 52; tstmsg_case_msg("getdns_dict_set_int(dict, key, newint)"); retval = getdns_dict_set_int(dict, key, newint); snprintf(msg, sizeof(msg), "test 25: getdns_dict_set_int,retval=%d,key=%s,int=%d", retval, key, newint); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)"); retval = getdns_dict_get_int(dict, key, &ans_int); snprintf(msg, sizeof(msg), "test 26: getdns_dict_get_int,retval=%d,key=%s,int=%d", retval, key, ans_int); tstmsg_case_msg(msg); tstmsg_case_msg("getdns_dict_get_data_type(dict, key, &dtype)"); retval = getdns_dict_get_data_type(dict, key, &dtype); snprintf(msg, sizeof(msg), "test 27: getdns_dict_get_data_type,retval=%d,key=%s,dtype=%d", retval, key, dtype); tstmsg_case_msg(msg); getdns_dict_destroy(dict); tstmsg_case_end(); return; } /* tst_intsetget */ /*---------------------------------------- tst_create */ /** * test the create, destroy and allocation functions */ void tst_create(void) { struct getdns_dict *dict = NULL; /* make sure we can do a simple create/destroy first */ tstmsg_case_begin("tst_create"); tstmsg_case_msg("getdns_dict_create"); dict = getdns_dict_create(); if (dict != NULL) { tstmsg_case_msg("getdns_dict_destroy(dict)"); getdns_dict_destroy(dict); } tstmsg_case_msg("getdns_dict_destroy(NULL)"); getdns_dict_destroy(NULL); tstmsg_case_end(); return; } /* tst_create */ /*---------------------------------------- main */ /** * runs unit tests against list management routines */ int main(int argc, char *argv[]) { tstmsg_prog_begin("tests_dict"); tst_create(); tst_bindatasetget(); tst_dictsetget(); tst_intsetget(); tst_listsetget(); tst_getnames(); tstmsg_prog_end(); return 0; } /* main */ /* tests_dict.c */ getdns-0.9.0/src/test/check_getdns_display_ip_address.h0000664000175100017510000001123512641212403020210 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_display_ip_address_h_ #define _check_getdns_display_ip_address_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I S P L A Y _ I P _ A D D R E S S * * * ************************************************************************** */ START_TEST (getdns_display_ip_address_1) { /* * bindata_of_ipv4_or_ipv6_address = NULL * expect: NULL */ //struct getdns_bindata bindata_of_ipv4_or_ipv6_address = NULL; char *ptr = NULL; ptr = getdns_display_ip_address(NULL); ck_assert_msg(ptr == NULL, "Expected retrieved bindata == NULL, got: %p", ptr); } END_TEST START_TEST (getdns_display_ip_address_2) { /* * bindata_of_ipv4_or_ipv6_address is getdns_bindata but not ip addresses * expect: Unknown */ char *ptr = NULL; struct getdns_bindata bindata_of_ipv4_or_ipv6_address = { 8, (void *)"bindata" }; ptr = getdns_display_ip_address(&bindata_of_ipv4_or_ipv6_address); ck_assert_msg(ptr == NULL, "Expected pointer == NULL, got: %p", ptr); } END_TEST START_TEST (getdns_display_ip_address_3) { /* * Create bindata containing “10.88.30.82" * Call getdns_display_ip_address() passing bindata * expect: 10.88.30.82 */ char *ptr = NULL; struct getdns_bindata bindata_of_ipv4_or_ipv6_address = { 4, (void *)"\x0A\x58\x1E\x52" }; ptr = getdns_display_ip_address(&bindata_of_ipv4_or_ipv6_address); ck_assert_msg(strcmp(ptr, "10.88.30.82") == 0, "Expected pointer == “10.88.30.82”, got: %s", ptr); } END_TEST START_TEST (getdns_display_ip_address_4) { /* * Create bindata containing 2607:f8b0:4006:802::1004 * Call getdns_display_ip_address() passing bindata * expect: 2607:f8b0:4006:802::1004 */ char *ptr = NULL; struct getdns_bindata bindata_of_ipv4_or_ipv6_address = { 16, (void *)"\x26\x07\xf8\xb0\x40\x06\x08\x02\x00\x00\x00\x00\x00\x00\x10\x04" }; ptr = getdns_display_ip_address(&bindata_of_ipv4_or_ipv6_address); ck_assert_msg(strcmp(ptr, "2607:f8b0:4006:802::1004") == 0, "Expected pointer == “2607:f8b0:4006:802::1004”, got: %s", ptr); } END_TEST Suite * getdns_display_ip_address_suite (void) { Suite *s = suite_create ("getdns_display_ip_address()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_display_ip_address_1); tcase_add_test(tc_neg, getdns_display_ip_address_2); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_display_ip_address_3); tcase_add_test(tc_pos, getdns_display_ip_address_4); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_service.h0000664000175100017510000001512412641212403016007 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_service_h_ #define _check_getdns_service_h_ /* *************************************************** * * * T E S T S F O R G E T D N S _ S E R V I C E * * * *************************************************** */ START_TEST (getdns_service_1) { /* * context = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; getdns_transaction_t transaction_id = 0; ASSERT_RC(getdns_service(context, "google.com", NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service()"); } END_TEST START_TEST (getdns_service_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_service(context, NULL, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_service_3) { /* * name = invalid domain (too many octets) * expect: GETDNS_RETURN_BAD_DOMAIN_NAME */ struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com"; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_service(context, name, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_service()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_service_4) { /* * name is invalid (domain name label length > 63) * expect: GETDNS_RETURN_BAD_DOMAIN_NAME */ struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com"; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_service(context, name, NULL, NULL, &transaction_id, callbackfn), GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_service()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_service_5) { /* * callbackfn = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_service(context, "google.com", NULL, NULL, &transaction_id, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST START_TEST (getdns_service_7) { /* * name is (NXDOMAIN) * expect: NXDOMAIN response (with SOA record) */ void verify_getdns_service_7(struct extracted_response *ex_response); struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; ASSERT_RC(getdns_service(context, "nitinsinghit.com", NULL, verify_getdns_address_8, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_service()"); RUN_EVENT_LOOP; CONTEXT_DESTROY; } END_TEST void verify_getdns_service_7(struct extracted_response *ex_response) { assert_nxdomain(ex_response); assert_nodata(ex_response); assert_soa_in_authority(ex_response); } Suite * getdns_service_suite (void) { Suite *s = suite_create ("getdns_service()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_service_1); tcase_add_test(tc_neg, getdns_service_2); tcase_add_test(tc_neg, getdns_service_3); tcase_add_test(tc_neg, getdns_service_4); tcase_add_test(tc_neg, getdns_service_5); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_service_7); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_list_get_int.h0000664000175100017510000001255512641212403017040 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_list_get_int_h_ #define _check_getdns_list_get_int_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ L I S T _ G E T _ I N T * * * ************************************************************************** */ START_TEST (getdns_list_get_int_1) { /* * list = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; uint32_t answer; ASSERT_RC(getdns_list_get_int(list, index, &answer), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_int()"); } END_TEST START_TEST (getdns_list_get_int_2) { /* index is out of range * create a list and set index 0 to an int with a value of 100 * Call getdns_get_list() for index 1 * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); index++; ASSERT_RC(getdns_list_get_list(list, index, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()"); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_int_3) { /* data type at index is not int * create a list * Create some bindata containing "bindata" and add it to the list with name = "bindata" * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; size_t index = 0; uint32_t answer; LIST_CREATE(list); ASSERT_RC(getdns_list_set_bindata(list, index, &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()"); ASSERT_RC(getdns_list_get_int(list, index, &answer), GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_list()"); LIST_DESTROY(list); } END_TEST START_TEST (getdns_list_get_int_4) { /* answer is NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_list *list = NULL; size_t index = 0; ASSERT_RC(getdns_list_get_int(list, index, NULL), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_int()"); } END_TEST START_TEST (getdns_list_get_int_5) { /* create a list * expect: GETDNS_RETURN_GOOD */ struct getdns_list *list = NULL; size_t index = 0; uint32_t answer; LIST_CREATE(list); ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()"); ASSERT_RC(getdns_list_get_int(list, index, &answer), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()"); ck_assert_msg(answer == 1, "Expected retrieved int == 1, got: %d", answer); LIST_DESTROY(list); } END_TEST Suite * getdns_list_get_int_suite (void) { Suite *s = suite_create ("getdns_list_get_int()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_list_get_int_1); tcase_add_test(tc_neg, getdns_list_get_int_2); tcase_add_test(tc_neg, getdns_list_get_int_3); tcase_add_test(tc_neg, getdns_list_get_int_4); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_list_get_int_5); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/check_getdns_dict_set_int.h0000664000175100017510000001277612641212403017031 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _check_getdns_dict_set_int_h_ #define _check_getdns_dict_set_int_h_ /* ************************************************************************** * * * T E S T S F O R G E T D N S _ D I C T _ S E T _ I N T * * * ************************************************************************** */ START_TEST (getdns_dict_set_int_1) { /* * this_dict = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; ASSERT_RC(getdns_dict_set_int(this_dict, "key", 100), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_int()"); } END_TEST START_TEST (getdns_dict_set_int_2) { /* * name = NULL * expect: GETDNS_RETURN_INVALID_PARAMETER */ struct getdns_dict *this_dict = NULL; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, NULL, 100), GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_int()"); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_set_int_3) { /* * name already exists in dict * Create a dict * Add an int to the dict (name = "int", value = 100) * Add an int to the dict (name = "int", value = 101) * Call getdns_dict_get_int() against the dict with name = "int" * expect: GETDNS_RETURN_GOOD (all functions) * int retrieved should = 101 */ struct getdns_dict *this_dict = NULL; uint32_t value; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_int(this_dict, "int", 100), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_set_int(this_dict, "int", 101), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_int(this_dict, "int", &value), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()"); ck_assert_msg(value == 101, "Expected retrieved int == 101, got: %d", value); DICT_DESTROY(this_dict); } END_TEST START_TEST (getdns_dict_set_int_4) { /* * name already exists in dict, changing data type * Create a dict * Add bindata to the dict (name = "bindata", value = { 8, "bindata" }) * Add an int to the dict (name = "bindata", value = 101) * Call getdns_dict_get_int() with name = "bindata" * expect: GETDNS_RETURN_GOOD (all functions) * int retrieved should = 101 */ struct getdns_dict *this_dict = NULL; struct getdns_bindata bindata = { 8, (void *)"bindata" }; uint32_t value; DICT_CREATE(this_dict); ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()"); ASSERT_RC(getdns_dict_set_int(this_dict, "bindata", 101), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); ASSERT_RC(getdns_dict_get_int(this_dict, "bindata", &value), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()"); ck_assert_msg(value == 101, "Expected retrieved int == 101, got: %d", value); DICT_DESTROY(this_dict); } END_TEST Suite * getdns_dict_set_int_suite (void) { Suite *s = suite_create ("getdns_dict_set_int()"); /* Negative test caseis */ TCase *tc_neg = tcase_create("Negative"); tcase_add_test(tc_neg, getdns_dict_set_int_1); tcase_add_test(tc_neg, getdns_dict_set_int_2); suite_add_tcase(s, tc_neg); /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_dict_set_int_3); tcase_add_test(tc_pos, getdns_dict_set_int_4); suite_add_tcase(s, tc_pos); return s; } #endif getdns-0.9.0/src/test/tests_namespaces.c0000664000175100017510000001244112641212403015201 00000000000000/** * \file * unit tests for getdns_dict helper routines, these should be used to * perform regression tests, output must be unchanged from canonical output * stored with the sources */ /* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include "testmessages.h" #include "getdns/getdns.h" static void print_response(struct getdns_dict * response) { char *dict_str = getdns_pretty_print_dict(response); if (dict_str) { fprintf(stdout, "The packet %s\n", dict_str); free(dict_str); } } int main() { /* First up, use the default settings on a general and non-general call */ /* The namespaces used are per query depending on the type of method called. But note that namespaces can only be changed before the first query.*/ /* Create the DNS context for this call */ struct getdns_context *this_context = NULL; getdns_return_t context_create_return = getdns_context_create(&this_context, 1); if (context_create_return != GETDNS_RETURN_GOOD) { fprintf(stderr, "Trying to create the context failed: %d", context_create_return); return (GETDNS_RETURN_GENERIC_ERROR); } getdns_context_set_resolution_type(this_context, GETDNS_RESOLUTION_STUB); /* This will return a response with only the just_address_answers part as the current implementaiton uses [LOCALNAMES, DNS]*/ struct getdns_dict *response = NULL; getdns_return_t ret = getdns_address_sync(this_context, "localhost", NULL, &response); if (ret != GETDNS_RETURN_GOOD || response == NULL) { fprintf(stderr, "Address sync returned error.\n"); exit(EXIT_FAILURE); } print_response(response); getdns_dict_destroy(response); /* This should fall back to a full DNS lookup*/ ret = getdns_address_sync(this_context, "www.google.com", NULL, &response); if (ret != GETDNS_RETURN_GOOD || response == NULL) { fprintf(stderr, "Address sync returned error.\n"); exit(EXIT_FAILURE); } print_response(response); getdns_dict_destroy(response); /* This should return a full DNS reply as the general lookups don't use the namespaces, they just do pure DNS*/ ret = getdns_general_sync(this_context, "localhost", GETDNS_RRTYPE_A, NULL, &response); if (ret != GETDNS_RETURN_GOOD || response == NULL) { fprintf(stderr, "General sync over TCP returned error.\n"); exit(EXIT_FAILURE); } print_response(response); getdns_dict_destroy(response); /* Clean up */ getdns_context_destroy(this_context); /* Secondly, specify the namespace and see what happens*/ /* Create the DNS context for this call */ struct getdns_context *next_context = NULL; context_create_return = getdns_context_create(&next_context, 1); if (context_create_return != GETDNS_RETURN_GOOD) { fprintf(stderr, "Trying to create the context failed: %d", context_create_return); return (GETDNS_RETURN_GENERIC_ERROR); } getdns_context_set_resolution_type(next_context, GETDNS_RESOLUTION_STUB); getdns_namespace_t namespace_arr[2] = {GETDNS_NAMESPACE_DNS, GETDNS_NAMESPACE_LOCALNAMES}; getdns_context_set_namespaces(next_context, 2,namespace_arr); /* This will return a full DNS reply*/ ret = getdns_address_sync(next_context, "localhost", NULL, &response); if (ret != GETDNS_RETURN_GOOD || response == NULL) { fprintf(stderr, "Address sync returned error.\n"); exit(EXIT_FAILURE); } print_response(response); getdns_dict_destroy(response); /* Clean up */ getdns_context_destroy(next_context); /* Assuming we get here, leave gracefully */ exit(EXIT_SUCCESS); } /* main */ /* tests_stub_sync.c */ getdns-0.9.0/src/test/getdns_query.c0000664000175100017510000016626312641212403014365 00000000000000/* * Copyright (c) 2013, NLNet Labs, Verisign, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of the copyright holders nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "debug.h" #include #include #include #include #include #include #define MAX_TIMEOUTS FD_SETSIZE #define EXAMPLE_PIN "pin-sha256=\"E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=\"" /* Eventloop based on select */ typedef struct my_eventloop { getdns_eventloop base; getdns_eventloop_event *fd_events[FD_SETSIZE]; uint64_t fd_timeout_times[FD_SETSIZE]; getdns_eventloop_event *timeout_events[MAX_TIMEOUTS]; uint64_t timeout_times[MAX_TIMEOUTS]; } my_eventloop; 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; } getdns_return_t my_eventloop_schedule(getdns_eventloop *loop, int fd, uint64_t timeout, getdns_eventloop_event *event) { my_eventloop *my_loop = (my_eventloop *)loop; size_t i; assert(loop); assert(event); assert(fd < FD_SETSIZE); DEBUG_SCHED( "%s(loop: %p, fd: %d, timeout: %"PRIu64", event: %p)\n" , __FUNCTION__, loop, fd, timeout, event); if (fd >= 0 && (event->read_cb || event->write_cb)) { assert(my_loop->fd_events[fd] == NULL); my_loop->fd_events[fd] = event; my_loop->fd_timeout_times[fd] = get_now_plus(timeout); event->ev = (void *) (intptr_t) fd + 1; DEBUG_SCHED( "scheduled read/write at %d\n", fd); return GETDNS_RETURN_GOOD; } assert(event->timeout_cb && !event->read_cb && !event->write_cb); for (i = 0; i < MAX_TIMEOUTS; i++) { if (my_loop->timeout_events[i] == NULL) { my_loop->timeout_events[i] = event; my_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; } } return GETDNS_RETURN_GENERIC_ERROR; } getdns_return_t my_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event) { my_eventloop *my_loop = (my_eventloop *)loop; size_t i; assert(loop); assert(event); DEBUG_SCHED( "%s(loop: %p, event: %p)\n", __FUNCTION__, loop, event); i = (intptr_t)event->ev - 1; assert(i >= 0 && i < FD_SETSIZE); if (event->timeout_cb && !event->read_cb && !event->write_cb) { assert(my_loop->timeout_events[i] == event); my_loop->timeout_events[i] = NULL; } else { assert(my_loop->fd_events[i] == event); my_loop->fd_events[i] = NULL; } event->ev = NULL; return GETDNS_RETURN_GOOD; } void my_eventloop_cleanup(getdns_eventloop *loop) { } void my_read_cb(int fd, getdns_eventloop_event *event) { DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); event->read_cb(event->userarg); } void my_write_cb(int fd, getdns_eventloop_event *event) { DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); event->write_cb(event->userarg); } void my_timeout_cb(int fd, getdns_eventloop_event *event) { DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); event->timeout_cb(event->userarg); } void my_eventloop_run_once(getdns_eventloop *loop, int blocking) { my_eventloop *my_loop = (my_eventloop *)loop; fd_set readfds, writefds; int fd, max_fd = -1; uint64_t now, timeout = (uint64_t)-1; size_t i; struct timeval tv; assert(loop); FD_ZERO(&readfds); FD_ZERO(&writefds); now = get_now_plus(0); for (i = 0; i < MAX_TIMEOUTS; i++) { if (!my_loop->timeout_events[i]) continue; if (now > my_loop->timeout_times[i]) my_timeout_cb(-1, my_loop->timeout_events[i]); else if (my_loop->timeout_times[i] < timeout) timeout = my_loop->timeout_times[i]; } for (fd = 0; fd < FD_SETSIZE; fd++) { if (!my_loop->fd_events[fd]) continue; if (my_loop->fd_events[fd]->read_cb) FD_SET(fd, &readfds); if (my_loop->fd_events[fd]->write_cb) FD_SET(fd, &writefds); if (fd > max_fd) max_fd = fd; if (my_loop->fd_timeout_times[fd] < timeout) timeout = my_loop->fd_timeout_times[fd]; } if (max_fd == -1 && timeout == (uint64_t)-1) 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; } if (select(max_fd + 1, &readfds, &writefds, NULL, &tv) < 0) { perror("select() failed"); exit(EXIT_FAILURE); } now = get_now_plus(0); for (fd = 0; fd < FD_SETSIZE; fd++) { if (my_loop->fd_events[fd] && my_loop->fd_events[fd]->read_cb && FD_ISSET(fd, &readfds)) my_read_cb(fd, my_loop->fd_events[fd]); if (my_loop->fd_events[fd] && my_loop->fd_events[fd]->write_cb && FD_ISSET(fd, &writefds)) my_write_cb(fd, my_loop->fd_events[fd]); if (my_loop->fd_events[fd] && my_loop->fd_events[fd]->timeout_cb && now > my_loop->fd_timeout_times[fd]) my_timeout_cb(fd, my_loop->fd_events[fd]); i = fd; if (my_loop->timeout_events[i] && my_loop->timeout_events[i]->timeout_cb && now > my_loop->timeout_times[i]) my_timeout_cb(-1, my_loop->timeout_events[i]); } } void my_eventloop_run(getdns_eventloop *loop) { my_eventloop *my_loop = (my_eventloop *)loop; size_t i; assert(loop); i = 0; while (i < MAX_TIMEOUTS) { if (my_loop->fd_events[i] || my_loop->timeout_events[i]) { my_eventloop_run_once(loop, 1); i = 0; } else { i++; } } } void my_eventloop_init(my_eventloop *loop) { static getdns_eventloop_vmt my_eventloop_vmt = { my_eventloop_cleanup, my_eventloop_schedule, my_eventloop_clear, my_eventloop_run, my_eventloop_run_once }; (void) memset(loop, 0, sizeof(my_eventloop)); loop->base.vmt = &my_eventloop_vmt; } static int quiet = 0; static int batch_mode = 0; static char *query_file = NULL; static int json = 0; static char *the_root = "."; static char *name; static getdns_context *context; static getdns_dict *extensions; static getdns_list *pubkey_pinset = NULL; static size_t pincount = 0; static uint16_t request_type = GETDNS_RRTYPE_NS; static int timeout, edns0_size, padding_blocksize; static int async = 0, interactive = 0; static enum { GENERAL, ADDRESS, HOSTNAME, SERVICE } calltype = GENERAL; int get_rrtype(const char *t); int gqldns_b64_pton(char const *src, uint8_t *target, size_t targsize) { const uint8_t pad64 = 64; /* is 64th in the b64 array */ const char* s = src; uint8_t in[4]; size_t o = 0, incount = 0; while(*s) { /* skip any character that is not base64 */ /* conceptually we do: const char* b64 = pad'=' is appended to array "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; const char* d = strchr(b64, *s++); and use d-b64; */ char d = *s++; if(d <= 'Z' && d >= 'A') d -= 'A'; else if(d <= 'z' && d >= 'a') d = d - 'a' + 26; else if(d <= '9' && d >= '0') d = d - '0' + 52; else if(d == '+') d = 62; else if(d == '/') d = 63; else if(d == '=') d = 64; else continue; in[incount++] = (uint8_t)d; if(incount != 4) continue; /* process whole block of 4 characters into 3 output bytes */ if(in[3] == pad64 && in[2] == pad64) { /* A B = = */ if(o+1 > targsize) return -1; target[o] = (in[0]<<2) | ((in[1]&0x30)>>4); o += 1; break; /* we are done */ } else if(in[3] == pad64) { /* A B C = */ if(o+2 > targsize) return -1; target[o] = (in[0]<<2) | ((in[1]&0x30)>>4); target[o+1]= ((in[1]&0x0f)<<4) | ((in[2]&0x3c)>>2); o += 2; break; /* we are done */ } else { if(o+3 > targsize) return -1; /* write xxxxxxyy yyyyzzzz zzwwwwww */ target[o] = (in[0]<<2) | ((in[1]&0x30)>>4); target[o+1]= ((in[1]&0x0f)<<4) | ((in[2]&0x3c)>>2); target[o+2]= ((in[2]&0x03)<<6) | in[3]; o += 3; } incount = 0; } return (int)o; } getdns_dict * ipaddr_dict(getdns_context *context, char *ipstr) { getdns_dict *r = getdns_dict_create_with_context(context); char *s = strchr(ipstr, '%'), *scope_id_str = ""; char *p = strchr(ipstr, '@'), *portstr = ""; char *t = strchr(ipstr, '#'), *tls_portstr = ""; char *n = strchr(ipstr, '~'), *tls_namestr = ""; /* ^[alg:]name:key */ char *T = strchr(ipstr, '^'), *tsig_name_str = "" , *tsig_secret_str = "" , *tsig_algorithm_str = ""; int tsig_secret_size; uint8_t tsig_secret_buf[256]; /* 4 times SHA512 */ getdns_bindata tsig_secret; uint8_t buf[sizeof(struct in6_addr)]; getdns_bindata addr; addr.data = buf; if (!r) return NULL; if (s) { *s = 0; scope_id_str = s + 1; } if (p) { *p = 0; portstr = p + 1; } if (t) { *t = 0; tls_portstr = t + 1; } if (n) { *n = 0; tls_namestr = n + 1; } if (T) { *T = 0; tsig_name_str = T + 1; if ((T = strchr(tsig_name_str, ':'))) { *T = 0; tsig_secret_str = T + 1; if ((T = strchr(tsig_secret_str, ':'))) { *T = 0; tsig_algorithm_str = tsig_name_str; tsig_name_str = tsig_secret_str; tsig_secret_str = T + 1; } } else { tsig_name_str = ""; } } if (strchr(ipstr, ':')) { getdns_dict_util_set_string(r, "address_type", "IPv6"); addr.size = 16; if (inet_pton(AF_INET6, ipstr, buf) <= 0) { getdns_dict_destroy(r); return NULL; } } else { getdns_dict_util_set_string(r, "address_type", "IPv4"); addr.size = 4; if (inet_pton(AF_INET, ipstr, buf) <= 0) { getdns_dict_destroy(r); return NULL; } } getdns_dict_set_bindata(r, "address_data", &addr); if (*portstr) getdns_dict_set_int(r, "port", (int32_t)atoi(portstr)); if (*tls_portstr) getdns_dict_set_int(r, "tls_port", (int32_t)atoi(tls_portstr)); if (*tls_namestr) { getdns_dict_util_set_string(r, "tls_auth_name", tls_namestr); } if (*scope_id_str) getdns_dict_util_set_string(r, "scope_id", scope_id_str); if (*tsig_name_str) getdns_dict_util_set_string(r, "tsig_name", tsig_name_str); if (*tsig_algorithm_str) getdns_dict_util_set_string(r, "tsig_algorithm", tsig_algorithm_str); if (*tsig_secret_str) { tsig_secret_size = gqldns_b64_pton( tsig_secret_str, tsig_secret_buf, sizeof(tsig_secret_buf)); if (tsig_secret_size > 0) { tsig_secret.size = tsig_secret_size; tsig_secret.data = tsig_secret_buf; getdns_dict_set_bindata(r, "tsig_secret", &tsig_secret); } } return r; } static getdns_return_t fill_transport_list(getdns_context *context, char *transport_list_str, getdns_transport_list_t *transports, size_t *transport_count) { size_t max_transports = *transport_count; *transport_count = 0; for ( size_t i = 0 ; i < max_transports && i < strlen(transport_list_str) ; i++, (*transport_count)++) { switch(*(transport_list_str + i)) { case 'U': transports[i] = GETDNS_TRANSPORT_UDP; break; case 'T': transports[i] = GETDNS_TRANSPORT_TCP; break; case 'L': transports[i] = GETDNS_TRANSPORT_TLS; break; default: fprintf(stderr, "Unrecognised transport '%c' in string %s\n", *(transport_list_str + i), transport_list_str); return GETDNS_RETURN_GENERIC_ERROR; } } return GETDNS_RETURN_GOOD; } void print_usage(FILE *out, const char *progname) { fprintf(out, "usage: %s [