diff options
| author | Garrett D'Amore <garrett@damore.org> | 2019-12-27 01:06:35 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2019-12-27 01:06:35 -0800 |
| commit | c590be7c6ead811f929041393a061e4068f35b00 (patch) | |
| tree | 967b495c0a0865996f2b849b6b475a4beb67a1a0 | |
| parent | 1bb46ca346e666fd9c60e7be06ef7a1c927ca2f1 (diff) | |
| download | nng-c590be7c6ead811f929041393a061e4068f35b00.tar.gz nng-c590be7c6ead811f929041393a061e4068f35b00.tar.bz2 nng-c590be7c6ead811f929041393a061e4068f35b00.zip | |
fixes #1051 nni_ntop is unused
| -rw-r--r-- | src/core/platform.h | 6 | ||||
| -rw-r--r-- | src/platform/posix/posix_resolv_gai.c | 41 | ||||
| -rw-r--r-- | src/platform/windows/win_resolv.c | 43 |
3 files changed, 1 insertions, 89 deletions
diff --git a/src/core/platform.h b/src/core/platform.h index 65d9af82..b1d76899 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -294,12 +294,6 @@ extern int nni_tcp_listener_setopt( extern int nni_tcp_listener_getopt( nni_tcp_listener *, const char *, void *, size_t *, nni_type); -// nni_ntop obtains the IP address for the socket (enclosing it -// in brackets if it is IPv6) and port. Enough space for both must -// be present (48 bytes and 6 bytes each), although if either is NULL then -// those components are skipped. This is based on inet_ntop. -extern int nni_ntop(const nni_sockaddr *, char *, char *); - // nni_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 diff --git a/src/platform/posix/posix_resolv_gai.c b/src/platform/posix/posix_resolv_gai.c index b082eac6..9e577403 100644 --- a/src/platform/posix/posix_resolv_gai.c +++ b/src/platform/posix/posix_resolv_gai.c @@ -345,47 +345,6 @@ resolv_worker(void *notused) } int -nni_ntop(const nni_sockaddr *sa, char *ipstr, char *portstr) -{ - const void *ap; - uint16_t port; - int af; - switch (sa->s_family) { - case NNG_AF_INET: - ap = &sa->s_in.sa_addr; - port = sa->s_in.sa_port; - af = AF_INET; - break; - case NNG_AF_INET6: - ap = &sa->s_in6.sa_addr; - port = sa->s_in6.sa_port; - af = AF_INET6; - break; - default: - return (NNG_EINVAL); - } - if (ipstr != NULL) { - if (af == AF_INET6) { - size_t l; - ipstr[0] = '['; - inet_ntop(af, ap, ipstr + 1, INET6_ADDRSTRLEN); - l = strlen(ipstr); - ipstr[l++] = ']'; - ipstr[l++] = '\0'; - } else { - inet_ntop(af, ap, ipstr, INET6_ADDRSTRLEN); - } - } - if (portstr != NULL) { -#ifdef NNG_LITTLE_ENDIAN - port = ((port >> 8) & 0xff) | ((port & 0xff) << 8); -#endif - snprintf(portstr, 6, "%u", port); - } - return (0); -} - -int nni_posix_resolv_sysinit(void) { nni_mtx_init(&resolv_mtx); diff --git a/src/platform/windows/win_resolv.c b/src/platform/windows/win_resolv.c index e01dba3b..53a39118 100644 --- a/src/platform/windows/win_resolv.c +++ b/src/platform/windows/win_resolv.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -308,47 +308,6 @@ resolv_worker(void *notused) } int -nni_ntop(const nni_sockaddr *sa, char *ipstr, char *portstr) -{ - void * ap; - uint16_t port; - int af; - switch (sa->s_family) { - case NNG_AF_INET: - ap = (void *) &sa->s_in.sa_addr; - port = sa->s_in.sa_port; - af = AF_INET; - break; - case NNG_AF_INET6: - ap = (void *) &sa->s_in6.sa_addr; - port = sa->s_in6.sa_port; - af = AF_INET6; - break; - default: - return (NNG_EINVAL); - } - if (ipstr != NULL) { - if (af == AF_INET6) { - size_t l; - ipstr[0] = '['; - InetNtopA(af, ap, ipstr + 1, INET6_ADDRSTRLEN); - l = strlen(ipstr); - ipstr[l++] = ']'; - ipstr[l++] = '\0'; - } else { - InetNtopA(af, ap, ipstr, INET6_ADDRSTRLEN); - } - } - if (portstr != NULL) { -#ifdef NNG_LITTLE_ENDIAN - port = ((port >> 8) & 0xff) | ((port & 0xff) << 8); -#endif - snprintf(portstr, 6, "%u", port); - } - return (0); -} - -int nni_win_resolv_sysinit(void) { nni_mtx_init(&resolv_mtx); |
