From 416ef5e2bf59bb2e45066a1d5d91ac677c0f48e5 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 10 Dec 2014 03:05:47 +0000 Subject: Initial commit --- src/libs6dns/s6dns_resolven_parse.c | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/libs6dns/s6dns_resolven_parse.c (limited to 'src/libs6dns/s6dns_resolven_parse.c') diff --git a/src/libs6dns/s6dns_resolven_parse.c b/src/libs6dns/s6dns_resolven_parse.c new file mode 100644 index 0000000..78289bc --- /dev/null +++ b/src/libs6dns/s6dns_resolven_parse.c @@ -0,0 +1,47 @@ +/* ISC license. */ + +#include +#include +#include +#include +#include +#include +#include + +int s6dns_resolven_parse_r (s6dns_resolve_t *list, unsigned int n, s6dns_ip46list_t const *servers, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) +{ + s6dns_engine_t dtl[n] ; + register unsigned int i = 0 ; + for (; i < n ; i++) list[i].status = ECONNABORTED ; + for (i = 0 ; i < n ; i++) + { + dtl[i] = s6dns_engine_zero ; + if (!s6dns_engine_init_r(dtl + i, servers, list[i].options, list[i].q.s, list[i].q.len, list[i].qtype, dbh, &list[i].deadline, stamp)) + { + list[i].status = errno ; + s6dns_engine_freen(dtl, i) ; + return 0 ; + } + list[i].status = EAGAIN ; + } + + if (s6dns_resolven_loop(dtl, n, 0, deadline, stamp) < 0) goto err ; + + for (i = 0 ; i < n ; i++) + { + if (dtl[i].status) list[i].status = dtl[i].status ; + else + { + s6dns_message_header_t h ; + register int r = s6dns_message_parse(&h, s6dns_engine_packet(dtl + i), s6dns_engine_packetlen(dtl + i), list[i].parsefunc, list[i].data) ; + if (r < 0) goto err ; + list[i].status = r ? 0 : errno ; + } + } + s6dns_engine_freen(dtl, n) ; + return 1 ; + + err: + s6dns_engine_freen(dtl, n) ; + return 0 ; +} -- cgit v1.2.3