From 91e808f1db0b76f3625f516ec73a95b4e32decb2 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 17 May 2020 18:07:58 +0000 Subject: Add s6-dnsip, prepare for 2.3.3.0, fix resolvenoq_aaaaa TODO: resolveq_aaaaa returns the best (1 answer) whereas we want both ip6 and ip4 when available. It works with noq, it should work with q too. --- src/libs6dns/s6dns_resolvenoq_aaaaa.c | 12 +++++++----- src/libs6dns/s6dns_resolveq_aaaaa.c | 12 ++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'src/libs6dns') diff --git a/src/libs6dns/s6dns_resolvenoq_aaaaa.c b/src/libs6dns/s6dns_resolvenoq_aaaaa.c index 734d048..7012594 100644 --- a/src/libs6dns/s6dns_resolvenoq_aaaaa.c +++ b/src/libs6dns/s6dns_resolvenoq_aaaaa.c @@ -26,7 +26,7 @@ int s6dns_resolvenoq_aaaaa_r (genalloc *ips, char const *name, size_t len, s6dns blob[1].data = &sa[1] ; if (!s6dns_resolven_parse_r(blob, 2, servers, dbh, deadline, stamp)) return -1 ; if (blob[0].status && blob[1].status) return (errno = blob[1].status, 0) ; - if (!genalloc_readyplus(ip46_t, ips, (sa[0].len >> 4) + (sa[1].len >> 2))) + if (!genalloc_readyplus(ip46full_t, ips, (sa[0].len >> 4) + (sa[1].len >> 2))) { stralloc_free(&sa[0]) ; stralloc_free(&sa[1]) ; @@ -34,13 +34,15 @@ int s6dns_resolvenoq_aaaaa_r (genalloc *ips, char const *name, size_t len, s6dns } { int e = (!!sa[0].len << 1) | !!sa[1].len ; - size_t n = genalloc_len(ip46_t, ips) ; + size_t n = genalloc_len(ip46full_t, ips) ; size_t i = 0 ; for (; i < (sa[0].len >> 4) ; i++) - ip46_from_ip6(genalloc_s(ip46_t, ips) + n++, sa[0].s + (i << 4)) ; + ip46full_from_ip6(genalloc_s(ip46full_t, ips) + n + i, sa[0].s + (i << 4)) ; + n += i ; for (i = 0 ; i < (sa[1].len >> 2) ; i++) - ip46_from_ip4(genalloc_s(ip46_t, ips) + n++, sa[1].s + (i << 2)) ; - genalloc_setlen(ip46_t, ips, n) ; + ip46full_from_ip4(genalloc_s(ip46full_t, ips) + n + i, sa[1].s + (i << 2)) ; + n += i ; + genalloc_setlen(ip46full_t, ips, n) ; stralloc_free(&sa[0]) ; stralloc_free(&sa[1]) ; return e ; diff --git a/src/libs6dns/s6dns_resolveq_aaaaa.c b/src/libs6dns/s6dns_resolveq_aaaaa.c index 5a0a358..f990a7c 100644 --- a/src/libs6dns/s6dns_resolveq_aaaaa.c +++ b/src/libs6dns/s6dns_resolveq_aaaaa.c @@ -1,16 +1,20 @@ /* ISC license. */ #include + #include #include #include #include + #include #include #include #include #include +#define d_ip46full_from_ip(i, s, h) ((h) ? ip46full_from_ip6(i, s) : ip46full_from_ip4(i, s)) + int s6dns_resolveq_aaaaa_r (genalloc *ips, char const *name, size_t len, s6dns_rci_t const *rci, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) { s6dns_engine_t dtl[rci->rulesnum << 1] ; @@ -75,11 +79,11 @@ int s6dns_resolveq_aaaaa_r (genalloc *ips, char const *name, size_t len, s6dns_r { size_t len = data.len >> ((best & 1) ? 2 : 4) ; size_t i = 0 ; - size_t base = genalloc_len(ip46_t, ips) ; - if (!genalloc_readyplus(ip46_t, ips, len)) return -1 ; + size_t base = genalloc_len(ip46full_t, ips) ; + if (!genalloc_readyplus(ip46full_t, ips, len)) return -1 ; for (; i < len ; i++) - ip46_from_ip(genalloc_s(ip46_t, ips) + base + i, data.s + (i << ((best & 1) ? 2 : 4)), !(best & 1)) ; - genalloc_setlen(ip46_t, ips, base + len) ; + d_ip46full_from_ip(genalloc_s(ip46full_t, ips) + base + i, data.s + (i << ((best & 1) ? 2 : 4)), !(best & 1)) ; + genalloc_setlen(ip46full_t, ips, base + len) ; } stralloc_free(&data) ; return 1 ; -- cgit v1.2.3