move unix socket functionality to unix_sockets_posix module
diff --git a/src/core/iomgr/sockaddr_utils.c b/src/core/iomgr/sockaddr_utils.c
index 3d464a2..667ab01 100644
--- a/src/core/iomgr/sockaddr_utils.c
+++ b/src/core/iomgr/sockaddr_utils.c
@@ -36,16 +36,13 @@
#include <errno.h>
#include <string.h>
-#ifdef GPR_HAVE_UNIX_SOCKET
-#include <sys/un.h>
-#endif
-
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>
+#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
static const uint8_t kV4MappedPrefix[] = {0, 0, 0, 0, 0, 0,
@@ -191,14 +188,9 @@
gpr_asprintf(&result, "ipv6:%s", temp);
gpr_free(temp);
return result;
-#ifdef GPR_HAVE_UNIX_SOCKET
- case AF_UNIX:
- gpr_asprintf(&result, "unix:%s", ((struct sockaddr_un *)addr)->sun_path);
- return result;
-#endif
+ default:
+ return grpc_sockaddr_to_uri_unix_if_possible(addr);
}
-
- return NULL;
}
int grpc_sockaddr_get_port(const struct sockaddr *addr) {
@@ -207,11 +199,10 @@
return ntohs(((struct sockaddr_in *)addr)->sin_port);
case AF_INET6:
return ntohs(((struct sockaddr_in6 *)addr)->sin6_port);
-#ifdef GPR_HAVE_UNIX_SOCKET
- case AF_UNIX:
- return 1;
-#endif
default:
+ if (grpc_is_unix_socket(addr->sa_family)) {
+ return 1;
+ }
gpr_log(GPR_ERROR, "Unknown socket family %d in grpc_sockaddr_get_port",
addr->sa_family);
return 0;