aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2016-08-09 14:00:41 -0700
committerGravatar murgatroid99 <mlumish@google.com>2016-08-09 14:00:41 -0700
commit31963632dc048d18f31d63101c0e5a6636aa98d7 (patch)
tree3b617736e26d3aa50b782c87ca53f86bfb9e6460 /src
parent0b110dd28d7a03a8f28cdbd112baf5998369d893 (diff)
Make usage of grpc_inet_ntop consistent
Diffstat (limited to 'src')
-rw-r--r--src/core/lib/iomgr/sockaddr_utils.c4
-rw-r--r--src/core/lib/iomgr/socket_utils.h2
-rw-r--r--src/core/lib/iomgr/socket_utils_common_posix.c4
-rw-r--r--src/core/lib/iomgr/socket_utils_windows.c5
4 files changed, 8 insertions, 7 deletions
diff --git a/src/core/lib/iomgr/sockaddr_utils.c b/src/core/lib/iomgr/sockaddr_utils.c
index 127d95c618..7f8e6ea3c3 100644
--- a/src/core/lib/iomgr/sockaddr_utils.c
+++ b/src/core/lib/iomgr/sockaddr_utils.c
@@ -42,6 +42,7 @@
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>
+#include "src/core/lib/iomgr/socket_utils.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
#include "src/core/lib/support/string.h"
@@ -155,9 +156,8 @@ int grpc_sockaddr_to_string(char **out, const struct sockaddr *addr,
ip = &addr6->sin6_addr;
port = ntohs(addr6->sin6_port);
}
- /* Windows inet_ntop wants a mutable ip pointer */
if (ip != NULL &&
- inet_ntop(addr->sa_family, (void *)ip, ntop_buf, sizeof(ntop_buf)) !=
+ grpc_inet_ntop(addr->sa_family, ip, ntop_buf, sizeof(ntop_buf)) !=
NULL) {
ret = gpr_join_host_port(out, ntop_buf, port);
} else {
diff --git a/src/core/lib/iomgr/socket_utils.h b/src/core/lib/iomgr/socket_utils.h
index 79903571a0..f0b5a33b63 100644
--- a/src/core/lib/iomgr/socket_utils.h
+++ b/src/core/lib/iomgr/socket_utils.h
@@ -43,7 +43,7 @@
#endif
/* A wrapper for inet_ntop on POSIX systems and InetNtop on Windows systems */
-const char *grpc_inet_ntop(int af, void *src,
+const char *grpc_inet_ntop(int af, const void *src,
char *dst, socklen_t size);
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H */
diff --git a/src/core/lib/iomgr/socket_utils_common_posix.c b/src/core/lib/iomgr/socket_utils_common_posix.c
index 42ee76d2fe..2143256846 100644
--- a/src/core/lib/iomgr/socket_utils_common_posix.c
+++ b/src/core/lib/iomgr/socket_utils_common_posix.c
@@ -297,9 +297,9 @@ grpc_error *grpc_create_dualstack_socket(const struct sockaddr *addr, int type,
return error_for_fd(*newfd, addr);
}
-const char *grpc_inet_ntop(int af, void *src,
+const char *grpc_inet_ntop(int af, const void *src,
char *dst, socklen_t size) {
- return inet_ntop(af, (const void*)src, dst, size);
+ return inet_ntop(af, src, dst, size);
}
#endif
diff --git a/src/core/lib/iomgr/socket_utils_windows.c b/src/core/lib/iomgr/socket_utils_windows.c
index c1dfc6e96f..41e53bd812 100644
--- a/src/core/lib/iomgr/socket_utils_windows.c
+++ b/src/core/lib/iomgr/socket_utils_windows.c
@@ -39,10 +39,11 @@
#include <grpc/support/log.h>
-const char *grpc_inet_ntop(int af, void *src,
+const char *grpc_inet_ntop(int af, const void *src,
char *dst, socklen_t size) {
GPR_ASSERT(sizeof(socklen_t) <= sizeof(size_t));
- return InetNtopA(af, src, dst, (size_t)size);
+ /* Windows InetNtopA wants a mutable ip pointer */
+ return InetNtopA(af, (void*)src, dst, (size_t)size);
}
#endif /* GRPC_WINDOWS_SOCKETUTILS */