Miscellaneous fixes to compile on windows

Also without warnings.
This commit is contained in:
Willem Toorop 2015-12-24 14:41:50 +01:00
parent caba5f19d5
commit 9d3905459e
12 changed files with 301 additions and 1919 deletions

View File

@ -193,6 +193,7 @@ $(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

View File

@ -255,20 +255,18 @@ libidn
The windows version of getdns currently only is supported in the stub only mode.
To configure:
./configure --enable-use-winsock --enable-stub-only --with-trust-anchor="c:\\\MinGW\\\msys\\\1.0\\\etc\\\unbound\\\getdns-root.key"
./configure --enable-stub-only --with-trust-anchor="c:\\\MinGW\\\msys\\\1.0\\\etc\\\unbound\\\getdns-root.key" --with-ssl=/c/OpenSSL --with-getdns_query
The trust anchor is also installed by unbound on c:\program Files (X86)\unbound\root.key and can be referenced from there
or anywhere else that the user chooses to configure it.
After configuring, do a 'make' and 'make install' to build getdns for Windows.
There is a sample, getdns_query.exe which can be built in src/samplewin using 'make'
Example test queries:
./getdns_query.exe -s gmadkat.com A @64.6.64.6 +return_call_debugging (UDP)
./getdns_query.exe -s gmadkat.com A @64.6.64.6 -T +return_call_debugging (TCP)
./getdns_query.exe -s gmadkat.com A -l L @185.49.141.37 +return_call_debugging (TLS without authentication)
./getdns_query.exe -s www.huque.com A +dnssec_return_status +return_call_debugging (DNSSEC)
./getdns_query.exe -s gmadkat.com A @64.6.64.6 +return_call_reporting (UDP)
./getdns_query.exe -s gmadkat.com A @64.6.64.6 -T +return_call_reporting (TCP)
./getdns_query.exe -s gmadkat.com A -l L @185.49.141.37 +return_call_reporting (TLS without authentication)
./getdns_query.exe -s www.huque.com A +dnssec_return_status +return_call_reporting (DNSSEC)
Contributors
============

View File

@ -32,6 +32,7 @@
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)
@ -444,56 +445,53 @@ case "$enable_stub_only" in
esac
# search to set include and library paths right
# find libidn
my_with_libidn=1
AC_MSG_NOTICE([Checking if building on Windows])
AC_ARG_ENABLE(use-winsock, AC_HELP_STRING([--enable-use-winsock], [Enable building for Microsoft Windows using mingw]))
case "$enable_use_winsock" in
yes)
AC_MSG_NOTICE([ Building on Windows ... YES! ])
AC_DEFINE_UNQUOTED([USE_WINSOCK], [1], [Define this to enable Windows build.])
AC_DEFINE_UNQUOTED([GETDNS_ON_WINDOWS], [1], [Define this to enable Windows build.])
AC_DEFINE_UNQUOTED([HAVE_WINSOCK2_H], [1], [Define this to enable Windows build.])
AC_DEFINE_UNQUOTED([HAVE_WS2TCPIP_H], [1], [Define this to enable Windows build.])
AC_DEFINE_UNQUOTED([STUB_NATIVE_DNSSEC], [1], [Define this to enable Windows build.])
my_with_libunbound=0
my_with_libidn=0
;;
no|*)
AC_MSG_NOTICE([ Building on Windows ... YES! ])
;;
esac
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
# 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
if test x_$withval != x_no; then
CFLAGS="$CFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
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
my_with_libidn=0
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
@ -1105,6 +1103,14 @@ 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

81
m4/acx_getaddrinfo.m4 Normal file
View File

@ -0,0 +1,81 @@
# Taken from acx_nlnetlabs.m4 - common macros for configure checks
# Copyright 2009, Wouter Wijngaards, NLnet Labs.
# BSD licensed.
#
dnl Check getaddrinfo.
dnl Works on linux, solaris, bsd and windows(links winsock).
dnl defines HAVE_GETADDRINFO, USE_WINSOCK.
AC_DEFUN([ACX_CHECK_GETADDRINFO_WITH_INCLUDES],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(for getaddrinfo)
ac_cv_func_getaddrinfo=no
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#ifdef __cplusplus
extern "C"
{
#endif
char* getaddrinfo();
char* (*f) () = getaddrinfo;
#ifdef __cplusplus
}
#endif
int main() {
;
return 0;
}
]])],
dnl this case on linux, solaris, bsd
[ac_cv_func_getaddrinfo="yes"
dnl see if on windows
if test "$ac_cv_header_windows_h" = "yes"; then
AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used])
USE_WINSOCK="1"
LIBS="$LIBS -lws2_32"
fi
],
dnl no quick getaddrinfo, try mingw32 and winsock2 library.
ORIGLIBS="$LIBS"
LIBS="$LIBS -lws2_32"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[
#define _WIN32_WINNT 0x0501
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#ifdef HAVE_WINSOCK_H
#include <winsock.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#include <stdio.h>
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
],
[
(void)getaddrinfo(NULL, NULL, NULL, NULL);
]
)],
[
ac_cv_func_getaddrinfo="yes"
dnl already: LIBS="$LIBS -lws2_32"
AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used])
USE_WINSOCK="1"
],
[
ac_cv_func_getaddrinfo="no"
LIBS="$ORIGLIBS"
])
)
AC_MSG_RESULT($ac_cv_func_getaddrinfo)
if test $ac_cv_func_getaddrinfo = yes; then
AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether getaddrinfo is available])
fi
])dnl Endof AC_CHECK_GETADDRINFO_WITH_INCLUDES
dnl End of file

View File

@ -106,7 +106,6 @@ getdns_port_str_array[] = {
/* 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 getdns_return_t set_os_defaults(struct getdns_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 *);
@ -705,6 +704,89 @@ upstream_init(getdns_upstream *upstream,
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, length;
struct getdns_bindata bindata;
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->suffix = getdns_list_create_with_context(context);
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);
}
(void)getdns_list_get_length(context->suffix, &length);
if (length == 0 && *domain != 0) {
bindata.data = (uint8_t *)domain;
bindata.size = strlen(domain) + 1;
(void)getdns_list_set_bindata(context->suffix, 0, &bindata);
}
return GETDNS_RETURN_GOOD;
} /* set_os_defaults_windows */
#else
static getdns_return_t
set_os_defaults(struct getdns_context *context)
{
@ -816,92 +898,6 @@ set_os_defaults(struct getdns_context *context)
_getdns_list_append_string(context->suffix, domain);
return GETDNS_RETURN_GOOD;
} /* set_os_defaults */
#ifdef USE_WINSOCK
static getdns_return_t
set_os_defaults_windows(struct getdns_context *context)
{
FILE *in;
char line[1024], domain[1024];
char *parse, *token, prev_ch;
size_t upstreams_limit = 10, length;
struct getdns_bindata bindata;
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->suffix = getdns_list_create_with_context(context);
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) {
int retval = 0;
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);
}
(void)getdns_list_get_length(context->suffix, &length);
if (length == 0 && *domain != 0) {
bindata.data = (uint8_t *)domain;
bindata.size = strlen(domain) + 1;
(void)getdns_list_set_bindata(context->suffix, 0, &bindata);
}
return GETDNS_RETURN_GOOD;
} /* set_os_defaults_windows */
#endif
/* compare of transaction ids in DESCENDING order

View File

@ -346,50 +346,50 @@ _getdns_hostname_loop(getdns_context *context, getdns_eventloop *loop,
switch (address_data->size) {
case 4:
(void)snprintf(name, sizeof(name),
"%hhu.%hhu.%hhu.%hhu.in-addr.arpa.",
((uint8_t *)address_data->data)[3],
((uint8_t *)address_data->data)[2],
((uint8_t *)address_data->data)[1],
((uint8_t *)address_data->data)[0]);
"%d.%d.%d.%d.in-addr.arpa.",
(int)((uint8_t *)address_data->data)[3],
(int)((uint8_t *)address_data->data)[2],
(int)((uint8_t *)address_data->data)[1],
(int)((uint8_t *)address_data->data)[0]);
break;
case 16:
(void)snprintf(name, sizeof(name),
"%hhx.%hhx.%hhx.%hhx.%hhx.%hhx.%hhx.%hhx."
"%hhx.%hhx.%hhx.%hhx.%hhx.%hhx.%hhx.%hhx."
"%hhx.%hhx.%hhx.%hhx.%hhx.%hhx.%hhx.%hhx."
"%hhx.%hhx.%hhx.%hhx.%hhx.%hhx.%hhx.%hhx.ip6.arpa.",
(uint8_t)(((uint8_t *)address_data->data)[15] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[15] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[14] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[14] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[13] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[13] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[12] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[12] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[11] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[11] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[10] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[10] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[9] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[9] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[8] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[8] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[7] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[7] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[6] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[6] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[5] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[5] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[4] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[4] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[3] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[3] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[2] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[2] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[1] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[1] >> 4),
(uint8_t)(((uint8_t *)address_data->data)[0] & 0x0F),
(uint8_t)(((uint8_t *)address_data->data)[0] >> 4));
"%x.%x.%x.%x.%x.%x.%x.%x."
"%x.%x.%x.%x.%x.%x.%x.%x."
"%x.%x.%x.%x.%x.%x.%x.%x."
"%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa.",
(int)(((uint8_t *)address_data->data)[15] & 0x0F),
(int)(((uint8_t *)address_data->data)[15] >> 4),
(int)(((uint8_t *)address_data->data)[14] & 0x0F),
(int)(((uint8_t *)address_data->data)[14] >> 4),
(int)(((uint8_t *)address_data->data)[13] & 0x0F),
(int)(((uint8_t *)address_data->data)[13] >> 4),
(int)(((uint8_t *)address_data->data)[12] & 0x0F),
(int)(((uint8_t *)address_data->data)[12] >> 4),
(int)(((uint8_t *)address_data->data)[11] & 0x0F),
(int)(((uint8_t *)address_data->data)[11] >> 4),
(int)(((uint8_t *)address_data->data)[10] & 0x0F),
(int)(((uint8_t *)address_data->data)[10] >> 4),
(int)(((uint8_t *)address_data->data)[9] & 0x0F),
(int)(((uint8_t *)address_data->data)[9] >> 4),
(int)(((uint8_t *)address_data->data)[8] & 0x0F),
(int)(((uint8_t *)address_data->data)[8] >> 4),
(int)(((uint8_t *)address_data->data)[7] & 0x0F),
(int)(((uint8_t *)address_data->data)[7] >> 4),
(int)(((uint8_t *)address_data->data)[6] & 0x0F),
(int)(((uint8_t *)address_data->data)[6] >> 4),
(int)(((uint8_t *)address_data->data)[5] & 0x0F),
(int)(((uint8_t *)address_data->data)[5] >> 4),
(int)(((uint8_t *)address_data->data)[4] & 0x0F),
(int)(((uint8_t *)address_data->data)[4] >> 4),
(int)(((uint8_t *)address_data->data)[3] & 0x0F),
(int)(((uint8_t *)address_data->data)[3] >> 4),
(int)(((uint8_t *)address_data->data)[2] & 0x0F),
(int)(((uint8_t *)address_data->data)[2] >> 4),
(int)(((uint8_t *)address_data->data)[1] & 0x0F),
(int)(((uint8_t *)address_data->data)[1] >> 4),
(int)(((uint8_t *)address_data->data)[0] & 0x0F),
(int)(((uint8_t *)address_data->data)[0] >> 4));
break;
default:
return GETDNS_RETURN_INVALID_PARAMETER;

View File

@ -1,150 +0,0 @@
#
# @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@ -I/usr/local/ssl/include
LDFLAGS=-L.. @LDFLAGS@ -L/usr/local/ssl/lib -L/usr/local/lib/
LDLIBS=../libgetdns.la @LIBS@ -lldns -lssl -lcrypto -lgdi32 -lws2_32 -liphlpapi
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) getdns_query.lo
PROGRAMS=getdns_query
.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 $@
getdns_query: getdns_query.lo
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ getdns_query.lo $(LDFLAGS) $(LDLIBS)
clean:
rm -f *.o *.lo $(PROGRAMS) scratchpad
rm -rf .libs
rm -f check_getdns.log
$(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 )
(cd $(srcdir) ; gcc -MM -I. -I.. *.c | \
sed -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!\(.*\)\.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
getdns_query.lo getdns_query.o: $(srcdir)/getdns_query.c ../config.h ../getdns/getdns.h \
../getdns/getdns_extra.h

File diff suppressed because it is too large Load Diff

View File

@ -639,7 +639,7 @@ stub_tcp_read(int fd, getdns_tcp_state *tcp, struct mem_funcs *mf, getdns_eventl
tcp->read_pos = tcp->read_buf;
tcp->to_read = 2; /* Packet size */
}
read = recv(fd, tcp->read_pos, tcp->to_read, 0);
read = recv(fd, (void *)tcp->read_pos, tcp->to_read, 0);
if (read == -1) {
#ifdef USE_WINSOCK
printf("read (in tcp ) %s\n",
@ -649,7 +649,7 @@ stub_tcp_read(int fd, getdns_tcp_state *tcp, struct mem_funcs *mf, getdns_eventl
if (WSAGetLastError() == WSAEINPROGRESS)
return STUB_TCP_AGAIN;
if (WSAGetLastError() == WSAEWOULDBLOCK) {
winsock_tcp_wouldblock(event, EV_READ);
winsock_tcp_wouldblock(event->ev, EV_READ);
return STUB_TCP_AGAIN;
}
@ -773,9 +773,10 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
#else
#ifdef USE_WINSOCK
written = sendto(fd, netreq->query - 2, pkt_len + 2,
0, (struct sockaddr *)&(netreq->upstream->addr),
netreq->upstream->addr_len);
written = sendto(fd, (const char *)(netreq->query - 2),
pkt_len + 2, 0,
(struct sockaddr *)&(netreq->upstream->addr),
netreq->upstream->addr_len);
#else
written = write(fd, netreq->query - 2, pkt_len + 2);
@ -1283,7 +1284,7 @@ stub_udp_read_cb(void *userarg)
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
read = recvfrom(netreq->fd, netreq->response,
read = recvfrom(netreq->fd, (void *)netreq->response,
netreq->max_udp_payload_size + 1, /* If read == max_udp_payload_size
* then all is good. If read ==
* max_udp_payload_size + 1, then
@ -1363,7 +1364,8 @@ stub_udp_write_cb(void *userarg)
return; /* too many upstream options */
}
pkt_len = _getdns_network_req_add_tsig(netreq);
if ((ssize_t)pkt_len != sendto(netreq->fd, netreq->query, pkt_len, 0,
if ((ssize_t)pkt_len != sendto(
netreq->fd, (const void *)netreq->query, pkt_len, 0,
(struct sockaddr *)&netreq->upstream->addr,
netreq->upstream->addr_len)) {
close(netreq->fd);
@ -1394,7 +1396,7 @@ upstream_read_cb(void *userarg)
&upstream->upstreams->mf);
else
q = stub_tcp_read(upstream->fd, &upstream->tcp,
&upstream->upstreams->mf, &netreq->event);
&upstream->upstreams->mf, &upstream->event);
switch (q) {
case STUB_TCP_AGAIN:

View File

@ -549,8 +549,7 @@ static getdns_return_t validate_chain(getdns_dict *response)
if ((r = getdns_list_set_dict(to_validate, 0, reply)))
goto error;
fprintf( stdout
, "reply %zu, dnssec_status: ", i);
printf("reply %u, dnssec_status: ", (unsigned)i);
switch ((s = getdns_validate_dnssec(
to_validate, validation_chain, trust_anchor))) {
@ -598,14 +597,13 @@ void callback(getdns_context *context, getdns_callback_type_t callback_type,
}
if (callback_type == GETDNS_CALLBACK_COMPLETE) {
fprintf(stdout,
"Response code was: GOOD. Status was: Callback with ID %llu was successfull.\n",
(unsigned long long)trans_id);
printf("Response code was: GOOD. Status was: Callback with ID %"PRIu64" was successfull.\n",
trans_id);
} else if (callback_type == GETDNS_CALLBACK_CANCEL)
fprintf(stderr,
"An error occurred: The callback with ID %llu was cancelled. Exiting.\n",
(unsigned long long)trans_id);
"An error occurred: The callback with ID %"PRIu64" was cancelled. Exiting.\n",
trans_id);
else {
fprintf(stderr,
"An error occurred: The callback got a callback_type of %d. Exiting.\n",

View File

@ -58,7 +58,8 @@ log_err(const char *format, ...)
{
va_list args;
va_start(args, format);
fprintf(stderr, "error", format, args);
fprintf(stderr, "error ");
fprintf(stderr, format, args);
va_end(args);
}
@ -353,7 +354,7 @@ int _getdns_handle_select(struct _getdns_event_base* base, struct timeval* wait)
DWORD ret;
WSANETWORKEVENTS netev;
struct _getdns_event* eventlist[WSK_MAX_ITEMS];
int i, numwait = 0, startidx = 0, was_timeout = 0;
int i, numwait = 0, startidx = 0;
int newstickies = 0;
struct timeval nultm;
@ -379,7 +380,7 @@ int _getdns_handle_select(struct _getdns_event_base* base, struct timeval* wait)
base->waitfor[numwait++] = base->items[i]->hEvent;
printf("winsock_event bmax=%d numwait=%d wait=%x "
"timeout=%d hEvent %d\n", base->max, numwait, (int)wait,
(int)timeout, base->items[i]->hEvent);
(int)timeout, (int)base->items[i]->hEvent);
if (numwait == WSK_MAX_ITEMS)
break; /* sanity check */
}
@ -391,7 +392,6 @@ int _getdns_handle_select(struct _getdns_event_base* base, struct timeval* wait)
if(wait) {
Sleep(timeout);
}
was_timeout = 1;
}
else {
//gv: do not schedule udp write
@ -409,7 +409,7 @@ int _getdns_handle_select(struct _getdns_event_base* base, struct timeval* wait)
0 /* do not wait for all, just one will do */,
wait?timeout:WSA_INFINITE,
0); /* we are not alertable (IO completion events) */
printf("after wait %d %d\n", ret, numwait);
printf("after wait %d %d\n", (int)ret, numwait);
if(ret == WSA_WAIT_IO_COMPLETION) {
//printf("getdns: WSAWaitForMultipleEvents failed: WSA_WAIT_IO_COMPLETION");
return -1;
@ -419,7 +419,6 @@ int _getdns_handle_select(struct _getdns_event_base* base, struct timeval* wait)
return -1;
} else if(ret == WSA_WAIT_TIMEOUT) {
printf("timeout\n");
was_timeout = 1;
} else
startidx = ret - WSA_WAIT_EVENT_0;
}
@ -633,25 +632,6 @@ int _getdns_event_base_set(struct _getdns_event_base *base, struct _getdns_event
return 0;
}
/**
* Find a fd in the list of items.
* Note that not all items have a fd associated (those are -1).
* Signals are stored separately, and not searched.
* @param base: event base to look in.
* @param fd: what socket to look for.
* @return the index in the array, or -1 on failure.
*/
static int
find_fd(struct _getdns_event_base* base, int fd)
{
int i;
for (i = 0; i<base->max; i++) {
if (base->items[i]->ev_fd == fd)
return i;
}
return -1;
}
int _getdns_event_add(struct _getdns_event *ev, struct timeval *tv)
{
printf( "event_add %p added=%d fd=%d tv=" ARG_LL "d %s%s%s\n",
@ -714,7 +694,7 @@ int _getdns_event_add(struct _getdns_event *ev, struct timeval *tv)
wsa_strerror(WSAGetLastError()));
/* automatically sets fd to nonblocking mode.
* nonblocking cannot be disabled, until wsaES(fd, NULL, 0) */
printf("\nWSAEventSelect %d events %d hEvent %d\n", ev->ev_fd, events, ev->hEvent);
printf("\nWSAEventSelect %d events %d hEvent %d\n", ev->ev_fd, (int)events, (int)ev->hEvent);
if (WSAEventSelect(ev->ev_fd, ev->hEvent, events) != 0) {
log_err("getdns: WSAEventSelect in getdns failed: %s",
wsa_strerror(WSAGetLastError()));
@ -722,13 +702,13 @@ int _getdns_event_add(struct _getdns_event *ev, struct timeval *tv)
if(ev->is_tcp && ev->stick_events &&
(ev->ev_events & ev->old_events)) {
/* go to processing the sticky event right away */
printf("\nWSAEventSelect sticky %d events %d hEvent %d\n", ev->ev_fd, events, ev->hEvent);
printf("\nWSAEventSelect sticky %d events %d hEvent %d\n", ev->ev_fd, (int)events, (int)ev->hEvent);
ev->ev_base->tcp_reinvigorated = 1;
}
}
if(tv && (ev->ev_events&EV_TIMEOUT)) {
printf("\nWSAEventSelect timeout %d hEvent %d\n", ev->ev_fd, ev->hEvent);
printf("\nWSAEventSelect timeout %d hEvent %d\n", ev->ev_fd, (int)ev->hEvent);
#ifndef S_SPLINT_S
struct timeval *now = ev->ev_base->time_tv;
@ -787,14 +767,8 @@ static struct _getdns_event_base* signal_base = NULL;
/** signal handler */
static RETSIGTYPE sigh(int sig)
{
struct getdns_event* ev;
if(!signal_base || sig < 0 || sig >= MAX_SIG)
return;
ev = signal_base->signals[sig];
if(!ev)
return;
//g fptr_ok(fptr_whitelist_event(ev->ev_callback));
//g (*ev->ev_callback)(sig, EV_SIGNAL, ev->ev_arg);
}
int _getdns_signal_add(struct _getdns_event *ev, struct timeval * ATTR_UNUSED(tv))

View File

@ -95,15 +95,15 @@
/* redefine the calls to different names so that there is no name
* collision with other code that uses libevent names. (that uses libunbound)*/
#define event_init winsockevent_init
#define _getdns_event_init winsockevent_init
#define event_get_version winsockevent_get_version
#define event_get_method winsockevent_get_method
#define _getdns_event_base_dispatch winsockevent_base_dispatch
#define event_base_loopexit winsockevent_base_loopexit
#define _getdns_event_base_free winsockevent_base_free
#define event_set winsockevent_set
#define event_base_set winsockevent_base_set
#define event_add winsockevent_add
#define _getdns_event_set winsockevent_set
#define _getdns_event_base_set winsockevent_base_set
#define _getdns_event_add winsockevent_add
#define _getdns_event_del winsockevent_del
#define signal_add winsocksignal_add
#define signal_del winsocksignal_del
@ -225,26 +225,26 @@ struct _getdns_event {
char* wsa_strerror(DWORD err);
void log_err(const char *format, ...);
/** create event base */
void *event_init(time_t* time_secs, struct timeval* time_tv);
void *_getdns_event_init(time_t* time_secs, struct timeval* time_tv);
/** get version */
const char *event_get_version(void);
/** get polling method (select,epoll) */
const char *event_get_method(void);
/** run select in a loop */
int event_base_dispatch(struct _getdns_event_base *);
int _getdns_event_base_dispatch(struct _getdns_event_base *);
/** exit that loop */
int event_base_loopexit(struct _getdns_event_base *, struct timeval *);
/** free event base. Free events yourself */
void event_base_free(struct _getdns_event_base *);
void _getdns_event_base_free(struct _getdns_event_base *);
/** set content of event */
void event_set(struct _getdns_event *, int, short, void (*)(int, short, void *), void *);
void _getdns_event_set(struct _getdns_event *, int, short, void (*)(int, short, void *), void *);
/** add event to a base. You *must* call this for every event. */
int event_base_set(struct _getdns_event_base *, struct _getdns_event *);
int _getdns_event_base_set(struct _getdns_event_base *, struct _getdns_event *);
/** add event to make it active. You may not change it with event_set anymore */
int event_add(struct _getdns_event *, struct timeval *);
int _getdns_event_add(struct _getdns_event *, struct timeval *);
/** remove event. You may change it again */
int event_del(struct _getdns_event *);
int _getdns_event_del(struct _getdns_event *);
#define evtimer_add(ev, tv) event_add(ev, tv)
#define evtimer_del(ev) event_del(ev)
@ -282,14 +282,14 @@ void winsock_tcp_wouldblock(struct _getdns_event* ev, int eventbit);
* @param arg: user argument to callback routine.
* @return false on error.
*/
static int winsock_register_wsaevent(struct _getdns_event_base* base, struct _getdns_event* ev,
int winsock_register_wsaevent(struct _getdns_event_base* base, struct _getdns_event* ev,
WSAEVENT wsaevent, void (*cb)(int, short, void*), void* arg);
/**
* Unregister a wsaevent. User has to close the WSAEVENT itself.
* @param ev: event data storage.
*/
static void winsock_unregister_wsaevent(struct _getdns_event* ev);
void winsock_unregister_wsaevent(struct _getdns_event* ev);
#endif /* USE_WINSOCK */
#endif /* UTIL_WINSOCK_EVENT_H */