summaryrefslogtreecommitdiff
path: root/src/libs6dns/s6dns_resolveq_aaaaa.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-05-17 18:07:58 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-05-17 18:07:58 +0000
commit91e808f1db0b76f3625f516ec73a95b4e32decb2 (patch)
treecacbb0f21daa96bffa4a74c8395c82983b185be5 /src/libs6dns/s6dns_resolveq_aaaaa.c
parent8e3663ba249b572af9332f2762f29ba514620a27 (diff)
downloads6-dns-91e808f1db0b76f3625f516ec73a95b4e32decb2.tar.xz
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.
Diffstat (limited to 'src/libs6dns/s6dns_resolveq_aaaaa.c')
-rw-r--r--src/libs6dns/s6dns_resolveq_aaaaa.c12
1 files changed, 8 insertions, 4 deletions
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 <errno.h>
+
#include <skalibs/error.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
#include <skalibs/ip46.h>
+
#include <s6-dns/s6dns-constants.h>
#include <s6-dns/s6dns-domain.h>
#include <s6-dns/s6dns-message.h>
#include <s6-dns/s6dns-engine.h>
#include <s6-dns/s6dns-resolve.h>
+#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 ;