X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=blobdiff_plain;f=resolver.c;h=033ddc113aa37466015b8124016ba00d062e81fa;hp=b7c56e3bdc4cd6ea87a16eae3636bde459e8cd35;hb=0e212483f7cedbbbea7f5dce9323fd0205620927;hpb=389070fed67552c613ce5afd3cdb436f8f8c538f diff --git a/resolver.c b/resolver.c index b7c56e3..033ddc1 100644 --- a/resolver.c +++ b/resolver.c @@ -6,6 +6,8 @@ #error secnet requires ADNS version 1.0 or above #endif #include +#include +#include struct adns { @@ -28,6 +30,20 @@ static bool_t resolve_request(void *sst, cstring_t name, struct adns *st=sst; struct query *q; int rv; + const int maxlitlen=50; + + ssize_t l=strlen(name); + if (name[0]=='[' && l2 && name[l-1]==']') { + char trimmed[maxlitlen+1]; + memcpy(trimmed,name+1,l-2); + trimmed[l-2]=0; + struct in_addr ia; + if (inet_aton(trimmed,&ia)) + cb(cst,&ia); + else + cb(cst,0); + return True; + } q=safe_malloc(sizeof *q,"resolve_request"); q->cst=cst; @@ -39,15 +55,13 @@ static bool_t resolve_request(void *sst, cstring_t name, } static int resolver_beforepoll(void *sst, struct pollfd *fds, int *nfds_io, - int *timeout_io, const struct timeval *tv_now, - uint64_t *now) + int *timeout_io) { struct adns *st=sst; return adns_beforepoll(st->ast, fds, nfds_io, timeout_io, tv_now); } -static void resolver_afterpoll(void *sst, struct pollfd *fds, int nfds, - const struct timeval *tv_now, uint64_t *now) +static void resolver_afterpoll(void *sst, struct pollfd *fds, int nfds) { struct adns *st=sst; adns_query aq;