aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contrib/lib/libc/asr/asr.c38
-rw-r--r--contrib/lib/libc/asr/asr.h105
-rw-r--r--contrib/lib/libc/asr/asr_debug.c27
-rw-r--r--contrib/lib/libc/asr/asr_private.h64
-rw-r--r--contrib/lib/libc/asr/asr_utils.c54
-rw-r--r--contrib/lib/libc/asr/getaddrinfo.c8
-rw-r--r--contrib/lib/libc/asr/getaddrinfo_async.c57
-rw-r--r--contrib/lib/libc/asr/gethostnamadr.c18
-rw-r--r--contrib/lib/libc/asr/gethostnamadr_async.c44
-rw-r--r--contrib/lib/libc/asr/getnameinfo.c10
-rw-r--r--contrib/lib/libc/asr/getnameinfo_async.c24
-rw-r--r--contrib/lib/libc/asr/getnetnamadr.c14
-rw-r--r--contrib/lib/libc/asr/getnetnamadr_async.c32
-rw-r--r--contrib/lib/libc/asr/getrrsetbyname.c10
-rw-r--r--contrib/lib/libc/asr/getrrsetbyname_async.c22
-rw-r--r--contrib/lib/libc/asr/res_init.c2
-rw-r--r--contrib/lib/libc/asr/res_mkquery.c12
-rw-r--r--contrib/lib/libc/asr/res_query.c14
-rw-r--r--contrib/lib/libc/asr/res_search_async.c26
-rw-r--r--contrib/lib/libc/asr/res_send.c10
-rw-r--r--contrib/lib/libc/asr/res_send_async.c97
21 files changed, 342 insertions, 346 deletions
diff --git a/contrib/lib/libc/asr/asr.c b/contrib/lib/libc/asr/asr.c
index 772338b0..13b6097e 100644
--- a/contrib/lib/libc/asr/asr.c
+++ b/contrib/lib/libc/asr/asr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr.c,v 1.31 2013/07/12 14:36:21 eric Exp $ */
+/* $OpenBSD: asr.c,v 1.32 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org>
*
@@ -92,7 +92,7 @@ static struct asr *_asr = NULL;
#define issetugid() ((getuid() != geteuid()))
/* Allocate and configure an async "resolver". */
-struct asr *
+void *
asr_resolver(const char *conf)
{
static int init = 0;
@@ -162,8 +162,9 @@ asr_resolver(const char *conf)
* Drop the reference to the current context.
*/
void
-asr_resolver_done(struct asr *asr)
+asr_resolver_done(void *arg)
{
+ struct asr *asr = arg;
struct asr **priv;
if (asr == NULL) {
@@ -183,26 +184,26 @@ asr_resolver_done(struct asr *asr)
* Cancel an async query.
*/
void
-asr_async_abort(struct async *as)
+asr_abort(struct asr_query *as)
{
asr_async_free(as);
}
/*
* Resume the "as" async query resolution. Return one of ASYNC_COND,
- * ASYNC_YIELD or ASYNC_DONE and put query-specific return values in
- * the user-allocated memory at "ar".
+ * or ASYNC_DONE and put query-specific return values in the user-allocated
+ * memory at "ar".
*/
int
-asr_async_run(struct async *as, struct async_res *ar)
+asr_run(struct asr_query *as, struct asr_result *ar)
{
int r, saved_errno = errno;
- DPRINT("asr: async_run(%p, %p) %s ctx=[%p]\n", as, ar,
+ DPRINT("asr: asr_run(%p, %p) %s ctx=[%p]\n", as, ar,
asr_querystr(as->as_type), as->as_ctx);
r = as->as_run(as, ar);
- DPRINT("asr: async_run(%p, %p) -> %s", as, ar, asr_transitionstr(r));
+ DPRINT("asr: asr_run(%p, %p) -> %s", as, ar, asr_transitionstr(r));
#ifdef DEBUG
if (r == ASYNC_COND)
#endif
@@ -220,20 +221,20 @@ asr_async_run(struct async *as, struct async_res *ar)
* Same as above, but run in a loop that handles the fd conditions result.
*/
int
-asr_async_run_sync(struct async *as, struct async_res *ar)
+asr_run_sync(struct asr_query *as, struct asr_result *ar)
{
struct pollfd fds[1];
int r, saved_errno = errno;
- while ((r = asr_async_run(as, ar)) == ASYNC_COND) {
+ while ((r = asr_run(as, ar)) == ASYNC_COND) {
fds[0].fd = ar->ar_fd;
- fds[0].events = (ar->ar_cond == ASYNC_READ) ? POLLIN : POLLOUT;
+ fds[0].events = (ar->ar_cond == ASR_WANT_READ) ? POLLIN:POLLOUT;
again:
r = poll(fds, 1, ar->ar_timeout);
if (r == -1 && errno == EINTR)
goto again;
/*
- * Otherwise, just ignore the error and let asr_async_run()
+ * Otherwise, just ignore the error and let asr_run()
* catch the failure.
*/
}
@@ -248,10 +249,10 @@ asr_async_run_sync(struct async *as, struct async_res *ar)
* Take a reference on it so it does not gets deleted while the async query
* is running.
*/
-struct async *
+struct asr_query *
asr_async_new(struct asr_ctx *ac, int type)
{
- struct async *as;
+ struct asr_query *as;
DPRINT("asr: asr_async_new(ctx=%p) type=%i refcount=%i\n", ac, type,
ac ? ac->ac_refcount : 0);
@@ -271,7 +272,7 @@ asr_async_new(struct asr_ctx *ac, int type)
* Free an async query and unref the associated context.
*/
void
-asr_async_free(struct async *as)
+asr_async_free(struct asr_query *as)
{
DPRINT("asr: asr_async_free(%p)\n", as);
switch (as->as_type) {
@@ -345,8 +346,9 @@ asr_async_free(struct async *as)
* using this context.
*/
struct asr_ctx *
-asr_use_resolver(struct asr *asr)
+asr_use_resolver(void *arg)
{
+ struct asr *asr = arg;
struct asr **priv;
if (asr == NULL) {
@@ -897,7 +899,7 @@ asr_parse_namedb_line(FILE *file, char **tokens, int ntoken)
* Return 0 on success, or -1 if no more DBs is available.
*/
int
-asr_iter_db(struct async *as)
+asr_iter_db(struct asr_query *as)
{
if (as->as_db_idx >= as->as_ctx->ac_dbcount) {
DPRINT("asr_iter_db: done\n");
diff --git a/contrib/lib/libc/asr/asr.h b/contrib/lib/libc/asr/asr.h
index 80204e72..9a1d7922 100644
--- a/contrib/lib/libc/asr/asr.h
+++ b/contrib/lib/libc/asr/asr.h
@@ -1,6 +1,6 @@
-/* $OpenBSD: asr.h,v 1.7 2013/07/12 14:36:21 eric Exp $ */
+/* $OpenBSD: asr.h,v 1.8 2014/03/25 19:48:11 eric Exp $ */
/*
- * Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
+ * Copyright (c) 2012-2014 Eric Faurot <eric@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -18,84 +18,75 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
-#include <netinet/in.h>
/*
- * This part is the generic API for the async mechanism. It could be useful
- * beyond the resolver.
+ * Expected fd conditions
*/
-
-/* Return values for async_run() */
-#define ASYNC_COND 0 /* wait for fd condition */
-#define ASYNC_YIELD 1 /* partial result */
-#define ASYNC_DONE 2 /* done */
-
-/* Expected fd conditions */
-#define ASYNC_READ 1
-#define ASYNC_WRITE 2
-
-/* This opaque structure holds an async query state. */
-struct async;
+#define ASR_WANT_READ 1
+#define ASR_WANT_WRITE 2
/*
- * This is the structure through which async_run() returns async
- * results to the caller.
+ * Structure through which asynchronous query results are returned when
+ * calling asr_run().
*/
-struct async_res {
- int ar_cond;
- int ar_fd;
- int ar_timeout;
+struct asr_result {
+ /* Fields set if the query is not done yet (asr_run returns 0) */
+ int ar_cond; /* ASR_WANT_READ or ASR_WANT_WRITE */
+ int ar_fd; /* the fd waiting for io condition */
+ int ar_timeout; /* time to wait for in milliseconds */
+ /* Error fields. Depends on the query type. */
int ar_errno;
int ar_h_errno;
int ar_gai_errno;
int ar_rrset_errno;
- int ar_count;
-
- int ar_rcode;
- void *ar_data;
- int ar_datalen;
- union {
- struct sockaddr sa;
- struct sockaddr_in sain;
- struct sockaddr_in6 sain6;
- } ar_sa;
+ /* Result for res_*_async() calls */
+ int ar_count; /* number of answers in the dns reply */
+ int ar_rcode; /* response code in the dns reply */
+ void *ar_data; /* raw reply packet (must be freed) */
+ int ar_datalen; /* reply packet length */
+ struct sockaddr_storage ar_ns; /* nameserver that responded */
+ /* Result for other calls. Must be freed properly. */
struct addrinfo *ar_addrinfo;
struct rrsetinfo *ar_rrsetinfo;
struct hostent *ar_hostent;
struct netent *ar_netent;
};
-int asr_async_run(struct async *, struct async_res *);
-int asr_async_run_sync(struct async *, struct async_res *);
-void asr_async_abort(struct async *);
-
-/* This opaque structure holds an async resolver context. */
-struct asr;
+/*
+ * Asynchronous query management.
+ */
-struct asr *asr_resolver(const char *);
-void asr_resolver_done(struct asr *);
+/* Forward declaration. The API uses opaque pointers as query handles. */
+struct asr_query;
-/* Async version of the resolver API */
+int asr_run(struct asr_query *, struct asr_result *);
+int asr_run_sync(struct asr_query *, struct asr_result *);
+void asr_abort(struct asr_query *);
-struct async *res_send_async(const unsigned char *, int, struct asr *);
-struct async *res_query_async(const char *, int, int, struct asr *);
-struct async *res_search_async(const char *, int, int, struct asr *);
+/*
+ * Asynchronous version of the resolver functions. Similar prototypes, with
+ * an extra context parameter at the end which must currently be set to NULL.
+ * All functions return a handle suitable for use with the management functions
+ * above.
+ */
+struct asr_query *res_send_async(const unsigned char *, int, void *);
+struct asr_query *res_query_async(const char *, int, int, void *);
+struct asr_query *res_search_async(const char *, int, int, void *);
-struct async *getrrsetbyname_async(const char *, unsigned int, unsigned int,
- unsigned int, struct asr *);
+struct asr_query *getrrsetbyname_async(const char *, unsigned int, unsigned int,
+ unsigned int, void *);
-struct async *gethostbyname_async(const char *, struct asr *);
-struct async *gethostbyname2_async(const char *, int, struct asr *);
-struct async *gethostbyaddr_async(const void *, socklen_t, int, struct asr *);
+struct asr_query *gethostbyname_async(const char *, void *);
+struct asr_query *gethostbyname2_async(const char *, int, void *);
+struct asr_query *gethostbyaddr_async(const void *, socklen_t, int, void *);
-struct async *getnetbyname_async(const char *, struct asr *);
-struct async *getnetbyaddr_async(in_addr_t, int, struct asr *);
+struct asr_query *getnetbyname_async(const char *, void *);
+struct asr_query *getnetbyaddr_async(in_addr_t, int, void *);
-struct async *getaddrinfo_async(const char *, const char *,
- const struct addrinfo *, struct asr *);
-struct async *getnameinfo_async(const struct sockaddr *, socklen_t, char *,
- size_t, char *, size_t, int, struct asr *);
-void asr_freeaddrinfo(struct addrinfo *);
+struct asr_query *getaddrinfo_async(const char *, const char *,
+ const struct addrinfo *, void *);
+struct asr_query *getnameinfo_async(const struct sockaddr *, socklen_t, char *,
+ size_t, char *, size_t, int, void *);
diff --git a/contrib/lib/libc/asr/asr_debug.c b/contrib/lib/libc/asr/asr_debug.c
index 00509eef..3dc6fe51 100644
--- a/contrib/lib/libc/asr/asr_debug.c
+++ b/contrib/lib/libc/asr/asr_debug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr_debug.c,v 1.14 2013/07/12 14:36:21 eric Exp $ */
+/* $OpenBSD: asr_debug.c,v 1.16 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -30,9 +30,9 @@
static const char *rcodetostr(uint16_t);
static const char *print_dname(const char *, char *, size_t);
-static const char *print_header(const struct header *, char *, size_t);
-static const char *print_query(const struct query *, char *, size_t);
-static const char *print_rr(const struct rr *, char *, size_t);
+static const char *print_header(const struct asr_dns_header *, char *, size_t);
+static const char *print_query(const struct asr_dns_query *, char *, size_t);
+static const char *print_rr(const struct asr_dns_rr *, char *, size_t);
FILE *asr_debug = NULL;
@@ -60,7 +60,7 @@ print_dname(const char *_dname, char *buf, size_t max)
}
static const char *
-print_rr(const struct rr *rr, char *buf, size_t max)
+print_rr(const struct asr_dns_rr *rr, char *buf, size_t max)
{
char *res;
char tmp[256];
@@ -132,7 +132,7 @@ print_rr(const struct rr *rr, char *buf, size_t max)
}
static const char *
-print_query(const struct query *q, char *buf, size_t max)
+print_query(const struct asr_dns_query *q, char *buf, size_t max)
{
char b[256];
@@ -144,7 +144,7 @@ print_query(const struct query *q, char *buf, size_t max)
}
static const char *
-print_header(const struct header *h, char *buf, size_t max)
+print_header(const struct asr_dns_header *h, char *buf, size_t max)
{
snprintf(buf, max,
"id:0x%04x %s op:%i %s %s %s %s z:%i r:%s qd:%i an:%i ns:%i ar:%i",
@@ -165,12 +165,12 @@ print_header(const struct header *h, char *buf, size_t max)
void
asr_dump_packet(FILE *f, const void *data, size_t len)
{
- char buf[1024];
- struct unpack p;
- struct header h;
- struct query q;
- struct rr rr;
- int i, an, ns, ar, n;
+ char buf[1024];
+ struct asr_unpack p;
+ struct asr_dns_header h;
+ struct asr_dns_query q;
+ struct asr_dns_rr rr;
+ int i, an, ns, ar, n;
if (f == NULL)
return;
@@ -356,7 +356,6 @@ asr_transitionstr(int type)
{
switch (type) {
CASE(ASYNC_COND);
- CASE(ASYNC_YIELD);
CASE(ASYNC_DONE);
default:
return "?";
diff --git a/contrib/lib/libc/asr/asr_private.h b/contrib/lib/libc/asr/asr_private.h
index 821f513f..d03e6863 100644
--- a/contrib/lib/libc/asr/asr_private.h
+++ b/contrib/lib/libc/asr/asr_private.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr_private.h,v 1.23 2013/07/12 14:36:21 eric Exp $ */
+/* $OpenBSD: asr_private.h,v 1.25 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -34,21 +34,21 @@
#define RCODE(v) ((v) & RCODE_MASK)
-struct pack {
+struct asr_pack {
char *buf;
size_t len;
size_t offset;
const char *err;
};
-struct unpack {
+struct asr_unpack {
const char *buf;
size_t len;
size_t offset;
const char *err;
};
-struct header {
+struct asr_dns_header {
uint16_t id;
uint16_t flags;
uint16_t qdcount;
@@ -57,13 +57,13 @@ struct header {
uint16_t arcount;
};
-struct query {
+struct asr_dns_query {
char q_dname[MAXDNAME];
uint16_t q_type;
uint16_t q_class;
};
-struct rr {
+struct asr_dns_rr {
char rr_dname[MAXDNAME];
uint16_t rr_type;
uint16_t rr_class;
@@ -152,6 +152,8 @@ struct asr {
struct asr_ctx *a_ctx;
};
+#define ASYNC_COND 0
+#define ASYNC_DONE 1
#define ASYNC_DOM_FQDN 0x00000001
#define ASYNC_DOM_NDOTS 0x00000002
@@ -164,8 +166,8 @@ struct asr {
#define ASYNC_EXTOBUF 0x00002000
-struct async {
- int (*as_run)(struct async *, struct async_res *);
+struct asr_query {
+ int (*as_run)(struct asr_query *, struct asr_result *);
struct asr_ctx *as_ctx;
int as_type;
int as_state;
@@ -212,7 +214,7 @@ struct async {
int class;
int type;
char *name;
- struct async *subq;
+ struct asr_query *subq;
int saved_h_errno;
} search;
@@ -221,13 +223,13 @@ struct async {
int class;
int type;
char *name;
- struct async *subq;
+ struct asr_query *subq;
} rrset;
struct {
char *name;
int family;
- struct async *subq;
+ struct asr_query *subq;
char addr[16];
int addrlen;
int subq_h_errno;
@@ -236,7 +238,7 @@ struct async {
struct {
char *name;
int family;
- struct async *subq;
+ struct asr_query *subq;
in_addr_t addr;
} netnamadr;
@@ -255,7 +257,7 @@ struct async {
char *fqdn;
struct addrinfo *aifirst;
struct addrinfo *ailast;
- struct async *subq;
+ struct asr_query *subq;
int flags;
} ai;
@@ -270,7 +272,7 @@ struct async {
struct sockaddr_in6 sain6;
} sa;
int flags;
- struct async *subq;
+ struct asr_query *subq;
} ni;
#define MAXTOKEN 10
} as;
@@ -299,32 +301,34 @@ enum asr_state {
/* asr_utils.c */
-void asr_pack_init(struct pack *, char *, size_t);
-int asr_pack_header(struct pack *, const struct header *);
-int asr_pack_query(struct pack *, uint16_t, uint16_t, const char *);
-void asr_unpack_init(struct unpack *, const char *, size_t);
-int asr_unpack_header(struct unpack *, struct header *);
-int asr_unpack_query(struct unpack *, struct query *);
-int asr_unpack_rr(struct unpack *, struct rr *);
-int asr_sockaddr_from_str(struct sockaddr *, int, const char *);
+void asr_pack_init(struct asr_pack *, char *, size_t);
+int asr_pack_header(struct asr_pack *, const struct asr_dns_header *);
+int asr_pack_query(struct asr_pack *, uint16_t, uint16_t, const char *);
+void asr_unpack_init(struct asr_unpack *, const char *, size_t);
+int asr_unpack_header(struct asr_unpack *, struct asr_dns_header *);
+int asr_unpack_query(struct asr_unpack *, struct asr_dns_query *);
+int asr_unpack_rr(struct asr_unpack *, struct asr_dns_rr *);
+int asr_sockaddr_from_str(struct sockaddr *, int, const char *);
ssize_t asr_dname_from_fqdn(const char *, char *, size_t);
ssize_t asr_addr_as_fqdn(const char *, int, char *, size_t);
/* asr.c */
-struct asr_ctx *asr_use_resolver(struct asr *);
+void *asr_resolver(const char *);
+void asr_resolver_done(void *);
+struct asr_ctx *asr_use_resolver(void *);
void asr_ctx_unref(struct asr_ctx *);
-struct async *asr_async_new(struct asr_ctx *, int);
-void asr_async_free(struct async *);
+struct asr_query *asr_async_new(struct asr_ctx *, int);
+void asr_async_free(struct asr_query *);
size_t asr_make_fqdn(const char *, const char *, char *, size_t);
char *asr_strdname(const char *, char *, size_t);
-int asr_iter_db(struct async *);
+int asr_iter_db(struct asr_query *);
int asr_parse_namedb_line(FILE *, char **, int);
char *asr_hostalias(struct asr_ctx *, const char *, char *, size_t);
-/* <*>_async.h */
-struct async *res_query_async_ctx(const char *, int, int, struct asr_ctx *);
-struct async *res_search_async_ctx(const char *, int, int, struct asr_ctx *);
-struct async *gethostbyaddr_async_ctx(const void *, socklen_t, int,
+/* *_async.c */
+struct asr_query *res_query_async_ctx(const char *, int, int, struct asr_ctx *);
+struct asr_query *res_search_async_ctx(const char *, int, int, struct asr_ctx *);
+struct asr_query *gethostbyaddr_async_ctx(const void *, socklen_t, int,
struct asr_ctx *);
#ifdef DEBUG
diff --git a/contrib/lib/libc/asr/asr_utils.c b/contrib/lib/libc/asr/asr_utils.c
index 871ccc1a..7d83ecdf 100644
--- a/contrib/lib/libc/asr/asr_utils.c
+++ b/contrib/lib/libc/asr/asr_utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr_utils.c,v 1.9 2013/11/24 23:51:29 deraadt Exp $ */
+/* $OpenBSD: asr_utils.c,v 1.11 2014/03/14 11:07:33 eric Exp $ */
/*
* Copyright (c) 2009-2012 Eric Faurot <eric@faurot.net>
*
@@ -39,16 +39,16 @@ static int dname_check_label(const char *, size_t);
static ssize_t dname_expand(const unsigned char *, size_t, size_t, size_t *,
char *, size_t);
-static int unpack_data(struct unpack *, void *, size_t);
-static int unpack_u16(struct unpack *, uint16_t *);
-static int unpack_u32(struct unpack *, uint32_t *);
-static int unpack_inaddr(struct unpack *, struct in_addr *);
-static int unpack_in6addr(struct unpack *, struct in6_addr *);
-static int unpack_dname(struct unpack *, char *, size_t);
+static int unpack_data(struct asr_unpack *, void *, size_t);
+static int unpack_u16(struct asr_unpack *, uint16_t *);
+static int unpack_u32(struct asr_unpack *, uint32_t *);
+static int unpack_inaddr(struct asr_unpack *, struct in_addr *);
+static int unpack_in6addr(struct asr_unpack *, struct in6_addr *);
+static int unpack_dname(struct asr_unpack *, char *, size_t);
-static int pack_data(struct pack *, const void *, size_t);
-static int pack_u16(struct pack *, uint16_t);
-static int pack_dname(struct pack *, const char *);
+static int pack_data(struct asr_pack *, const void *, size_t);
+static int pack_u16(struct asr_pack *, uint16_t);
+static int pack_dname(struct asr_pack *, const char *);
static int
dname_check_label(const char *s, size_t l)
@@ -163,7 +163,7 @@ dname_expand(const unsigned char *data, size_t len, size_t offset,
}
void
-asr_pack_init(struct pack *pack, char *buf, size_t len)
+asr_pack_init(struct asr_pack *pack, char *buf, size_t len)
{
pack->buf = buf;
pack->len = len;
@@ -172,7 +172,7 @@ asr_pack_init(struct pack *pack, char *buf, size_t len)
}
void
-asr_unpack_init(struct unpack *unpack, const char *buf, size_t len)
+asr_unpack_init(struct asr_unpack *unpack, const char *buf, size_t len)
{
unpack->buf = buf;
unpack->len = len;
@@ -181,7 +181,7 @@ asr_unpack_init(struct unpack *unpack, const char *buf, size_t len)
}
static int
-unpack_data(struct unpack *p, void *data, size_t len)
+unpack_data(struct asr_unpack *p, void *data, size_t len)
{
if (p->err)
return (-1);
@@ -198,7 +198,7 @@ unpack_data(struct unpack *p, void *data, size_t len)
}
static int
-unpack_u16(struct unpack *p, uint16_t *u16)
+unpack_u16(struct asr_unpack *p, uint16_t *u16)
{
if (unpack_data(p, u16, 2) == -1)
return (-1);
@@ -209,7 +209,7 @@ unpack_u16(struct unpack *p, uint16_t *u16)
}
static int
-unpack_u32(struct unpack *p, uint32_t *u32)
+unpack_u32(struct asr_unpack *p, uint32_t *u32)
{
if (unpack_data(p, u32, 4) == -1)
return (-1);
@@ -220,19 +220,19 @@ unpack_u32(struct unpack *p, uint32_t *u32)
}
static int
-unpack_inaddr(struct unpack *p, struct in_addr *a)
+unpack_inaddr(struct asr_unpack *p, struct in_addr *a)
{
return (unpack_data(p, a, 4));
}
static int
-unpack_in6addr(struct unpack *p, struct in6_addr *a6)
+unpack_in6addr(struct asr_unpack *p, struct in6_addr *a6)
{
return (unpack_data(p, a6, 16));
}
static int
-unpack_dname(struct unpack *p, char *dst, size_t max)
+unpack_dname(struct asr_unpack *p, char *dst, size_t max)
{
ssize_t e;
@@ -253,7 +253,7 @@ unpack_dname(struct unpack *p, char *dst, size_t max)
}
int
-asr_unpack_header(struct unpack *p, struct header *h)
+asr_unpack_header(struct asr_unpack *p, struct asr_dns_header *h)
{
if (unpack_data(p, h, HFIXEDSZ) == -1)
return (-1);
@@ -268,7 +268,7 @@ asr_unpack_header(struct unpack *p, struct header *h)
}
int
-asr_unpack_query(struct unpack *p, struct query *q)
+asr_unpack_query(struct asr_unpack *p, struct asr_dns_query *q)
{
unpack_dname(p, q->q_dname, sizeof(q->q_dname));
unpack_u16(p, &q->q_type);
@@ -278,7 +278,7 @@ asr_unpack_query(struct unpack *p, struct query *q)
}
int
-asr_unpack_rr(struct unpack *p, struct rr *rr)
+asr_unpack_rr(struct asr_unpack *p, struct asr_dns_rr *rr)
{
uint16_t rdlen;
size_t save_offset;
@@ -357,7 +357,7 @@ asr_unpack_rr(struct unpack *p, struct rr *rr)
}
static int
-pack_data(struct pack *p, const void *data, size_t len)
+pack_data(struct asr_pack *p, const void *data, size_t len)
{
if (p->err)
return (-1);
@@ -374,7 +374,7 @@ pack_data(struct pack *p, const void *data, size_t len)
}
static int
-pack_u16(struct pack *p, uint16_t v)
+pack_u16(struct asr_pack *p, uint16_t v)
{
v = htons(v);
@@ -382,7 +382,7 @@ pack_u16(struct pack *p, uint16_t v)
}
static int
-pack_dname(struct pack *p, const char *dname)
+pack_dname(struct asr_pack *p, const char *dname)
{
/* dname compression would be nice to have here.
* need additionnal context.
@@ -391,9 +391,9 @@ pack_dname(struct pack *p, const char *dname)
}
int
-asr_pack_header(struct pack *p, const struct header *h)
+asr_pack_header(struct asr_pack *p, const struct asr_dns_header *h)
{
- struct header c;
+ struct asr_dns_header c;
c.id = h->id;
c.flags = htons(h->flags);
@@ -406,7 +406,7 @@ asr_pack_header(struct pack *p, const struct header *h)
}
int
-asr_pack_query(struct pack *p, uint16_t type, uint16_t class, const char *dname)
+asr_pack_query(struct asr_pack *p, uint16_t type, uint16_t class, const char *dname)
{
pack_dname(p, dname);
pack_u16(p, type);
diff --git a/contrib/lib/libc/asr/getaddrinfo.c b/contrib/lib/libc/asr/getaddrinfo.c
index 0c6e2f45..074a824c 100644
--- a/contrib/lib/libc/asr/getaddrinfo.c
+++ b/contrib/lib/libc/asr/getaddrinfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getaddrinfo.c,v 1.3 2013/07/12 14:36:21 eric Exp $ */
+/* $OpenBSD: getaddrinfo.c,v 1.4 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -27,8 +27,8 @@ int
getaddrinfo(const char *hostname, const char *servname,
const struct addrinfo *hints, struct addrinfo **res)
{
- struct async *as;
- struct async_res ar;
+ struct asr_query *as;
+ struct asr_result ar;
int saved_errno = errno;
res_init();
@@ -42,7 +42,7 @@ getaddrinfo(const char *hostname, const char *servname,
return (EAI_SYSTEM);
}
- asr_async_run_sync(as, &ar);
+ asr_run_sync(as, &ar);
*res = ar.ar_addrinfo;
if (ar.ar_gai_errno == EAI_SYSTEM)
diff --git a/contrib/lib/libc/asr/getaddrinfo_async.c b/contrib/lib/libc/asr/getaddrinfo_async.c
index 1a6732f9..6a0c4cde 100644
--- a/contrib/lib/libc/asr/getaddrinfo_async.c
+++ b/contrib/lib/libc/asr/getaddrinfo_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getaddrinfo_async.c,v 1.19 2013/07/12 14:36:21 eric Exp $ */
+/* $OpenBSD: getaddrinfo_async.c,v 1.25 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -45,15 +45,15 @@ struct match {
int protocol;
};
-static int getaddrinfo_async_run(struct async *, struct async_res *);
+static int getaddrinfo_async_run(struct asr_query *, struct asr_result *);
static int get_port(const char *, const char *, int);
-static int iter_family(struct async *, int);
-static int iter_domain(struct async *, const char *, char *, size_t);
-static int addrinfo_add(struct async *, const struct sockaddr *, const char *);
-static int addrinfo_from_file(struct async *, int, FILE *);
-static int addrinfo_from_pkt(struct async *, char *, size_t);
+static int iter_family(struct asr_query *, int);
+static int iter_domain(struct asr_query *, const char *, char *, size_t);
+static int addrinfo_add(struct asr_query *, const struct sockaddr *, const char *);
+static int addrinfo_from_file(struct asr_query *, int, FILE *);
+static int addrinfo_from_pkt(struct asr_query *, char *, size_t);
#ifdef YP
-static int addrinfo_from_yp(struct async *, int, char *);
+static int addrinfo_from_yp(struct asr_query *, int, char *);
#endif
static const struct match matches[] = {
@@ -78,13 +78,13 @@ enum {
DOM_DONE
};
-struct async *
+struct asr_query *
getaddrinfo_async(const char *hostname, const char *servname,
- const struct addrinfo *hints, struct asr *asr)
+ const struct addrinfo *hints, void *asr)
{
- struct asr_ctx *ac;
- struct async *as;
- char alias[MAXDNAME];
+ struct asr_ctx *ac;
+ struct asr_query *as;
+ char alias[MAXDNAME];
ac = asr_use_resolver(asr);
if ((as = asr_async_new(ac, ASR_GETADDRINFO)) == NULL)
@@ -116,7 +116,7 @@ getaddrinfo_async(const char *hostname, const char *servname,
}
static int
-getaddrinfo_async_run(struct async *as, struct async_res *ar)
+getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar)
{
#ifdef YP
static char *domain = NULL;
@@ -430,8 +430,9 @@ getaddrinfo_async_run(struct async *as, struct async_res *ar)
break;
case ASR_STATE_SUBQUERY:
- if ((r = asr_async_run(as->as.ai.subq, ar)) == ASYNC_COND)
+ if ((r = asr_run(as->as.ai.subq, ar)) == ASYNC_COND)
return (ASYNC_COND);
+
as->as.ai.subq = NULL;
if (ar->ar_datalen == -1) {
@@ -489,7 +490,7 @@ get_port(const char *servname, const char *proto, int numonly)
{
struct servent se;
#ifdef HAVE_STRUCT_SERVENT_DATA
- struct servent_data sed;
+ struct servent_data sed;
#endif
int port, r;
const char *e;
@@ -530,7 +531,7 @@ get_port(const char *servname, const char *proto, int numonly)
* list on the async context, unless a specific family was given in hints.
*/
static int
-iter_family(struct async *as, int first)
+iter_family(struct asr_query *as, int first)
{
if (first) {
as->as_family_idx = 0;
@@ -579,7 +580,7 @@ domcat(const char *name, const char *domain, char *buf, size_t buflen)
* error generating the next name, or the resulting name length.
*/
static int
-iter_domain(struct async *as, const char *name, char * buf, size_t len)
+iter_domain(struct asr_query *as, const char *name, char * buf, size_t len)
{
const char *c;
int dots;
@@ -662,7 +663,7 @@ iter_domain(struct async *as, const char *name, char * buf, size_t len)
* entry per protocol/socktype match.
*/
static int
-addrinfo_add(struct async *as, const struct sockaddr *sa, const char *cname)
+addrinfo_add(struct asr_query *as, const struct sockaddr *sa, const char *cname)
{
struct addrinfo *ai;
int i, port, proto;
@@ -726,7 +727,7 @@ addrinfo_add(struct async *as, const struct sockaddr *sa, const char *cname)
void
asr_freeaddrinfo(struct addrinfo *ai)
{
- struct addrinfo *ai_next;
+ struct addrinfo *ai_next;
while (ai) {
ai_next = ai->ai_next;
@@ -738,7 +739,7 @@ asr_freeaddrinfo(struct addrinfo *ai)
}
static int
-addrinfo_from_file(struct async *as, int family, FILE *f)
+addrinfo_from_file(struct asr_query *as, int family, FILE *f)
{
char *tokens[MAXTOKEN], *c;
int n, i;
@@ -775,13 +776,13 @@ addrinfo_from_file(struct async *as, int family, FILE *f)
}
static int
-addrinfo_from_pkt(struct async *as, char *pkt, size_t pktlen)
+addrinfo_from_pkt(struct asr_query *as, char *pkt, size_t pktlen)
{
- struct unpack p;
- struct header h;
- struct query q;
- struct rr rr;
- int i;
+ struct asr_unpack p;
+ struct asr_dns_header h;
+ struct asr_dns_query q;
+ struct asr_dns_rr rr;
+ int i;
union {
struct sockaddr sa;
struct sockaddr_in sain;
@@ -851,7 +852,7 @@ strsplit(char *line, char **tokens, int ntokens)
}
static int
-addrinfo_from_yp(struct async *as, int family, char *line)
+addrinfo_from_yp(struct asr_query *as, int family, char *line)
{
char *next, *tokens[MAXTOKEN], *c;
int ntok;
diff --git a/contrib/lib/libc/asr/gethostnamadr.c b/contrib/lib/libc/asr/gethostnamadr.c
index 31ead29c..a7561f13 100644
--- a/contrib/lib/libc/asr/gethostnamadr.c
+++ b/contrib/lib/libc/asr/gethostnamadr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gethostnamadr.c,v 1.9 2013/07/12 14:36:21 eric Exp $ */
+/* $OpenBSD: gethostnamadr.c,v 1.10 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012,2013 Eric Faurot <eric@openbsd.org>
*
@@ -102,9 +102,9 @@ static int
_gethostbyname(const char *name, int af, struct hostent *ret, char *buf,
size_t buflen, int *h_errnop)
{
- struct async *as;
- struct async_res ar;
- int r;
+ struct asr_query *as;
+ struct asr_result ar;
+ int r;
if (af == -1)
as = gethostbyname_async(name, NULL);
@@ -114,7 +114,7 @@ _gethostbyname(const char *name, int af, struct hostent *ret, char *buf,
if (as == NULL)
return (errno);
- asr_async_run_sync(as, &ar);
+ asr_run_sync(as, &ar);
errno = ar.ar_errno;
*h_errnop = ar.ar_h_errno;
@@ -164,9 +164,9 @@ gethostbyname2(const char *name, int af)
struct hostent *
gethostbyaddr(const void *addr, socklen_t len, int af)
{
- struct async *as;
- struct async_res ar;
- int r;
+ struct asr_query *as;
+ struct asr_result ar;
+ int r;
res_init();
@@ -176,7 +176,7 @@ gethostbyaddr(const void *addr, socklen_t len, int af)
return (NULL);
}
- asr_async_run_sync(as, &ar);
+ asr_run_sync(as, &ar);
errno = ar.ar_errno;
h_errno = ar.ar_h_errno;
diff --git a/contrib/lib/libc/asr/gethostnamadr_async.c b/contrib/lib/libc/asr/gethostnamadr_async.c
index 1d8d8509..9723db05 100644
--- a/contrib/lib/libc/asr/gethostnamadr_async.c
+++ b/contrib/lib/libc/asr/gethostnamadr_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gethostnamadr_async.c,v 1.23 2013/11/24 23:51:29 deraadt Exp $ */
+/* $OpenBSD: gethostnamadr_async.c,v 1.27 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -51,7 +51,7 @@ struct hostent_ext {
char *pos;
};
-static int gethostnamadr_async_run(struct async *, struct async_res *);
+static int gethostnamadr_async_run(struct asr_query *, struct asr_result *);
static struct hostent_ext *hostent_alloc(int);
static int hostent_set_cname(struct hostent_ext *, const char *, int);
static int hostent_add_alias(struct hostent_ext *, const char *, int);
@@ -65,17 +65,17 @@ static struct hostent_ext *_yp_gethostnamadr(int, const void *);
static struct hostent_ext *hostent_from_yp(int, char *);
#endif
-struct async *
-gethostbyname_async(const char *name, struct asr *asr)
+struct asr_query *
+gethostbyname_async(const char *name, void *asr)
{
return gethostbyname2_async(name, AF_INET, asr);
}
-struct async *
-gethostbyname2_async(const char *name, int af, struct asr *asr)
+struct asr_query *
+gethostbyname2_async(const char *name, int af, void *asr)
{
- struct asr_ctx *ac;
- struct async *as;
+ struct asr_ctx *ac;
+ struct asr_query *as;
/* the original segfaults */
if (name == NULL) {
@@ -107,11 +107,11 @@ gethostbyname2_async(const char *name, int af, struct asr *asr)
return (NULL);
}
-struct async *
-gethostbyaddr_async(const void *addr, socklen_t len, int af, struct asr *asr)
+struct asr_query *
+gethostbyaddr_async(const void *addr, socklen_t len, int af, void *asr)
{
- struct asr_ctx *ac;
- struct async *as;
+ struct asr_ctx *ac;
+ struct asr_query *as;
ac = asr_use_resolver(asr);
as = gethostbyaddr_async_ctx(addr, len, af, ac);
@@ -120,11 +120,11 @@ gethostbyaddr_async(const void *addr, socklen_t len, int af, struct asr *asr)
return (as);
}
-struct async *
+struct asr_query *
gethostbyaddr_async_ctx(const void *addr, socklen_t len, int af,
struct asr_ctx *ac)
{
- struct async *as;
+ struct asr_query *as;
if ((as = asr_async_new(ac, ASR_GETHOSTBYADDR)) == NULL)
goto abort; /* errno set */
@@ -144,7 +144,7 @@ gethostbyaddr_async_ctx(const void *addr, socklen_t len, int af,
}
static int
-gethostnamadr_async_run(struct async *as, struct async_res *ar)
+gethostnamadr_async_run(struct asr_query *as, struct asr_result *ar)
{
struct hostent_ext *h;
int r, type, saved_errno;
@@ -308,7 +308,7 @@ gethostnamadr_async_run(struct async *as, struct async_res *ar)
/* Run the DNS subquery. */
- if ((r = asr_async_run(as->as.hostnamadr.subq, ar)) == ASYNC_COND)
+ if ((r = asr_run(as->as.hostnamadr.subq, ar)) == ASYNC_COND)
return (ASYNC_COND);
/* Done. */
@@ -469,12 +469,12 @@ fail:
static struct hostent_ext *
hostent_from_packet(int reqtype, int family, char *pkt, size_t pktlen)
{
- struct hostent_ext *h;
- struct unpack p;
- struct header hdr;
- struct query q;
- struct rr rr;
- char dname[MAXDNAME];
+ struct hostent_ext *h;
+ struct asr_unpack p;
+ struct asr_dns_header hdr;
+ struct asr_dns_query q;
+ struct asr_dns_rr rr;
+ char dname[MAXDNAME];
if ((h = hostent_alloc(family)) == NULL)
return (NULL);
diff --git a/contrib/lib/libc/asr/getnameinfo.c b/contrib/lib/libc/asr/getnameinfo.c
index 5f5c6535..4ca82dae 100644
--- a/contrib/lib/libc/asr/getnameinfo.c
+++ b/contrib/lib/libc/asr/getnameinfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getnameinfo.c,v 1.3 2013/07/12 14:36:21 eric Exp $ */
+/* $OpenBSD: getnameinfo.c,v 1.4 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -27,9 +27,9 @@ int
getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
size_t hostlen, char *serv, size_t servlen, int flags)
{
- struct async *as;
- struct async_res ar;
- int saved_errno = errno;
+ struct asr_query *as;
+ struct asr_result ar;
+ int saved_errno = errno;
res_init();
@@ -43,7 +43,7 @@ getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
return (EAI_SYSTEM);
}
- asr_async_run_sync(as, &ar);
+ asr_run_sync(as, &ar);
if (ar.ar_gai_errno == EAI_SYSTEM)
errno = ar.ar_errno;
diff --git a/contrib/lib/libc/asr/getnameinfo_async.c b/contrib/lib/libc/asr/getnameinfo_async.c
index a9f5181e..c727f2b8 100644
--- a/contrib/lib/libc/asr/getnameinfo_async.c
+++ b/contrib/lib/libc/asr/getnameinfo_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getnameinfo_async.c,v 1.7 2013/07/12 14:36:22 eric Exp $ */
+/* $OpenBSD: getnameinfo_async.c,v 1.8 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -33,16 +33,16 @@
#include "asr.h"
#include "asr_private.h"
-static int getnameinfo_async_run(struct async *, struct async_res *);
-static int _servname(struct async *);
-static int _numerichost(struct async *);
+static int getnameinfo_async_run(struct asr_query *, struct asr_result *);
+static int _servname(struct asr_query *);
+static int _numerichost(struct asr_query *);
-struct async *
+struct asr_query *
getnameinfo_async(const struct sockaddr *sa, socklen_t slen, char *host,
- size_t hostlen, char *serv, size_t servlen, int flags, struct asr *asr)
+ size_t hostlen, char *serv, size_t servlen, int flags, void *asr)
{
- struct asr_ctx *ac;
- struct async *as;
+ struct asr_ctx *ac;
+ struct asr_query *as;
ac = asr_use_resolver(asr);
if ((as = asr_async_new(ac, ASR_GETNAMEINFO)) == NULL)
@@ -74,7 +74,7 @@ getnameinfo_async(const struct sockaddr *sa, socklen_t slen, char *host,
}
static int
-getnameinfo_async_run(struct async *as, struct async_res *ar)
+getnameinfo_async_run(struct asr_query *as, struct asr_result *ar)
{
void *addr;
socklen_t addrlen;
@@ -157,7 +157,7 @@ getnameinfo_async_run(struct async *as, struct async_res *ar)
case ASR_STATE_SUBQUERY:
- if ((r = asr_async_run(as->as.ni.subq, ar)) == ASYNC_COND)
+ if ((r = asr_run(as->as.ni.subq, ar)) == ASYNC_COND)
return (ASYNC_COND);
/*
@@ -210,7 +210,7 @@ getnameinfo_async_run(struct async *as, struct async_res *ar)
* return (-1) if the buffer is too small.
*/
static int
-_servname(struct async *as)
+_servname(struct asr_query *as)
{
struct servent s;
#ifdef HAVE_STRUCT_SERVENT_DATA
@@ -259,7 +259,7 @@ _servname(struct async *as)
* Write the numeric address
*/
static int
-_numerichost(struct async *as)
+_numerichost(struct asr_query *as)
{
unsigned int ifidx;
char scope[IF_NAMESIZE + 1], *ifname;
diff --git a/contrib/lib/libc/asr/getnetnamadr.c b/contrib/lib/libc/asr/getnetnamadr.c
index eeae092c..07ed822d 100644
--- a/contrib/lib/libc/asr/getnetnamadr.c
+++ b/contrib/lib/libc/asr/getnetnamadr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getnetnamadr.c,v 1.6 2013/07/12 14:36:22 eric Exp $ */
+/* $OpenBSD: getnetnamadr.c,v 1.7 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -80,8 +80,8 @@ _fillnetent(const struct netent *e, struct netent *r, char *buf, size_t len)
struct netent *
getnetbyname(const char *name)
{
- struct async *as;
- struct async_res ar;
+ struct asr_query *as;
+ struct asr_result ar;
res_init();
@@ -91,7 +91,7 @@ getnetbyname(const char *name)
return (NULL);
}
- asr_async_run_sync(as, &ar);
+ asr_run_sync(as, &ar);
errno = ar.ar_errno;
h_errno = ar.ar_h_errno;
@@ -107,8 +107,8 @@ getnetbyname(const char *name)
struct netent *
getnetbyaddr(in_addr_t net, int type)
{
- struct async *as;
- struct async_res ar;
+ struct asr_query *as;
+ struct asr_result ar;
res_init();
@@ -118,7 +118,7 @@ getnetbyaddr(in_addr_t net, int type)
return (NULL);
}
- asr_async_run_sync(as, &ar);
+ asr_run_sync(as, &ar);
errno = ar.ar_errno;
h_errno = ar.ar_h_errno;
diff --git a/contrib/lib/libc/asr/getnetnamadr_async.c b/contrib/lib/libc/asr/getnetnamadr_async.c
index 128e598d..d024d97e 100644
--- a/contrib/lib/libc/asr/getnetnamadr_async.c
+++ b/contrib/lib/libc/asr/getnetnamadr_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getnetnamadr_async.c,v 1.10 2013/07/12 14:36:22 eric Exp $ */
+/* $OpenBSD: getnetnamadr_async.c,v 1.13 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -42,18 +42,18 @@ struct netent_ext {
char *pos;
};
-static int getnetnamadr_async_run(struct async *, struct async_res *);
+static int getnetnamadr_async_run(struct asr_query *, struct asr_result *);
static struct netent_ext *netent_alloc(int);
static int netent_set_cname(struct netent_ext *, const char *, int);
static int netent_add_alias(struct netent_ext *, const char *, int);
static struct netent_ext *netent_file_match(FILE *, int, const char *);
static struct netent_ext *netent_from_packet(int, char *, size_t);
-struct async *
-getnetbyname_async(const char *name, struct asr *asr)
+struct asr_query *
+getnetbyname_async(const char *name, void *asr)
{
- struct asr_ctx *ac;
- struct async *as;
+ struct asr_ctx *ac;
+ struct asr_query *as;
/* The current resolver segfaults. */
if (name == NULL) {
@@ -81,11 +81,11 @@ getnetbyname_async(const char *name, struct asr *asr)
return (NULL);
}
-struct async *
-getnetbyaddr_async(in_addr_t net, int family, struct asr *asr)
+struct asr_query *
+getnetbyaddr_async(in_addr_t net, int family, void *asr)
{
- struct asr_ctx *ac;
- struct async *as;
+ struct asr_ctx *ac;
+ struct asr_query *as;
ac = asr_use_resolver(asr);
if ((as = asr_async_new(ac, ASR_GETNETBYADDR)) == NULL)
@@ -106,7 +106,7 @@ getnetbyaddr_async(in_addr_t net, int family, struct asr *asr)
}
static int
-getnetnamadr_async_run(struct async *as, struct async_res *ar)
+getnetnamadr_async_run(struct asr_query *as, struct asr_result *ar)
{
struct netent_ext *n;
int r, type, saved_errno;
@@ -203,7 +203,7 @@ getnetnamadr_async_run(struct async *as, struct async_res *ar)
case ASR_STATE_SUBQUERY:
- if ((r = asr_async_run(as->as.netnamadr.subq, ar)) == ASYNC_COND)
+ if ((r = asr_run(as->as.netnamadr.subq, ar)) == ASYNC_COND)
return (ASYNC_COND);
as->as.netnamadr.subq = NULL;
@@ -322,10 +322,10 @@ static struct netent_ext *
netent_from_packet(int reqtype, char *pkt, size_t pktlen)
{
struct netent_ext *n;
- struct unpack p;
- struct header hdr;
- struct query q;
- struct rr rr;
+ struct asr_unpack p;
+ struct asr_dns_header hdr;
+ struct asr_dns_query q;
+ struct asr_dns_rr rr;
if ((n = netent_alloc(AF_INET)) == NULL)
return (NULL);
diff --git a/contrib/lib/libc/asr/getrrsetbyname.c b/contrib/lib/libc/asr/getrrsetbyname.c
index 8736ae06..359f1dd4 100644
--- a/contrib/lib/libc/asr/getrrsetbyname.c
+++ b/contrib/lib/libc/asr/getrrsetbyname.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getrrsetbyname.c,v 1.3 2013/07/12 14:36:22 eric Exp $ */
+/* $OpenBSD: getrrsetbyname.c,v 1.4 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -28,9 +28,9 @@ int
getrrsetbyname(const char *name, unsigned int class, unsigned int type,
unsigned int flags, struct rrsetinfo **res)
{
- struct async *as;
- struct async_res ar;
- int r, saved_errno = errno;
+ struct asr_query *as;
+ struct asr_result ar;
+ int r, saved_errno = errno;
res_init();
@@ -41,7 +41,7 @@ getrrsetbyname(const char *name, unsigned int class, unsigned int type,
return (r);
}
- asr_async_run_sync(as, &ar);
+ asr_run_sync(as, &ar);
*res = ar.ar_rrsetinfo;
diff --git a/contrib/lib/libc/asr/getrrsetbyname_async.c b/contrib/lib/libc/asr/getrrsetbyname_async.c
index ad75c05f..eb5db42d 100644
--- a/contrib/lib/libc/asr/getrrsetbyname_async.c
+++ b/contrib/lib/libc/asr/getrrsetbyname_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getrrsetbyname_async.c,v 1.5 2013/07/12 14:36:22 eric Exp $ */
+/* $OpenBSD: getrrsetbyname_async.c,v 1.6 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -33,15 +33,15 @@
#include "asr.h"
#include "asr_private.h"
-static int getrrsetbyname_async_run(struct async *, struct async_res *);
-static void get_response(struct async_res *, const char *, int);
+static int getrrsetbyname_async_run(struct asr_query *, struct asr_result *);
+static void get_response(struct asr_result *, const char *, int);
-struct async *
+struct asr_query *
getrrsetbyname_async(const char *hostname, unsigned int rdclass,
- unsigned int rdtype, unsigned int flags, struct asr *asr)
+ unsigned int rdtype, unsigned int flags, void *asr)
{
- struct asr_ctx *ac;
- struct async *as;
+ struct asr_ctx *ac;
+ struct asr_query *as;
ac = asr_use_resolver(asr);
if ((as = asr_async_new(ac, ASR_GETRRSETBYNAME)) == NULL)
@@ -66,7 +66,7 @@ getrrsetbyname_async(const char *hostname, unsigned int rdclass,
}
static int
-getrrsetbyname_async_run(struct async *as, struct async_res *ar)
+getrrsetbyname_async_run(struct asr_query *as, struct asr_result *ar)
{
next:
switch (as->as_state) {
@@ -111,7 +111,7 @@ getrrsetbyname_async_run(struct async *as, struct async_res *ar)
case ASR_STATE_SUBQUERY:
- if ((asr_async_run(as->as.rrset.subq, ar)) == ASYNC_COND)
+ if ((asr_run(as->as.rrset.subq, ar)) == ASYNC_COND)
return (ASYNC_COND);
as->as.rrset.subq = NULL;
@@ -171,7 +171,7 @@ getrrsetbyname_async_run(struct async *as, struct async_res *ar)
/* The rest of this file is taken from the orignal implementation. */
-/* $OpenBSD: getrrsetbyname_async.c,v 1.5 2013/07/12 14:36:22 eric Exp $ */
+/* $OpenBSD: getrrsetbyname_async.c,v 1.6 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2001 Jakob Schlyter. All rights reserved.
@@ -256,7 +256,7 @@ static void free_dns_response(struct dns_response *);
static int count_dns_rr(struct dns_rr *, u_int16_t, u_int16_t);
static void
-get_response(struct async_res *ar, const char *pkt, int pktlen)
+get_response(struct asr_result *ar, const char *pkt, int pktlen)
{
struct rrsetinfo *rrset = NULL;
struct dns_response *response = NULL;
diff --git a/contrib/lib/libc/asr/res_init.c b/contrib/lib/libc/asr/res_init.c
index 136a6a11..86065046 100644
--- a/contrib/lib/libc/asr/res_init.c
+++ b/contrib/lib/libc/asr/res_init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_init.c,v 1.2 2013/05/27 17:31:01 eric Exp $ */
+/* $OpenBSD: res_init.c,v 1.3 2014/01/15 02:25:34 sthen Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
diff --git a/contrib/lib/libc/asr/res_mkquery.c b/contrib/lib/libc/asr/res_mkquery.c
index 8e9e2689..9f2aa0de 100644
--- a/contrib/lib/libc/asr/res_mkquery.c
+++ b/contrib/lib/libc/asr/res_mkquery.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_mkquery.c,v 1.6 2013/07/12 14:36:22 eric Exp $ */
+/* $OpenBSD: res_mkquery.c,v 1.7 2014/03/14 11:07:33 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -32,11 +32,11 @@ res_mkquery(int op, const char *dname, int class, int type,
const unsigned char *data, int datalen, const unsigned char *newrr,
unsigned char *buf, int buflen)
{
- struct asr_ctx *ac;
- struct pack p;
- struct header h;
- char fqdn[MAXDNAME];
- char dn[MAXDNAME];
+ struct asr_ctx *ac;
+ struct asr_pack p;
+ struct asr_dns_header h;
+ char fqdn[MAXDNAME];
+ char dn[MAXDNAME];
/* we currently only support QUERY */
if (op != QUERY || data)
diff --git a/contrib/lib/libc/asr/res_query.c b/contrib/lib/libc/asr/res_query.c
index 72401af3..2c6b198e 100644
--- a/contrib/lib/libc/asr/res_query.c
+++ b/contrib/lib/libc/asr/res_query.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_query.c,v 1.6 2013/11/12 06:09:50 deraadt Exp $ */
+/* $OpenBSD: res_query.c,v 1.7 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -28,8 +28,8 @@
int
res_query(const char *name, int class, int type, u_char *ans, int anslen)
{
- struct async *as;
- struct async_res ar;
+ struct asr_query *as;
+ struct asr_result ar;
size_t len;
res_init();
@@ -49,7 +49,7 @@ res_query(const char *name, int class, int type, u_char *ans, int anslen)
return (-1); /* errno set */
}
- asr_async_run_sync(as, &ar);
+ asr_run_sync(as, &ar);
if (ar.ar_errno)
errno = ar.ar_errno;
@@ -70,8 +70,8 @@ res_query(const char *name, int class, int type, u_char *ans, int anslen)
int
res_search(const char *name, int class, int type, u_char *ans, int anslen)
{
- struct async *as;
- struct async_res ar;
+ struct asr_query *as;
+ struct asr_result ar;
size_t len;
res_init();
@@ -91,7 +91,7 @@ res_search(const char *name, int class, int type, u_char *ans, int anslen)
return (-1); /* errno set */
}
- asr_async_run_sync(as, &ar);
+ asr_run_sync(as, &ar);
if (ar.ar_errno)
errno = ar.ar_errno;
diff --git a/contrib/lib/libc/asr/res_search_async.c b/contrib/lib/libc/asr/res_search_async.c
index e6017d55..6a23a962 100644
--- a/contrib/lib/libc/asr/res_search_async.c
+++ b/contrib/lib/libc/asr/res_search_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_search_async.c,v 1.10 2013/07/12 14:36:22 eric Exp $ */
+/* $OpenBSD: res_search_async.c,v 1.12 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -30,19 +30,19 @@
#include "asr.h"
#include "asr_private.h"
-static int res_search_async_run(struct async *, struct async_res *);
+static int res_search_async_run(struct asr_query *, struct asr_result *);
static size_t domcat(const char *, const char *, char *, size_t);
-static int iter_domain(struct async *, const char *, char *, size_t);
+static int iter_domain(struct asr_query *, const char *, char *, size_t);
/*
* Unlike res_query_async(), this function returns a valid packet only if
* h_errno is NETDB_SUCCESS.
*/
-struct async *
-res_search_async(const char *name, int class, int type, struct asr *asr)
+struct asr_query *
+res_search_async(const char *name, int class, int type, void *asr)
{
- struct asr_ctx *ac;
- struct async *as;
+ struct asr_ctx *ac;
+ struct asr_query *as;
DPRINT("asr: res_search_async(\"%s\", %i, %i)\n", name, class, type);
@@ -53,11 +53,11 @@ res_search_async(const char *name, int class, int type, struct asr *asr)
return (as);
}
-struct async *
+struct asr_query *
res_search_async_ctx(const char *name, int class, int type, struct asr_ctx *ac)
{
- struct async *as;
- char alias[MAXDNAME];
+ struct asr_query *as;
+ char alias[MAXDNAME];
DPRINT("asr: res_search_async_ctx(\"%s\", %i, %i)\n", name, class,
type);
@@ -84,7 +84,7 @@ res_search_async_ctx(const char *name, int class, int type, struct asr_ctx *ac)
#define HERRNO_UNSET -2
static int
-res_search_async_run(struct async *as, struct async_res *ar)
+res_search_async_run(struct asr_query *as, struct asr_result *ar)
{
int r;
char fqdn[MAXDNAME];
@@ -136,7 +136,7 @@ res_search_async_run(struct async *as, struct async_res *ar)
case ASR_STATE_SUBQUERY:
- if ((r = asr_async_run(as->as.search.subq, ar)) == ASYNC_COND)
+ if ((r = asr_run(as->as.search.subq, ar)) == ASYNC_COND)
return (ASYNC_COND);
as->as.search.subq = NULL;
@@ -241,7 +241,7 @@ enum {
* error generating the next name, or the resulting name length.
*/
int
-iter_domain(struct async *as, const char *name, char * buf, size_t len)
+iter_domain(struct asr_query *as, const char *name, char * buf, size_t len)
{
const char *c;
int dots;
diff --git a/contrib/lib/libc/asr/res_send.c b/contrib/lib/libc/asr/res_send.c
index 7c6152e2..b00510c4 100644
--- a/contrib/lib/libc/asr/res_send.c
+++ b/contrib/lib/libc/asr/res_send.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_send.c,v 1.6 2013/11/12 06:09:50 deraadt Exp $ */
+/* $OpenBSD: res_send.c,v 1.7 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -28,9 +28,9 @@
int
res_send(const u_char *buf, int buflen, u_char *ans, int anslen)
{
- struct async *as;
- struct async_res ar;
- size_t len;
+ struct asr_query *as;
+ struct asr_result ar;
+ size_t len;
res_init();
@@ -43,7 +43,7 @@ res_send(const u_char *buf, int buflen, u_char *ans, int anslen)
if (as == NULL)
return (-1); /* errno set */
- asr_async_run_sync(as, &ar);
+ asr_run_sync(as, &ar);
if (ar.ar_errno) {
errno = ar.ar_errno;
diff --git a/contrib/lib/libc/asr/res_send_async.c b/contrib/lib/libc/asr/res_send_async.c
index 76f9808f..d8eee859 100644
--- a/contrib/lib/libc/asr/res_send_async.c
+++ b/contrib/lib/libc/asr/res_send_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_send_async.c,v 1.19 2013/07/12 14:36:22 eric Exp $ */
+/* $OpenBSD: res_send_async.c,v 1.21 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -36,28 +36,28 @@
#define OP_QUERY (0)
-static int res_send_async_run(struct async *, struct async_res *);
+static int res_send_async_run(struct asr_query *, struct asr_result *);
static int sockaddr_connect(const struct sockaddr *, int);
-static int udp_send(struct async *);
-static int udp_recv(struct async *);
-static int tcp_write(struct async *);
-static int tcp_read(struct async *);
-static int validate_packet(struct async *);
-static int setup_query(struct async *, const char *, const char *, int, int);
-static int ensure_ibuf(struct async *, size_t);
-static int iter_ns(struct async *);
+static int udp_send(struct asr_query *);
+static int udp_recv(struct asr_query *);
+static int tcp_write(struct asr_query *);
+static int tcp_read(struct asr_query *);
+static int validate_packet(struct asr_query *);
+static int setup_query(struct asr_query *, const char *, const char *, int, int);
+static int ensure_ibuf(struct asr_query *, size_t);
+static int iter_ns(struct asr_query *);
#define AS_NS_SA(p) ((p)->as_ctx->ac_ns[(p)->as.dns.nsidx - 1])
-struct async *
-res_send_async(const unsigned char *buf, int buflen, struct asr *asr)
+struct asr_query *
+res_send_async(const unsigned char *buf, int buflen, void *asr)
{
- struct asr_ctx *ac;
- struct async *as;
- struct unpack p;
- struct header h;
- struct query q;
+ struct asr_ctx *ac;
+ struct asr_query *as;
+ struct asr_unpack p;
+ struct asr_dns_header h;
+ struct asr_dns_query q;
DPRINT_PACKET("asr: res_send_async()", buf, buflen);
@@ -99,14 +99,13 @@ res_send_async(const unsigned char *buf, int buflen, struct asr *asr)
/*
* Unlike res_query(), this version will actually return the packet
* if it has received a valid one (errno == 0) even if h_errno is
- * not NETDB_SUCCESS. So the packet *must* be freed if necessary
- * (ans == NULL).
+ * not NETDB_SUCCESS. So the packet *must* be freed if necessary.
*/
-struct async *
-res_query_async(const char *name, int class, int type, struct asr *asr)
+struct asr_query *
+res_query_async(const char *name, int class, int type, void *asr)
{
- struct asr_ctx *ac;
- struct async *as;
+ struct asr_ctx *ac;
+ struct asr_query *as;
DPRINT("asr: res_query_async(\"%s\", %i, %i)\n", name, class, type);
@@ -117,10 +116,10 @@ res_query_async(const char *name, int class, int type, struct asr *asr)
return (as);
}
-struct async *
+struct asr_query *
res_query_async_ctx(const char *name, int class, int type, struct asr_ctx *a_ctx)
{
- struct async *as;
+ struct asr_query *as;
DPRINT("asr: res_query_async_ctx(\"%s\", %i, %i)\n", name, class, type);
@@ -144,7 +143,7 @@ res_query_async_ctx(const char *name, int class, int type, struct asr_ctx *a_ctx
}
static int
-res_send_async_run(struct async *as, struct async_res *ar)
+res_send_async_run(struct asr_query *as, struct asr_result *ar)
{
next:
switch (as->as_state) {
@@ -182,7 +181,7 @@ res_send_async_run(struct async *as, struct async_res *ar)
break;
}
async_set_state(as, ASR_STATE_UDP_RECV);
- ar->ar_cond = ASYNC_READ;
+ ar->ar_cond = ASR_WANT_READ;
ar->ar_fd = as->as_fd;
ar->ar_timeout = as->as_timeout;
return (ASYNC_COND);
@@ -217,12 +216,12 @@ res_send_async_run(struct async *as, struct async_res *ar)
break;
case 0:
async_set_state(as, ASR_STATE_TCP_READ);
- ar->ar_cond = ASYNC_READ;
+ ar->ar_cond = ASR_WANT_READ;
ar->ar_fd = as->as_fd;
ar->ar_timeout = as->as_timeout;
return (ASYNC_COND);
case 1:
- ar->ar_cond = ASYNC_WRITE;
+ ar->ar_cond = ASR_WANT_WRITE;
ar->ar_fd = as->as_fd;
ar->ar_timeout = as->as_timeout;
return (ASYNC_COND);
@@ -243,7 +242,7 @@ res_send_async_run(struct async *as, struct async_res *ar)
async_set_state(as, ASR_STATE_PACKET);
break;
case 1:
- ar->ar_cond = ASYNC_READ;
+ ar->ar_cond = ASR_WANT_READ;
ar->ar_fd = as->as_fd;
ar->ar_timeout = as->as_timeout;
return (ASYNC_COND);
@@ -252,7 +251,7 @@ res_send_async_run(struct async *as, struct async_res *ar)
case ASR_STATE_PACKET:
- memmove(&ar->ar_sa.sa, AS_NS_SA(as), SA_LEN(AS_NS_SA(as)));
+ memmove(&ar->ar_ns, AS_NS_SA(as), SA_LEN(AS_NS_SA(as)));
ar->ar_datalen = as->as.dns.ibuflen;
ar->ar_data = as->as.dns.ibuf;
as->as.dns.ibuf = NULL;
@@ -345,13 +344,13 @@ sockaddr_connect(const struct sockaddr *sa, int socktype)
* Return 0 on success, set errno and return -1 on error.
*/
static int
-setup_query(struct async *as, const char *name, const char *dom,
+setup_query(struct asr_query *as, const char *name, const char *dom,
int class, int type)
{
- struct pack p;
- struct header h;
- char fqdn[MAXDNAME];
- char dname[MAXDNAME];
+ struct asr_pack p;
+ struct asr_dns_header h;
+ char fqdn[MAXDNAME];
+ char dname[MAXDNAME];
if (as->as.dns.flags & ASYNC_EXTOBUF) {
errno = EINVAL;
@@ -418,7 +417,7 @@ setup_query(struct async *as, const char *name, const char *dom,
* Return 0 on success, or -1 on error (errno set).
*/
static int
-udp_send(struct async *as)
+udp_send(struct asr_query *as)
{
ssize_t n;
int save_errno;
@@ -451,7 +450,7 @@ udp_send(struct async *as)
* Return 0 if a full packet could be read, or -1 on error (errno set).
*/
static int
-udp_recv(struct async *as)
+udp_recv(struct asr_query *as)
{
ssize_t n;
int save_errno;
@@ -489,7 +488,7 @@ udp_recv(struct async *as)
* socket or it is not connected yet, or -1 on error (errno set).
*/
static int
-tcp_write(struct async *as)
+tcp_write(struct asr_query *as)
{
struct msghdr msg;
struct iovec iov[2];
@@ -537,7 +536,7 @@ tcp_write(struct async *as)
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL SO_NOSIGPIPE
#endif
- n = sendmsg(as->as_fd, &msg, MSG_NOSIGNAL);
+ n = sendmsg(as->as_fd, &msg, MSG_NOSIGNAL);
if (n == -1) {
if (errno == EINTR)
goto send_again;
@@ -568,7 +567,7 @@ close:
* socket must be read again, or -1 on error (errno set).
*/
static int
-tcp_read(struct async *as)
+tcp_read(struct asr_query *as)
{
ssize_t n;
size_t offset, len;
@@ -647,7 +646,7 @@ close:
* extend it if necessary. Return 0 on success, or set errno and return -1.
*/
static int
-ensure_ibuf(struct async *as, size_t n)
+ensure_ibuf(struct asr_query *as, size_t n)
{
char *t;
@@ -676,13 +675,13 @@ ensure_ibuf(struct async *as, size_t n)
* Return 0 on success, or set errno and return -1.
*/
static int
-validate_packet(struct async *as)
+validate_packet(struct asr_query *as)
{
- struct unpack p;
- struct header h;
- struct query q;
- struct rr rr;
- int r;
+ struct asr_unpack p;
+ struct asr_dns_header h;
+ struct asr_dns_query q;
+ struct asr_dns_rr rr;
+ int r;
asr_unpack_init(&p, as->as.dns.ibuf, as->as.dns.ibuflen);
@@ -747,7 +746,7 @@ validate_packet(struct async *as)
* success, or -1 if all nameservers were used.
*/
static int
-iter_ns(struct async *as)
+iter_ns(struct asr_query *as)
{
for (;;) {
if (as->as.dns.nsloop >= as->as_ctx->ac_nsretries)