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

(isc_dns_resolve_cb): New function.

(isc_resolve_remote): New function.
(isc_gethostname): Removed.
parent 4c86dfce
......@@ -61,6 +61,7 @@
#include "isc.h"
#include "intern.h"
#include "isc_addr.h"
#include "unused.h"
......@@ -186,23 +187,17 @@ char *isc_getipnum(union isc_address *ia, char *buf, int len)
}
char *isc_gethostname(union isc_address *ia, char *buf, int len)
void *
isc_dns_resolve_cb(oop_source *UNUSED(src),
struct timeval UNUSED(tv),
void *user)
{
static char hostname[256];
struct isc_scb_internal *session = user;
struct hostent *hp;
if (ia == NULL)
{
return NULL;
}
isc_resolve_done_cb *cb;
union isc_address *ia = session->pub.raddr;
if (!buf)
{
buf = hostname;
len = sizeof(hostname)-1;
}
hp = CHOOSE_IP4OR6(ia->saddr,
gethostbyaddr((char *) &ia->saddr.sa_in.sin_addr,
sizeof(ia->saddr.sa_in.sin_addr),
......@@ -211,13 +206,31 @@ char *isc_gethostname(union isc_address *ia, char *buf, int len)
sizeof(ia->saddr.sa_in6.sin6_addr),
ia->saddr.sa.sa_family));
if (!hp)
return NULL;
strncpy(buf, hp->h_name, len);
buf[len] = '\0';
return buf;
cb = session->resolve_callback;
session->resolve_callback = NULL;
if (hp)
{
s_crea_str(&session->pub.remote, hp->h_name);
return cb(&session->pub, isc_resolve_ok, 0);
}
else
{
s_crea_str(&session->pub.remote, isc_getipnum(ia, NULL, 0));
return cb(&session->pub, isc_resolve_h_errno, h_errno);
}
}
void
isc_resolve_remote(struct isc_scb *scb,
isc_resolve_done_cb *callback)
{
struct isc_scb_internal *session = (struct isc_scb_internal*)scb;
oop_source *source = session->pub.master->event_source;
session->resolve_callback = callback;
source->on_time(source, OOP_TIME_NOW, isc_dns_resolve_cb, session);
}
......
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