return 1;
}
#endif
-#ifdef AF_UNIX
+#ifndef OPENSSL_NO_UNIX_SOCK
if (sa->sa_family == AF_UNIX) {
memcpy(&(ap->s_un), sa, sizeof(struct sockaddr_un));
return 1;
const void *where, size_t wherelen,
unsigned short port)
{
-#ifdef AF_UNIX
+#ifndef OPENSSL_NO_UNIX_SOCK
if (family == AF_UNIX) {
if (wherelen + 1 > sizeof(ap->s_un.sun_path))
return 0;
addrptr = &ap->s_in6.sin6_addr;
}
#endif
-#ifdef AF_UNIX
+#ifndef OPENSSL_NO_UNIX_SOCK
else if (ap->sa.sa_family == AF_UNIX) {
len = strlen(ap->s_un.sun_path);
addrptr = &ap->s_un.sun_path;
char *BIO_ADDR_path_string(const BIO_ADDR *ap)
{
-#ifdef AF_UNIX
+#ifndef OPENSSL_NO_UNIX_SOCK
if (ap->sa.sa_family == AF_UNIX)
return OPENSSL_strdup(ap->s_un.sun_path);
#endif
if (ap->sa.sa_family == AF_INET6)
return sizeof(ap->s_in6);
#endif
-#ifdef AF_UNIX
+#ifndef OPENSSL_NO_UNIX_SOCK
if (ap->sa.sa_family == AF_UNIX)
return sizeof(ap->s_un);
#endif
if (bai->bai_protocol != 0)
return bai->bai_protocol;
-#ifdef AF_UNIX
+#ifndef OPENSSL_NO_UNIX_SOCK
if (bai->bai_family == AF_UNIX)
return 0;
#endif
return;
#ifdef AI_PASSIVE
-# ifdef AF_UNIX
+# ifndef OPENSSL_NO_UNIX_SOCK
# define _cond bai->bai_family != AF_UNIX
# else
# define _cond 1
(*bai)->bai_protocol = IPPROTO_TCP;
if (socktype == SOCK_DGRAM)
(*bai)->bai_protocol = IPPROTO_UDP;
-#ifdef AF_UNIX
+#ifndef OPENSSL_NO_UNIX_SOCK
if (family == AF_UNIX)
(*bai)->bai_protocol = 0;
#endif
#if OPENSSL_USE_IPV6
case AF_INET6:
#endif
-#ifdef AF_UNIX
+#ifndef OPENSSL_NO_UNIX_SOCK
case AF_UNIX:
#endif
#ifdef AF_UNSPEC
return 0;
}
-#ifdef AF_UNIX
+#ifndef OPENSSL_NO_UNIX_SOCK
if (family == AF_UNIX) {
if (addrinfo_wrap(family, socktype, host, strlen(host), 0, res))
return 1;
# include <inet.h>
# else
# include <sys/socket.h>
-# ifndef NO_SYS_UN_H
+# if !defined(NO_SYS_UN_H) && defined(AF_UNIX) && !defined(OPENSSL_NO_UNIX_SOCK)
# include <sys/un.h>
# ifndef UNIX_PATH_MAX
# define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path)
# endif
# endif
+/*
+ * Some platforms define AF_UNIX, but don't support it
+ */
+# if !defined(OPENSSL_NO_UNIX_SOCK)
+# if !defined(AF_UNIX) || defined(NO_SYS_UN_H)
+# define OPENSSL_NO_UNIX_SOCK
+# endif
+# endif
+
# define get_last_socket_error() errno
# define clear_socket_error() errno=0