summaryrefslogtreecommitdiff
path: root/lib/libc/asr
diff options
context:
space:
mode:
authorJeremie Courreges-Anglas <jca@cvs.openbsd.org>2017-02-27 10:44:47 +0000
committerJeremie Courreges-Anglas <jca@cvs.openbsd.org>2017-02-27 10:44:47 +0000
commite70c07db38bac3044c7e116b4d83a122829834a8 (patch)
tree4271be436d442d8b9af9d4f918779fdb0f86bdba /lib/libc/asr
parent3254daa67a21ef835d8c29b1eea71d87f3551fb7 (diff)
Put a common flags field in the query struct, rather than in some
elements of the union. This field is for internal asr flags. The flags in "struct rrset" and "struct ni" are different kinds of flags. ok eric@
Diffstat (limited to 'lib/libc/asr')
-rw-r--r--lib/libc/asr/asr.c4
-rw-r--r--lib/libc/asr/asr_private.h6
-rw-r--r--lib/libc/asr/getaddrinfo_async.c14
-rw-r--r--lib/libc/asr/res_search_async.c10
-rw-r--r--lib/libc/asr/res_send_async.c6
5 files changed, 19 insertions, 21 deletions
diff --git a/lib/libc/asr/asr.c b/lib/libc/asr/asr.c
index b678ebccebf..d5601e59c59 100644
--- a/lib/libc/asr/asr.c
+++ b/lib/libc/asr/asr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr.c,v 1.56 2017/02/23 17:04:02 eric Exp $ */
+/* $OpenBSD: asr.c,v 1.57 2017/02/27 10:44:46 jca Exp $ */
/*
* Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org>
*
@@ -244,7 +244,7 @@ _asr_async_free(struct asr_query *as)
case ASR_SEND:
if (as->as_fd != -1)
close(as->as_fd);
- if (as->as.dns.obuf && !(as->as.dns.flags & ASYNC_EXTOBUF))
+ if (as->as.dns.obuf && !(as->as_flags & ASYNC_EXTOBUF))
free(as->as.dns.obuf);
if (as->as.dns.ibuf)
free(as->as.dns.ibuf);
diff --git a/lib/libc/asr/asr_private.h b/lib/libc/asr/asr_private.h
index 1bd49300d32..6b4198933ec 100644
--- a/lib/libc/asr/asr_private.h
+++ b/lib/libc/asr/asr_private.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr_private.h,v 1.43 2017/02/23 17:04:02 eric Exp $ */
+/* $OpenBSD: asr_private.h,v 1.44 2017/02/27 10:44:46 jca Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -165,6 +165,7 @@ struct asr_query {
int (*as_run)(struct asr_query *, struct asr_result *);
struct asr_ctx *as_ctx;
int as_type;
+ int as_flags;
int as_state;
/* cond */
@@ -183,7 +184,6 @@ struct asr_query {
union {
struct {
- int flags;
uint16_t reqid;
int class;
int type;
@@ -206,7 +206,6 @@ struct asr_query {
} dns;
struct {
- int flags;
int class;
int type;
char *name;
@@ -249,7 +248,6 @@ struct asr_query {
char *fqdn;
struct addrinfo *aifirst;
struct addrinfo *ailast;
- int flags;
} ai;
struct {
diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c
index b2bc71d4b5f..eeaa19b4f6e 100644
--- a/lib/libc/asr/getaddrinfo_async.c
+++ b/lib/libc/asr/getaddrinfo_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getaddrinfo_async.c,v 1.53 2017/02/23 17:04:02 eric Exp $ */
+/* $OpenBSD: getaddrinfo_async.c,v 1.54 2017/02/27 10:44:46 jca Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -356,11 +356,11 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar)
AS_FAMILY(as) : as->as.ai.hints.ai_family;
if (family == AF_INET &&
- as->as.ai.flags & ASYNC_NO_INET) {
+ as->as_flags & ASYNC_NO_INET) {
async_set_state(as, ASR_STATE_NEXT_FAMILY);
break;
} else if (family == AF_INET6 &&
- as->as.ai.flags & ASYNC_NO_INET6) {
+ as->as_flags & ASYNC_NO_INET6) {
async_set_state(as, ASR_STATE_NEXT_FAMILY);
break;
}
@@ -431,7 +431,7 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar)
case ASR_STATE_NOT_FOUND:
/* No result found. Maybe we can try again. */
- if (as->as.ai.flags & ASYNC_AGAIN)
+ if (as->as_flags & ASYNC_AGAIN)
ar->ar_gai_errno = EAI_AGAIN;
else
ar->ar_gai_errno = EAI_NODATA;
@@ -684,7 +684,7 @@ addrconfig_setup(struct asr_query *as)
if (getifaddrs(&ifa0) == -1)
return (-1);
- as->as.ai.flags |= ASYNC_NO_INET | ASYNC_NO_INET6;
+ as->as_flags |= ASYNC_NO_INET | ASYNC_NO_INET6;
for (ifa = ifa0; ifa != NULL; ifa = ifa->ifa_next) {
if (ifa->ifa_addr == NULL)
@@ -697,7 +697,7 @@ addrconfig_setup(struct asr_query *as)
if (sinp->sin_addr.s_addr == htonl(INADDR_LOOPBACK))
continue;
- as->as.ai.flags &= ~ASYNC_NO_INET;
+ as->as_flags &= ~ASYNC_NO_INET;
break;
case PF_INET6:
sin6p = (struct sockaddr_in6 *)ifa->ifa_addr;
@@ -708,7 +708,7 @@ addrconfig_setup(struct asr_query *as)
if (IN6_IS_ADDR_LINKLOCAL(&sin6p->sin6_addr))
continue;
- as->as.ai.flags &= ~ASYNC_NO_INET6;
+ as->as_flags &= ~ASYNC_NO_INET6;
break;
}
}
diff --git a/lib/libc/asr/res_search_async.c b/lib/libc/asr/res_search_async.c
index 26be7d91622..a24bd3caae4 100644
--- a/lib/libc/asr/res_search_async.c
+++ b/lib/libc/asr/res_search_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_search_async.c,v 1.20 2017/02/23 17:04:02 eric Exp $ */
+/* $OpenBSD: res_search_async.c,v 1.21 2017/02/27 10:44:46 jca Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -169,9 +169,9 @@ res_search_async_run(struct asr_query *as, struct asr_result *ar)
if (as->as_dom_flags & ASYNC_DOM_DOMAIN) {
if (ar->ar_h_errno == NO_DATA)
- as->as.search.flags |= ASYNC_NODATA;
+ as->as_flags |= ASYNC_NODATA;
else if (ar->ar_h_errno == TRY_AGAIN)
- as->as.search.flags |= ASYNC_AGAIN;
+ as->as_flags |= ASYNC_AGAIN;
}
async_set_state(as, ASR_STATE_NEXT_DOMAIN);
@@ -181,9 +181,9 @@ res_search_async_run(struct asr_query *as, struct asr_result *ar)
if (as->as.search.saved_h_errno != HERRNO_UNSET)
ar->ar_h_errno = as->as.search.saved_h_errno;
- else if (as->as.search.flags & ASYNC_NODATA)
+ else if (as->as_flags & ASYNC_NODATA)
ar->ar_h_errno = NO_DATA;
- else if (as->as.search.flags & ASYNC_AGAIN)
+ else if (as->as_flags & ASYNC_AGAIN)
ar->ar_h_errno = TRY_AGAIN;
/*
* Else, we got the ar_h_errno value set by res_query_async()
diff --git a/lib/libc/asr/res_send_async.c b/lib/libc/asr/res_send_async.c
index 4be5731c8e0..931c8a495d3 100644
--- a/lib/libc/asr/res_send_async.c
+++ b/lib/libc/asr/res_send_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_send_async.c,v 1.32 2017/02/18 22:25:13 eric Exp $ */
+/* $OpenBSD: res_send_async.c,v 1.33 2017/02/27 10:44:46 jca Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -67,7 +67,7 @@ res_send_async(const unsigned char *buf, int buflen, void *asr)
}
as->as_run = res_send_async_run;
- as->as.dns.flags |= ASYNC_EXTOBUF;
+ as->as_flags |= ASYNC_EXTOBUF;
as->as.dns.obuf = (unsigned char *)buf;
as->as.dns.obuflen = buflen;
as->as.dns.obufsize = buflen;
@@ -346,7 +346,7 @@ setup_query(struct asr_query *as, const char *name, const char *dom,
char fqdn[MAXDNAME];
char dname[MAXDNAME];
- if (as->as.dns.flags & ASYNC_EXTOBUF) {
+ if (as->as_flags & ASYNC_EXTOBUF) {
errno = EINVAL;
DPRINT("attempting to write in user packet");
return (-1);