Commit e6783a7f authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(isc_dns_resolve_adns_cb): New function.

(isc_resolve_remote): Try to use adns to look up the address.
	Fall back to the old method if adns returns ENOSYS, which
	indicates that it doesn't support the addess family.
parent 0d1957df
......@@ -53,8 +53,11 @@
# include <stdarg.h>
#endif
#include <fcntl.h>
#include <assert.h>
#include "oop.h"
#include "adns.h"
#include "oop-adns.h"
#include "s-string.h"
......@@ -63,7 +66,7 @@
#include "isc_addr.h"
#include "unused.h"
static oop_adns_call isc_dns_resolve_adns_cb;
#if defined(__GNUC__) && defined(__sparc__)
/*
......@@ -221,18 +224,68 @@ isc_dns_resolve_cb(oop_source *UNUSED(src),
}
}
void
void *
isc_dns_resolve_adns_cb(oop_adapter_adns *UNUSED(adapter),
adns_answer *answer,
void *user)
{
struct isc_scb_internal *session = user;
isc_resolve_done_cb *cb;
void *res = NULL;
cb = session->resolve_callback;
session->resolve_callback = NULL;
if (answer->status == adns_s_ok && answer->nrrs > 0)
{
fprintf(stderr, "ADNS RULEZ OK!\n");
s_crea_str(&session->pub.remote, answer->rrs.str[0]);
res = cb(&session->pub, isc_resolve_ok, 0);
}
else
{
s_crea_str(&session->pub.remote,
isc_getipnum(session->pub.raddr, NULL, 0));
res = cb(&session->pub, isc_resolve_adns_error, answer->status);
}
free(answer);
return res;
}
int
isc_resolve_remote(struct isc_scb *scb,
isc_resolve_done_cb *callback)
{
int errcode;
struct isc_scb_internal *session = (struct isc_scb_internal*)scb;
oop_source *source = session->pub.master->event_source;
session->resolve_callback = callback;
session->adns_query = oop_adns_submit_reverse(
scb->master->adns, &errcode,
&scb->raddr->saddr.sa,
adns_r_ptr,
0,
isc_dns_resolve_adns_cb,
session);
source->on_time(source, OOP_TIME_NOW, isc_dns_resolve_cb, session);
}
if (session->adns_query == NULL)
{
/* adns does not yet support IPv6 addresses, so if this is an
IPv6 socket we have to use the old blocking method of host
name lookup. */
if (errcode == ENOSYS)
source->on_time(source, OOP_TIME_NOW, isc_dns_resolve_cb, session);
else
{
assert(errcode);
return errcode;
}
}
session->resolve_callback = callback;
return 0;
}
int isc_getportnum(union isc_address *ia)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment