mirror of https://github.com/getdnsapi/getdns.git
Merge branch 'develop' of github.com:verisign/getdns into develop
This commit is contained in:
commit
99575d89ea
|
@ -634,6 +634,8 @@ ac_includes_default="\
|
||||||
|
|
||||||
ac_subst_vars='LTLIBOBJS
|
ac_subst_vars='LTLIBOBJS
|
||||||
LIBOBJS
|
LIBOBJS
|
||||||
|
EXTENSION_LIBEV_OBJ
|
||||||
|
have_libev
|
||||||
EXTENSION_LIBUV_OBJ
|
EXTENSION_LIBUV_OBJ
|
||||||
have_libuv
|
have_libuv
|
||||||
EXTENSION_LIBEVENT_OBJ
|
EXTENSION_LIBEVENT_OBJ
|
||||||
|
@ -11295,6 +11297,74 @@ fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# libev extension
|
||||||
|
have_libev=1
|
||||||
|
EXTENSION_LIBEV_OBJ="extension/libev.lo"
|
||||||
|
{ $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"
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_LIBEV 1" >>confdefs.h
|
||||||
|
|
||||||
|
else
|
||||||
|
have_libev=0
|
||||||
|
EXTENSION_LIBEV_OBJ=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ac_config_files="$ac_config_files Makefile src/Makefile src/getdns/Makefile src/example/Makefile src/test/Makefile doc/Makefile"
|
ac_config_files="$ac_config_files Makefile src/Makefile src/getdns/Makefile src/example/Makefile src/test/Makefile doc/Makefile"
|
||||||
|
|
||||||
if test -n "$DOXYGEN"
|
if test -n "$DOXYGEN"
|
||||||
|
|
12
configure.ac
12
configure.ac
|
@ -195,6 +195,18 @@ AC_SEARCH_LIBS([uv_run],
|
||||||
AC_SUBST(have_libuv)
|
AC_SUBST(have_libuv)
|
||||||
AC_SUBST(EXTENSION_LIBUV_OBJ)
|
AC_SUBST(EXTENSION_LIBUV_OBJ)
|
||||||
|
|
||||||
|
# libev extension
|
||||||
|
have_libev=1
|
||||||
|
EXTENSION_LIBEV_OBJ="extension/libev.lo"
|
||||||
|
AC_SEARCH_LIBS([ev_run],
|
||||||
|
[ev],
|
||||||
|
[AC_DEFINE([HAVE_LIBEV], [1], [Define to 1 to enable the libev extension])],
|
||||||
|
[have_libev=0]
|
||||||
|
[EXTENSION_LIBEV_OBJ=""])
|
||||||
|
|
||||||
|
AC_SUBST(have_libev)
|
||||||
|
AC_SUBST(EXTENSION_LIBEV_OBJ)
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile src/Makefile src/getdns/Makefile src/example/Makefile src/test/Makefile doc/Makefile])
|
AC_CONFIG_FILES([Makefile src/Makefile src/getdns/Makefile src/example/Makefile src/test/Makefile doc/Makefile])
|
||||||
if [ test -n "$DOXYGEN" ]
|
if [ test -n "$DOXYGEN" ]
|
||||||
then AC_CONFIG_FILES([src/Doxyfile])
|
then AC_CONFIG_FILES([src/Doxyfile])
|
||||||
|
|
|
@ -34,10 +34,11 @@ CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I/usr/local/include -std=c99
|
||||||
LDFLAGS=@LDFLAGS@ @LIBS@
|
LDFLAGS=@LDFLAGS@ @LIBS@
|
||||||
EXTENSION_LIBEVENT_OBJ=@EXTENSION_LIBEVENT_OBJ@
|
EXTENSION_LIBEVENT_OBJ=@EXTENSION_LIBEVENT_OBJ@
|
||||||
EXTENSION_LIBUV_OBJ=@EXTENSION_LIBUV_OBJ@
|
EXTENSION_LIBUV_OBJ=@EXTENSION_LIBUV_OBJ@
|
||||||
|
EXTENSION_LIBEV_OBJ=@EXTENSION_LIBEV_OBJ@
|
||||||
GETDNS_OBJ=sync.lo context.lo list.lo dict.lo convert.lo general.lo \
|
GETDNS_OBJ=sync.lo context.lo list.lo dict.lo convert.lo general.lo \
|
||||||
hostname.lo service.lo request-internal.lo validate_dnssec.lo \
|
hostname.lo service.lo request-internal.lo validate_dnssec.lo \
|
||||||
util-internal.lo getdns_error.lo rr-dict.lo validation-chain.lo \
|
util-internal.lo getdns_error.lo rr-dict.lo validation-chain.lo \
|
||||||
$(EXTENSION_LIBEVENT_OBJ) $(EXTENSION_LIBUV_OBJ)
|
$(EXTENSION_LIBEVENT_OBJ) $(EXTENSION_LIBUV_OBJ) $(EXTENSION_LIBEV_OBJ)
|
||||||
|
|
||||||
.SUFFIXES: .c .o .a .lo .h
|
.SUFFIXES: .c .o .a .lo .h
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#undef HAVE_INTTYPES_H
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
|
/* Define to 1 to enable the libev extension */
|
||||||
|
#undef HAVE_LIBEV
|
||||||
|
|
||||||
/* Define to 1 to enable the libevent extension */
|
/* Define to 1 to enable the libevent extension */
|
||||||
#undef HAVE_LIBEVENT
|
#undef HAVE_LIBEVENT
|
||||||
|
|
||||||
|
|
|
@ -1396,7 +1396,7 @@ getdns_context_clear_timeout(struct getdns_context* context,
|
||||||
getdns_timeout_data_t* timeout_data = (getdns_timeout_data_t*) node->data;
|
getdns_timeout_data_t* timeout_data = (getdns_timeout_data_t*) node->data;
|
||||||
GETDNS_FREE(context->my_mf, node);
|
GETDNS_FREE(context->my_mf, node);
|
||||||
if (context->extension) {
|
if (context->extension) {
|
||||||
context->extension->clear_timeout(context, context->extension,
|
context->extension->clear_timeout(context, context->extension_data,
|
||||||
timeout_data->extension_timer);
|
timeout_data->extension_timer);
|
||||||
} else {
|
} else {
|
||||||
/* make sure it is removed from the timeout node */
|
/* make sure it is removed from the timeout node */
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
#include "config.h"
|
||||||
|
#ifdef HAVE_EVENT2_EVENT_H
|
||||||
|
# include <event2/event.h>
|
||||||
|
#else
|
||||||
|
# include <event.h>
|
||||||
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -34,6 +34,12 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#ifdef HAVE_EVENT2_EVENT_H
|
||||||
|
# include <event2/event.h>
|
||||||
|
#else
|
||||||
|
# include <event.h>
|
||||||
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
#include "config.h"
|
||||||
|
#ifdef HAVE_EVENT2_EVENT_H
|
||||||
|
# include <event2/event.h>
|
||||||
|
#else
|
||||||
|
# include <event.h>
|
||||||
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
/**
|
||||||
|
* \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, Versign, 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 name of the <organization> nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* 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 <getdns/getdns_ext_libev.h>
|
||||||
|
#include "config.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ev.h>
|
||||||
|
|
||||||
|
#define RETURN_IF_NULL(ptr, code) if(ptr == NULL) return code;
|
||||||
|
|
||||||
|
/* extension info */
|
||||||
|
struct getdns_libev_data {
|
||||||
|
struct ev_loop* loop;
|
||||||
|
struct ev_io* poll_handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* lib event callbacks */
|
||||||
|
static void
|
||||||
|
getdns_libev_cb(struct ev_loop *loop, struct ev_io *handle, int revents) {
|
||||||
|
struct getdns_context* context = (struct getdns_context*) handle->data;
|
||||||
|
getdns_context_process_async(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
getdns_libev_timeout_cb(struct ev_loop *loop, struct ev_timer* handle, int status) {
|
||||||
|
getdns_timeout_data_t* timeout_data = (getdns_timeout_data_t*) handle->data;
|
||||||
|
timeout_data->callback(timeout_data->userarg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* getdns extension functions */
|
||||||
|
static getdns_return_t
|
||||||
|
getdns_libev_cleanup(struct getdns_context* context, void* data) {
|
||||||
|
struct getdns_libev_data *ev_data = (struct getdns_libev_data*) data;
|
||||||
|
ev_io_stop(ev_data->loop, ev_data->poll_handle);
|
||||||
|
free(ev_data->poll_handle);
|
||||||
|
free(ev_data);
|
||||||
|
return GETDNS_RETURN_GOOD;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getdns_return_t
|
||||||
|
getdns_libev_schedule_timeout(struct getdns_context* context,
|
||||||
|
void* eventloop_data, uint16_t timeout,
|
||||||
|
getdns_timeout_data_t* timeout_data,
|
||||||
|
void** eventloop_timer) {
|
||||||
|
|
||||||
|
struct ev_timer *timer;
|
||||||
|
struct getdns_libev_data* ev_data = (struct getdns_libev_data*) eventloop_data;
|
||||||
|
ev_tstamp to = timeout;
|
||||||
|
to /= 1000;
|
||||||
|
timer = (struct ev_timer*) malloc(sizeof(struct ev_timer));
|
||||||
|
ev_timer_init(timer, getdns_libev_timeout_cb, to, 0);
|
||||||
|
timer->data = timeout_data;
|
||||||
|
ev_timer_start(ev_data->loop, timer);
|
||||||
|
|
||||||
|
*eventloop_timer = timer;
|
||||||
|
return GETDNS_RETURN_GOOD;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getdns_return_t
|
||||||
|
getdns_libev_clear_timeout(struct getdns_context* context,
|
||||||
|
void* eventloop_data, void* eventloop_timer) {
|
||||||
|
struct ev_timer* timer = (struct ev_timer*) eventloop_timer;
|
||||||
|
struct getdns_libev_data* ev_data = (struct getdns_libev_data*) eventloop_data;
|
||||||
|
ev_timer_stop(ev_data->loop, timer);
|
||||||
|
free(timer);
|
||||||
|
return GETDNS_RETURN_GOOD;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static getdns_eventloop_extension LIBEV_EXT = {
|
||||||
|
getdns_libev_cleanup,
|
||||||
|
getdns_libev_schedule_timeout,
|
||||||
|
getdns_libev_clear_timeout
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* getdns_extension_set_libev_loop
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
getdns_return_t
|
||||||
|
getdns_extension_set_libev_loop(struct getdns_context *context,
|
||||||
|
struct ev_loop *loop)
|
||||||
|
{
|
||||||
|
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||||
|
RETURN_IF_NULL(loop, GETDNS_RETURN_INVALID_PARAMETER);
|
||||||
|
/* TODO: cleanup current extension base */
|
||||||
|
getdns_return_t r = getdns_extension_detach_eventloop(context);
|
||||||
|
if (r != GETDNS_RETURN_GOOD) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
struct getdns_libev_data* ev_data = (struct getdns_libev_data*) malloc(sizeof(struct getdns_libev_data));
|
||||||
|
if (!ev_data) {
|
||||||
|
return GETDNS_RETURN_MEMORY_ERROR;
|
||||||
|
}
|
||||||
|
int fd = getdns_context_fd(context);
|
||||||
|
ev_data->poll_handle = (struct ev_io*) malloc(sizeof(struct ev_io));
|
||||||
|
ev_io_init(ev_data->poll_handle, getdns_libev_cb, fd, EV_READ);
|
||||||
|
ev_data->loop = loop;
|
||||||
|
|
||||||
|
ev_io_start(ev_data->loop, ev_data->poll_handle);
|
||||||
|
ev_data->poll_handle->data = context;
|
||||||
|
return getdns_extension_set_eventloop(context, &LIBEV_EXT, ev_data);
|
||||||
|
} /* getdns_extension_set_libev_loop */
|
|
@ -111,7 +111,7 @@ getdns_libevent_schedule_timeout(struct getdns_context* context,
|
||||||
|
|
||||||
static getdns_return_t
|
static getdns_return_t
|
||||||
getdns_libevent_clear_timeout(struct getdns_context* context,
|
getdns_libevent_clear_timeout(struct getdns_context* context,
|
||||||
void* eventloop_data, void** eventloop_timer) {
|
void* eventloop_data, void* eventloop_timer) {
|
||||||
struct event* ev = (struct event*) eventloop_timer;
|
struct event* ev = (struct event*) eventloop_timer;
|
||||||
event_del(ev);
|
event_del(ev);
|
||||||
event_free(ev);
|
event_free(ev);
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <getdns/getdns_ext_libevent.h>
|
#include <getdns/getdns_ext_libuv.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -99,7 +99,7 @@ getdns_libuv_schedule_timeout(struct getdns_context* context,
|
||||||
|
|
||||||
static getdns_return_t
|
static getdns_return_t
|
||||||
getdns_libuv_clear_timeout(struct getdns_context* context,
|
getdns_libuv_clear_timeout(struct getdns_context* context,
|
||||||
void* eventloop_data, void** eventloop_timer) {
|
void* eventloop_data, void* eventloop_timer) {
|
||||||
uv_timer_t* timer = (uv_timer_t*) eventloop_timer;
|
uv_timer_t* timer = (uv_timer_t*) eventloop_timer;
|
||||||
uv_timer_stop(timer);
|
uv_timer_stop(timer);
|
||||||
uv_close((uv_handle_t*) timer, getdns_libuv_close_cb);
|
uv_close((uv_handle_t*) timer, getdns_libuv_close_cb);
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
* \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, Versign, 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 name of the <organization> nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* 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_EXT_LIBEV_H
|
||||||
|
#define GETDNS_EXT_LIBEV_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <getdns/getdns.h>
|
||||||
|
|
||||||
|
struct ev_loop;
|
||||||
|
|
||||||
|
/* For libevent, which we are using for these examples */
|
||||||
|
getdns_return_t
|
||||||
|
getdns_extension_set_libev_loop(struct getdns_context *context,
|
||||||
|
struct ev_loop *ev_loop);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -45,8 +45,8 @@ tests_stub_sync: tests_stub_sync.o
|
||||||
check_getdns_common: check_getdns_common.o
|
check_getdns_common: check_getdns_common.o
|
||||||
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns_common.o
|
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns_common.o
|
||||||
|
|
||||||
check_getdns: check_getdns.o check_getdns_common.o
|
check_getdns: check_getdns.o check_getdns_common.o check_getdns_libev.o
|
||||||
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns.o check_getdns_common.o
|
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns.o check_getdns_common.o check_getdns_libev.o
|
||||||
|
|
||||||
tests_dnssec: tests_dnssec.o testmessages.o
|
tests_dnssec: tests_dnssec.o testmessages.o
|
||||||
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_dnssec.o testmessages.o
|
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_dnssec.o testmessages.o
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
#include <getdns/getdns_ext_libuv.h>
|
#include <getdns/getdns_ext_libuv.h>
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if HAVE_LIBEV
|
||||||
|
#include "check_getdns_libev.h"
|
||||||
|
#endif
|
||||||
#include "check_getdns_common.h"
|
#include "check_getdns_common.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -303,6 +306,7 @@ void update_callbackfn(struct getdns_context *context,
|
||||||
#define NO_LOOP 0
|
#define NO_LOOP 0
|
||||||
#define LIBEVENT_LOOP 1
|
#define LIBEVENT_LOOP 1
|
||||||
#define LIBUV_LOOP 2
|
#define LIBUV_LOOP 2
|
||||||
|
#define LIBEV_LOOP 3
|
||||||
|
|
||||||
static int get_event_loop_type() {
|
static int get_event_loop_type() {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
@ -317,6 +321,11 @@ static int get_event_loop_type() {
|
||||||
result = LIBUV_LOOP;
|
result = LIBUV_LOOP;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if HAVE_LIBEV
|
||||||
|
if (loop && strcmp("libev", loop) == 0) {
|
||||||
|
result = LIBEV_LOOP;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,6 +358,11 @@ void run_event_loop(struct getdns_context* context, void* eventloop) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if HAVE_LIBEV
|
||||||
|
else if (event_loop_type == LIBEV_LOOP) {
|
||||||
|
run_libev_event_loop(context, eventloop);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void* create_event_base(struct getdns_context* context) {
|
void* create_event_base(struct getdns_context* context) {
|
||||||
|
@ -373,5 +387,10 @@ void* create_event_base(struct getdns_context* context) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if HAVE_LIBEV
|
||||||
|
if (event_loop_type == LIBEV_LOOP) {
|
||||||
|
return create_libev_base(context);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
/**
|
||||||
|
* \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, Versign, 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 name of the <organization> nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* 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_libev.h"
|
||||||
|
|
||||||
|
#if HAVE_LIBEV
|
||||||
|
|
||||||
|
#include <getdns/getdns_ext_libev.h>
|
||||||
|
#include <ev.h>
|
||||||
|
#include <check.h>
|
||||||
|
#include "check_getdns_common.h"
|
||||||
|
|
||||||
|
void run_libev_event_loop(struct getdns_context* context, void* eventloop) {
|
||||||
|
struct ev_loop* loop = (struct ev_loop*) eventloop;
|
||||||
|
while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
|
||||||
|
ev_run(loop, EVRUN_ONCE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void* create_libev_base(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,48 @@
|
||||||
|
/**
|
||||||
|
* \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, Versign, 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 name of the <organization> nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* 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_libev_h_
|
||||||
|
#define _check_getdns_libev_h_
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#if HAVE_LIBEV
|
||||||
|
struct getdns_context* context;
|
||||||
|
void run_libev_event_loop(struct getdns_context* context, void* eventloop);
|
||||||
|
void* create_libev_base(struct getdns_context* context);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -99,13 +99,13 @@ main(int argc, char** argv)
|
||||||
return (GETDNS_RETURN_GENERIC_ERROR);
|
return (GETDNS_RETURN_GENERIC_ERROR);
|
||||||
}
|
}
|
||||||
/* Set up the getdns call */
|
/* Set up the getdns call */
|
||||||
const char *this_name = argc > 1 ? argv[1] : "www.google.com";
|
const char *this_name = argc > 1 ? argv[1] : "mx.kitchensink.net";
|
||||||
char *this_userarg = "somestring"; // Could add things here to help identify this call
|
char *this_userarg = "somestring"; // Could add things here to help identify this call
|
||||||
getdns_transaction_t this_transaction_id = 0;
|
getdns_transaction_t this_transaction_id = 0;
|
||||||
|
|
||||||
/* Make the call */
|
/* Make the call */
|
||||||
getdns_return_t dns_request_return =
|
getdns_return_t dns_request_return =
|
||||||
getdns_address(this_context, this_name,
|
getdns_general(this_context, this_name, GETDNS_RRTYPE_APL,
|
||||||
NULL, this_userarg, &this_transaction_id, this_callbackfn);
|
NULL, this_userarg, &this_transaction_id, this_callbackfn);
|
||||||
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME) {
|
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME) {
|
||||||
fprintf(stderr, "A bad domain name was used: %s. Exiting.",
|
fprintf(stderr, "A bad domain name was used: %s. Exiting.",
|
||||||
|
|
|
@ -50,8 +50,17 @@ if test $? -ne 0; then
|
||||||
fi
|
fi
|
||||||
checkoutput tests_dict
|
checkoutput tests_dict
|
||||||
checkoutput tests_list
|
checkoutput tests_list
|
||||||
checkpacket tests_stub_async
|
|
||||||
checkpacket tests_stub_sync
|
# 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
|
rm -f output output.good output2 output2.good
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -259,7 +259,7 @@ typedef getdns_return_t (*getdns_eventloop_schedule_timeout_t)(struct getdns_con
|
||||||
getdns_timeout_data_t* timeout_data,
|
getdns_timeout_data_t* timeout_data,
|
||||||
void** eventloop_timer);
|
void** eventloop_timer);
|
||||||
typedef getdns_return_t (*getdns_eventloop_clear_timeout_t)(struct getdns_context* context,
|
typedef getdns_return_t (*getdns_eventloop_clear_timeout_t)(struct getdns_context* context,
|
||||||
void* eventloop_data, void** eventloop_timer);
|
void* eventloop_data, void* eventloop_timer);
|
||||||
|
|
||||||
|
|
||||||
typedef struct getdns_eventloop_extension {
|
typedef struct getdns_eventloop_extension {
|
||||||
|
|
Loading…
Reference in New Issue