From 82c70435ec9be9c607de4fbd62d4de9ae7d7c081 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 6 Jul 2017 13:34:20 -0700 Subject: Initial swag at asynchronous name resolution. --- src/core/aio.h | 6 +++--- src/core/defs.h | 6 ++++-- src/core/platform.h | 9 +++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/aio.h b/src/core/aio.h index d3c238f6..ee2b084e 100644 --- a/src/core/aio.h +++ b/src/core/aio.h @@ -39,12 +39,12 @@ struct nni_aio { nni_msg * a_msg; // Connect/accept operations. - nni_sockaddr * a_remaddr; - nni_sockaddr * a_locaddr; void * a_endpt; // opaque endpoint handle void * a_pipe; // opaque pipe handle - // TBD: Resolver operations. + // Resolver operations. + nni_sockaddr * a_addrs; + int a_naddrs; // Provider-use fields. void (*a_prov_cancel)(nni_aio *); diff --git a/src/core/defs.h b/src/core/defs.h index 1c44e9af..5db68c1c 100644 --- a/src/core/defs.h +++ b/src/core/defs.h @@ -72,8 +72,10 @@ typedef struct { #define NNI_SECOND (1000000) // Structure allocation conveniences. -#define NNI_ALLOC_STRUCT(s) nni_alloc(sizeof (*s)) -#define NNI_FREE_STRUCT(s) nni_free((s), sizeof (*s)) +#define NNI_ALLOC_STRUCT(s) nni_alloc(sizeof (*s)) +#define NNI_FREE_STRUCT(s) nni_free((s), sizeof (*s)) +#define NNI_ALLOC_STRUCTS(s, n) nni_alloc(sizeof (*s) * n) +#define NNI_FREE_STRUCTS(s, n) nni_free(s, sizeof (*s) * n) #define NNI_PUT16(ptr, u) \ do { \ diff --git a/src/core/platform.h b/src/core/platform.h index 971c6a5d..0dcab40a 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -242,6 +242,15 @@ extern void nni_plat_tcp_aio_send(nni_plat_tcpsock *, nni_aio *); // full, or an error condition occurs. extern void nni_plat_tcp_aio_recv(nni_plat_tcpsock *, nni_aio *); +// nni_plat_tcp_resolv resolves a TCP name asynchronously. The family +// should be one of NNG_AF_INET, NNG_AF_INET6, or NNG_AF_UNSPEC. The +// first two constrain the name to those families, while the third will +// return names of either family. The passive flag indicates that the +// name will be used for bind(), otherwise the name will be used with +// connect(). The host part may be NULL only if passive is true. +extern void nni_plat_tcp_resolv(const char *, const char *, int, int, + nni_aio *); + // // IPC (UNIX Domain Sockets & Named Pipes) Support. // -- cgit v1.2.3-70-g09d2