From c590be7c6ead811f929041393a061e4068f35b00 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 27 Dec 2019 01:06:35 -0800 Subject: fixes #1051 nni_ntop is unused --- src/core/platform.h | 6 ----- src/platform/posix/posix_resolv_gai.c | 41 --------------------------------- src/platform/windows/win_resolv.c | 43 +---------------------------------- 3 files changed, 1 insertion(+), 89 deletions(-) (limited to 'src') 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 @@ -344,47 +344,6 @@ resolv_worker(void *notused) nni_mtx_unlock(&resolv_mtx); } -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) { 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. +// Copyright 2019 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -307,47 +307,6 @@ resolv_worker(void *notused) nni_mtx_unlock(&resolv_mtx); } -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) { -- cgit v1.2.3-70-g09d2