This commit is contained in:
whottgen 2004-10-14 14:06:14 +00:00
parent 7e407c1fb6
commit e64af682dc
2 changed files with 130 additions and 83 deletions

153
smmapdfw/configure vendored
View File

@ -19138,82 +19138,6 @@ fi
fi fi
if test "x$WITHOUT_DJBDNS" = "x0"; then
echo "$as_me:$LINENO: checking for dns_transmit_start in -ldjbdns" >&5
echo $ECHO_N "checking for dns_transmit_start in -ldjbdns... $ECHO_C" >&6
if test "${ac_cv_lib_djbdns_dns_transmit_start+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldjbdns $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char dns_transmit_start ();
int
main ()
{
dns_transmit_start ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_djbdns_dns_transmit_start=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_djbdns_dns_transmit_start=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_djbdns_dns_transmit_start" >&5
echo "${ECHO_T}$ac_cv_lib_djbdns_dns_transmit_start" >&6
if test $ac_cv_lib_djbdns_dns_transmit_start = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBDJBDNS 1
_ACEOF
LIBS="-ldjbdns $LIBS"
fi
fi
echo "$as_me:$LINENO: checking for inet_aton in -lresolv" >&5 echo "$as_me:$LINENO: checking for inet_aton in -lresolv" >&5
echo $ECHO_N "checking for inet_aton in -lresolv... $ECHO_C" >&6 echo $ECHO_N "checking for inet_aton in -lresolv... $ECHO_C" >&6
@ -19361,6 +19285,83 @@ _ACEOF
fi fi
if test "x$WITHOUT_DJBDNS" = "x0"; then
echo "$as_me:$LINENO: checking for dns_transmit_start in -ldjbdns" >&5
echo $ECHO_N "checking for dns_transmit_start in -ldjbdns... $ECHO_C" >&6
if test "${ac_cv_lib_djbdns_dns_transmit_start+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldjbdns $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char dns_transmit_start ();
int
main ()
{
dns_transmit_start ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_djbdns_dns_transmit_start=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_djbdns_dns_transmit_start=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_djbdns_dns_transmit_start" >&5
echo "${ECHO_T}$ac_cv_lib_djbdns_dns_transmit_start" >&6
if test $ac_cv_lib_djbdns_dns_transmit_start = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBDJBDNS 1
_ACEOF
LIBS="-ldjbdns $LIBS"
fi
fi
# Checks for header files. # Checks for header files.
echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo "$as_me:$LINENO: checking for ANSI C header files" >&5

View File

@ -19,6 +19,7 @@
*/ */
#include "config.h"
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h> #include <netinet/in.h>
@ -33,6 +34,7 @@
#if HAVE_LIBDJBDNS #if HAVE_LIBDJBDNS
#include <dns.h> #include <dns.h>
#include <pthread.h>
#else #else
#include <resolv.h> #include <resolv.h>
#endif #endif
@ -58,6 +60,9 @@ typedef union answer_u answer_t;
#define get16(b, o) ((b[o] << 8) + b[o+1]) #define get16(b, o) ((b[o] << 8) + b[o+1])
#if HAVE_LIBDJBDNS
pthread_mutex_t dns_transmit_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
static int get_domain_name(answer_t *answer, int offset, char **name) { static int get_domain_name(answer_t *answer, int offset, char **name) {
int start, len, i, offset2; int start, len, i, offset2;
@ -205,7 +210,7 @@ static void** get_rrs(char *domain, int qtype) {
#if HAVE_LIBDJBDNS #if HAVE_LIBDJBDNS
{ {
char s[64]; char s[64];
int flagrecursive = 0; int flagrecursive = 1;
char *q = NULL; char *q = NULL;
char t[2]; char t[2];
char localip[4] = "\0\0\0\0"; char localip[4] = "\0\0\0\0";
@ -213,8 +218,9 @@ static void** get_rrs(char *domain, int qtype) {
struct taia deadline; struct taia deadline;
struct taia stamp; struct taia stamp;
t[0] = '\0'; t[0] = '\0';
t[1] = type; t[1] = qtype;
if (dns_resolvconfip(s) == -1) { if (dns_resolvconfip(s) == -1) {
syslog(LOG_ERR, "failure in dns_resolvconfip: %d, %s\n", syslog(LOG_ERR, "failure in dns_resolvconfip: %d, %s\n",
@ -223,8 +229,12 @@ static void** get_rrs(char *domain, int qtype) {
} }
dns_domain_fromdot(&q, domain, strlen(domain)); dns_domain_fromdot(&q, domain, strlen(domain));
if (dns_transmit_start(&dt, s, flagrecursive, q, t, localip) == -1) { pthread_mutex_lock(&dns_transmit_mutex);
res = dns_transmit_start(&dt, s, flagrecursive, q, t, localip);
pthread_mutex_unlock(&dns_transmit_mutex);
if (res == -1) {
syslog(LOG_ERR, "failure in dns_transmit_start: %d, %s\n", syslog(LOG_ERR, "failure in dns_transmit_start: %d, %s\n",
errno, strerror(errno)); errno, strerror(errno));
return NULL; return NULL;
@ -232,18 +242,28 @@ static void** get_rrs(char *domain, int qtype) {
for (;;) { for (;;) {
int r; int r;
taia_now(&stamp); taia_now(&stamp);
taia_uint(&deadline,120); taia_uint(&deadline,120);
taia_add(&deadline, &deadline, &stamp); taia_add(&deadline, &deadline, &stamp);
pthread_mutex_lock(&dns_transmit_mutex);
dns_transmit_io(&dt, x, &deadline); dns_transmit_io(&dt, x, &deadline);
pthread_mutex_unlock(&dns_transmit_mutex);
iopause(x, 1, &deadline, &stamp); iopause(x, 1, &deadline, &stamp);
pthread_mutex_lock(&dns_transmit_mutex);
r = dns_transmit_get(&dt, x, &stamp); r = dns_transmit_get(&dt, x, &stamp);
pthread_mutex_unlock(&dns_transmit_mutex);
if (-1 == r) { if (-1 == r) {
syslog(LOG_ERR, "failure in dns_transmit_get: %d, %s\n", syslog(LOG_ERR, "failure in dns_transmit_get: %d, %s\n",
errno, strerror(errno)); errno, strerror(errno));
dns_transmit_free(&dt);
pthread_mutex_lock(&dns_transmit_mutex);
dns_transmit_free(&dt);
pthread_mutex_unlock(&dns_transmit_mutex);
return NULL; return NULL;
} }
@ -256,6 +276,8 @@ static void** get_rrs(char *domain, int qtype) {
#else #else
{ {
answer_t lanswer; answer_t lanswer;
syslog(LOG_DEBUG, "get_rrs: before res_search");
res = res_search(domain, C_IN, qtype, (u_char*) &lanswer, sizeof(answer_t)); res = res_search(domain, C_IN, qtype, (u_char*) &lanswer, sizeof(answer_t));
if (-1 == res) { if (-1 == res) {
syslog(LOG_ERR, "get_rrs: error in res_search: h_errno=%d, errno=%d, (%s)", syslog(LOG_ERR, "get_rrs: error in res_search: h_errno=%d, errno=%d, (%s)",
@ -268,6 +290,23 @@ static void** get_rrs(char *domain, int qtype) {
cnt = sizeof(HEADER); cnt = sizeof(HEADER);
#if 0
syslog(LOG_DEBUG, "id: %d\n", answer->hdr.id);
syslog(LOG_DEBUG, "qr: %d\n", answer->hdr.qr);
syslog(LOG_DEBUG, "oc: %d\n", answer->hdr.opcode);
syslog(LOG_DEBUG, "aa: %d\n", answer->hdr.aa);
syslog(LOG_DEBUG, "tc: %d\n", answer->hdr.tc);
syslog(LOG_DEBUG, "rd: %d\n", answer->hdr.rd);
syslog(LOG_DEBUG, "ra: %d\n", answer->hdr.ra);
syslog(LOG_DEBUG, "ad: %d\n", answer->hdr.ad);
syslog(LOG_DEBUG, "cd: %d\n", answer->hdr.cd);
syslog(LOG_DEBUG, "rc: %d\n", answer->hdr.rcode);
syslog(LOG_DEBUG, "qdcount: %d\n", ntohs(answer->hdr.qdcount));
syslog(LOG_DEBUG, "ancount: %d\n", ntohs(answer->hdr.ancount));
syslog(LOG_DEBUG, "nscount: %d\n", ntohs(answer->hdr.nscount));
syslog(LOG_DEBUG, "arcount: %d\n", ntohs(answer->hdr.arcount));
#endif
/* query section */ /* query section */
for (y = 0; y < ntohs(answer->hdr.qdcount); y++) { for (y = 0; y < ntohs(answer->hdr.qdcount); y++) {
cnt = get_domain_name(answer, cnt, NULL); cnt = get_domain_name(answer, cnt, NULL);
@ -300,7 +339,9 @@ static void** get_rrs(char *domain, int qtype) {
*((void**)rdata2) = NULL; *((void**)rdata2) = NULL;
#if HAVE_LIBDJBDNS #if HAVE_LIBDJBDNS
pthread_mutex_lock(&dns_transmit_mutex);
dns_transmit_free(&dt); dns_transmit_free(&dt);
pthread_mutex_unlock(&dns_transmit_mutex);
#endif #endif
return rdata; return rdata;
@ -399,6 +440,9 @@ int main(int argc, char **argv) {
domain = argv[1]; domain = argv[1];
} }
openlog("htdns-test", LOG_PID, LOG_LOCAL2);
printf("before get_mx_rrs: %s\n", domain); printf("before get_mx_rrs: %s\n", domain);
mx_rdata = get_mx_rrs(domain); mx_rdata = get_mx_rrs(domain);
@ -440,6 +484,8 @@ int main(int argc, char **argv) {
/* free_rrs((void**)a_rdata); */ /* free_rrs((void**)a_rdata); */
closelog();
} }
#endif /* _TEST_MODE_ */ #endif /* _TEST_MODE_ */