mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
parent
9334d900e5
commit
dc590c7d0a
15 changed files with 179 additions and 23 deletions
27
configure.ac
27
configure.ac
|
|
@ -1087,6 +1087,27 @@ AC_SUBST(POLKIT_LIBS)
|
|||
AC_SUBST(HAVE_POLKIT)
|
||||
AM_CONDITIONAL([HAVE_POLKIT], [test "x$HAVE_POLKIT" = x1])
|
||||
|
||||
|
||||
### IPv6 connection support (optional) ###
|
||||
|
||||
AC_ARG_ENABLE([ipv6],
|
||||
AS_HELP_STRING([--disable-ipv6],[Disable optional IPv6 support]),
|
||||
[
|
||||
case "${enableval}" in
|
||||
yes) ipv6=yes ;;
|
||||
no) ipv6=no ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for --disable-ipv6) ;;
|
||||
esac
|
||||
],
|
||||
[ipv6=auto])
|
||||
|
||||
if test "x${ipv6}" != xno ; then
|
||||
AC_DEFINE([HAVE_IPV6], [1], [Define this to enable IPv6 connection support])
|
||||
HAVE_IPV6=1
|
||||
else
|
||||
HAVE_IPV6=0
|
||||
fi
|
||||
|
||||
#### OpenSSL support (optional) ####
|
||||
|
||||
AC_ARG_ENABLE([openssl],
|
||||
|
|
@ -1333,6 +1354,11 @@ if test "x${HAVE_OPENSSL}" = "x1" ; then
|
|||
ENABLE_OPENSSL=yes
|
||||
fi
|
||||
|
||||
ENABLE_IPV6=no
|
||||
if test "x${HAVE_IPV6}" = "x1" ; then
|
||||
ENABLE_IPV6=yes
|
||||
fi
|
||||
|
||||
ENABLE_PER_USER_ESOUND_SOCKET=no
|
||||
if test "x$per_user_esound_socket" = "x1" ; then
|
||||
ENABLE_PER_USER_ESOUND_SOCKET=yes
|
||||
|
|
@ -1366,6 +1392,7 @@ echo "
|
|||
Enable TCP Wrappers: ${ENABLE_TCPWRAP}
|
||||
Enable libsamplerate: ${ENABLE_LIBSAMPLERATE}
|
||||
Enable PolicyKit: ${ENABLE_POLKIT}
|
||||
Enable IPv6: ${ENABLE_IPV6}
|
||||
Enable OpenSSL (for Airtunes): ${ENABLE_OPENSSL}
|
||||
|
||||
System User: ${PA_SYSTEM_USER}
|
||||
|
|
|
|||
|
|
@ -211,7 +211,9 @@ struct userdata {
|
|||
|
||||
#if defined(USE_TCP_SOCKETS)
|
||||
pa_socket_server *socket_server_ipv4;
|
||||
# ifdef HAVE_IPV6
|
||||
pa_socket_server *socket_server_ipv6;
|
||||
# endif
|
||||
#else
|
||||
pa_socket_server *socket_server_unix;
|
||||
char *socket_path;
|
||||
|
|
@ -299,20 +301,30 @@ int pa__init(pa_module*m) {
|
|||
listen_on = pa_modargs_get_value(ma, "listen", NULL);
|
||||
|
||||
if (listen_on) {
|
||||
# ifdef HAVE_IPV6
|
||||
u->socket_server_ipv6 = pa_socket_server_new_ipv6_string(m->core->mainloop, listen_on, (uint16_t) port, TCPWRAP_SERVICE);
|
||||
# endif
|
||||
u->socket_server_ipv4 = pa_socket_server_new_ipv4_string(m->core->mainloop, listen_on, (uint16_t) port, TCPWRAP_SERVICE);
|
||||
} else {
|
||||
# ifdef HAVE_IPV6
|
||||
u->socket_server_ipv6 = pa_socket_server_new_ipv6_any(m->core->mainloop, (uint16_t) port, TCPWRAP_SERVICE);
|
||||
# endif
|
||||
u->socket_server_ipv4 = pa_socket_server_new_ipv4_any(m->core->mainloop, (uint16_t) port, TCPWRAP_SERVICE);
|
||||
}
|
||||
|
||||
# ifdef HAVE_IPV6
|
||||
if (!u->socket_server_ipv4 && !u->socket_server_ipv6)
|
||||
# else
|
||||
if (!u->socket_server_ipv4)
|
||||
# endif
|
||||
goto fail;
|
||||
|
||||
if (u->socket_server_ipv4)
|
||||
pa_socket_server_set_callback(u->socket_server_ipv4, socket_server_on_connection_cb, u);
|
||||
# ifdef HAVE_IPV6
|
||||
if (u->socket_server_ipv6)
|
||||
pa_socket_server_set_callback(u->socket_server_ipv6, socket_server_on_connection_cb, u);
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
|
|
@ -358,9 +370,11 @@ int pa__init(pa_module*m) {
|
|||
if (pa_socket_server_get_address(u->socket_server_ipv4, t, sizeof(t)))
|
||||
pa_native_protocol_add_server_string(u->native_protocol, t);
|
||||
|
||||
# ifdef HAVE_IPV6
|
||||
if (u->socket_server_ipv6)
|
||||
if (pa_socket_server_get_address(u->socket_server_ipv6, t, sizeof(t)))
|
||||
pa_native_protocol_add_server_string(u->native_protocol, t);
|
||||
# endif
|
||||
# else
|
||||
if (pa_socket_server_get_address(u->socket_server_unix, t, sizeof(t)))
|
||||
pa_native_protocol_add_server_string(u->native_protocol, t);
|
||||
|
|
@ -418,9 +432,11 @@ void pa__done(pa_module*m) {
|
|||
if (pa_socket_server_get_address(u->socket_server_ipv4, t, sizeof(t)))
|
||||
pa_native_protocol_remove_server_string(u->native_protocol, t);
|
||||
|
||||
# ifdef HAVE_IPV6
|
||||
if (u->socket_server_ipv6)
|
||||
if (pa_socket_server_get_address(u->socket_server_ipv6, t, sizeof(t)))
|
||||
pa_native_protocol_remove_server_string(u->native_protocol, t);
|
||||
# endif
|
||||
# else
|
||||
if (u->socket_server_unix)
|
||||
if (pa_socket_server_get_address(u->socket_server_unix, t, sizeof(t)))
|
||||
|
|
@ -444,8 +460,10 @@ void pa__done(pa_module*m) {
|
|||
#if defined(USE_TCP_SOCKETS)
|
||||
if (u->socket_server_ipv4)
|
||||
pa_socket_server_unref(u->socket_server_ipv4);
|
||||
# ifdef HAVE_IPV6
|
||||
if (u->socket_server_ipv6)
|
||||
pa_socket_server_unref(u->socket_server_ipv6);
|
||||
# endif
|
||||
#else
|
||||
if (u->socket_server_unix)
|
||||
pa_socket_server_unref(u->socket_server_unix);
|
||||
|
|
|
|||
|
|
@ -373,11 +373,13 @@ static int mcast_socket(const struct sockaddr* sa, socklen_t salen) {
|
|||
memset(&mr4, 0, sizeof(mr4));
|
||||
mr4.imr_multiaddr = ((const struct sockaddr_in*) sa)->sin_addr;
|
||||
r = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mr4, sizeof(mr4));
|
||||
#ifdef HAVE_IPV6
|
||||
} else {
|
||||
struct ipv6_mreq mr6;
|
||||
memset(&mr6, 0, sizeof(mr6));
|
||||
mr6.ipv6mr_multiaddr = ((const struct sockaddr_in6*) sa)->sin6_addr;
|
||||
r = setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mr6, sizeof(mr6));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (r < 0) {
|
||||
|
|
@ -608,7 +610,9 @@ int pa__init(pa_module*m) {
|
|||
struct userdata *u;
|
||||
pa_modargs *ma = NULL;
|
||||
struct sockaddr_in sa4;
|
||||
#ifdef HAVE_IPV6
|
||||
struct sockaddr_in6 sa6;
|
||||
#endif
|
||||
struct sockaddr *sa;
|
||||
socklen_t salen;
|
||||
const char *sap_address;
|
||||
|
|
@ -624,16 +628,18 @@ int pa__init(pa_module*m) {
|
|||
|
||||
sap_address = pa_modargs_get_value(ma, "sap_address", DEFAULT_SAP_ADDRESS);
|
||||
|
||||
if (inet_pton(AF_INET6, sap_address, &sa6.sin6_addr) > 0) {
|
||||
sa6.sin6_family = AF_INET6;
|
||||
sa6.sin6_port = htons(SAP_PORT);
|
||||
sa = (struct sockaddr*) &sa6;
|
||||
salen = sizeof(sa6);
|
||||
} else if (inet_pton(AF_INET, sap_address, &sa4.sin_addr) > 0) {
|
||||
if (inet_pton(AF_INET, sap_address, &sa4.sin_addr) > 0) {
|
||||
sa4.sin_family = AF_INET;
|
||||
sa4.sin_port = htons(SAP_PORT);
|
||||
sa = (struct sockaddr*) &sa4;
|
||||
salen = sizeof(sa4);
|
||||
#ifdef HAVE_IPV6
|
||||
} else if (inet_pton(AF_INET6, sap_address, &sa6.sin6_addr) > 0) {
|
||||
sa6.sin6_family = AF_INET6;
|
||||
sa6.sin6_port = htons(SAP_PORT);
|
||||
sa = (struct sockaddr*) &sa6;
|
||||
salen = sizeof(sa6);
|
||||
#endif
|
||||
} else {
|
||||
pa_log("Invalid SAP address '%s'", sap_address);
|
||||
goto fail;
|
||||
|
|
|
|||
|
|
@ -177,7 +177,9 @@ int pa__init(pa_module*m) {
|
|||
pa_sample_spec ss;
|
||||
pa_channel_map cm;
|
||||
struct sockaddr_in sa4, sap_sa4;
|
||||
#ifdef HAVE_IPV6
|
||||
struct sockaddr_in6 sa6, sap_sa6;
|
||||
#endif
|
||||
struct sockaddr_storage sa_dst;
|
||||
pa_source_output *o = NULL;
|
||||
uint8_t payload;
|
||||
|
|
@ -247,16 +249,18 @@ int pa__init(pa_module*m) {
|
|||
|
||||
dest = pa_modargs_get_value(ma, "destination", DEFAULT_DESTINATION);
|
||||
|
||||
if (inet_pton(AF_INET6, dest, &sa6.sin6_addr) > 0) {
|
||||
sa6.sin6_family = af = AF_INET6;
|
||||
sa6.sin6_port = htons((uint16_t) port);
|
||||
sap_sa6 = sa6;
|
||||
sap_sa6.sin6_port = htons(SAP_PORT);
|
||||
} else if (inet_pton(AF_INET, dest, &sa4.sin_addr) > 0) {
|
||||
if (inet_pton(AF_INET, dest, &sa4.sin_addr) > 0) {
|
||||
sa4.sin_family = af = AF_INET;
|
||||
sa4.sin_port = htons((uint16_t) port);
|
||||
sap_sa4 = sa4;
|
||||
sap_sa4.sin_port = htons(SAP_PORT);
|
||||
#ifdef HAVE_IPV6
|
||||
} else if (inet_pton(AF_INET6, dest, &sa6.sin6_addr) > 0) {
|
||||
sa6.sin6_family = af = AF_INET6;
|
||||
sa6.sin6_port = htons((uint16_t) port);
|
||||
sap_sa6 = sa6;
|
||||
sap_sa6.sin6_port = htons(SAP_PORT);
|
||||
#endif
|
||||
} else {
|
||||
pa_log("Invalid destination '%s'", dest);
|
||||
goto fail;
|
||||
|
|
@ -267,9 +271,14 @@ int pa__init(pa_module*m) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (connect(fd, af == AF_INET ? (struct sockaddr*) &sa4 : (struct sockaddr*) &sa6, (socklen_t) (af == AF_INET ? sizeof(sa4) : sizeof(sa6))) < 0) {
|
||||
if (af == AF_INET && connect(fd, (struct sockaddr*) &sa4, sizeof(sa4)) < 0) {
|
||||
pa_log("connect() failed: %s", pa_cstrerror(errno));
|
||||
goto fail;
|
||||
#ifdef HAVE_IPV6
|
||||
} else if (af == AF_INET6 && connect(fd, (struct sockaddr*) &sa6, sizeof(sa6)) < 0) {
|
||||
pa_log("connect() failed: %s", pa_cstrerror(errno));
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((sap_fd = socket(af, SOCK_DGRAM, 0)) < 0) {
|
||||
|
|
@ -277,9 +286,14 @@ int pa__init(pa_module*m) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (connect(sap_fd, af == AF_INET ? (struct sockaddr*) &sap_sa4 : (struct sockaddr*) &sap_sa6, (socklen_t) (af == AF_INET ? sizeof(sap_sa4) : sizeof(sap_sa6))) < 0) {
|
||||
if (af == AF_INET && connect(sap_fd, (struct sockaddr*) &sap_sa4, sizeof(sap_sa4)) < 0) {
|
||||
pa_log("connect() failed: %s", pa_cstrerror(errno));
|
||||
goto fail;
|
||||
#ifdef HAVE_IPV6
|
||||
} else if (af == AF_INET6 && connect(sap_fd, (struct sockaddr*) &sap_sa6, sizeof(sap_sa6)) < 0) {
|
||||
pa_log("connect() failed: %s", pa_cstrerror(errno));
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
|
||||
j = !!loop;
|
||||
|
|
@ -357,10 +371,19 @@ int pa__init(pa_module*m) {
|
|||
|
||||
n = pa_sprintf_malloc("PulseAudio RTP Stream on %s", pa_get_fqdn(hn, sizeof(hn)));
|
||||
|
||||
p = pa_sdp_build(af,
|
||||
af == AF_INET ? (void*) &((struct sockaddr_in*) &sa_dst)->sin_addr : (void*) &((struct sockaddr_in6*) &sa_dst)->sin6_addr,
|
||||
af == AF_INET ? (void*) &sa4.sin_addr : (void*) &sa6.sin6_addr,
|
||||
if (af == AF_INET) {
|
||||
p = pa_sdp_build(af,
|
||||
(void*) &((struct sockaddr_in*) &sa_dst)->sin_addr,
|
||||
(void*) &sa4.sin_addr,
|
||||
n, (uint16_t) port, payload, &ss);
|
||||
#ifdef HAVE_IPV6
|
||||
} else {
|
||||
p = pa_sdp_build(af,
|
||||
(void*) &((struct sockaddr_in6*) &sa_dst)->sin6_addr,
|
||||
(void*) &sa6.sin6_addr,
|
||||
n, (uint16_t) port, payload, &ss);
|
||||
#endif
|
||||
}
|
||||
|
||||
pa_xfree(n);
|
||||
|
||||
|
|
|
|||
|
|
@ -87,18 +87,31 @@ int pa_sap_send(pa_sap_context *c, pa_bool_t goodbye) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
pa_assert(sa->sa_family == AF_INET || sa->sa_family == AF_INET6);
|
||||
#else
|
||||
pa_assert(sa->sa_family == AF_INET);
|
||||
#endif
|
||||
|
||||
header = htonl(((uint32_t) 1 << 29) |
|
||||
#ifdef HAVE_IPV6
|
||||
(sa->sa_family == AF_INET6 ? (uint32_t) 1 << 28 : 0) |
|
||||
#endif
|
||||
(goodbye ? (uint32_t) 1 << 26 : 0) |
|
||||
(c->msg_id_hash));
|
||||
|
||||
iov[0].iov_base = &header;
|
||||
iov[0].iov_len = sizeof(header);
|
||||
|
||||
iov[1].iov_base = sa->sa_family == AF_INET ? (void*) &((struct sockaddr_in*) sa)->sin_addr : (void*) &((struct sockaddr_in6*) sa)->sin6_addr;
|
||||
iov[1].iov_len = sa->sa_family == AF_INET ? 4U : 16U;
|
||||
if (sa->sa_family == AF_INET) {
|
||||
iov[1].iov_base = (void*) &((struct sockaddr_in*) sa)->sin_addr;
|
||||
iov[1].iov_len = 4U;
|
||||
#ifdef HAVE_IPV6
|
||||
} else {
|
||||
iov[1].iov_base = (void*) &((struct sockaddr_in6*) sa)->sin6_addr;
|
||||
iov[1].iov_len = 16U;
|
||||
#endif
|
||||
}
|
||||
|
||||
iov[2].iov_base = (char*) MIME_TYPE;
|
||||
iov[2].iov_len = sizeof(MIME_TYPE);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,12 @@ char *pa_sdp_build(int af, const void *src, const void *dst, const char *name, u
|
|||
|
||||
pa_assert(src);
|
||||
pa_assert(dst);
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
pa_assert(af == AF_INET || af == AF_INET6);
|
||||
#else
|
||||
pa_assert(af == AF_INET);
|
||||
#endif
|
||||
|
||||
pa_assert_se(f = pa_rtp_format_to_string(ss->format));
|
||||
|
||||
|
|
@ -162,6 +167,7 @@ pa_sdp_info *pa_sdp_parse(const char *t, pa_sdp_info *i, int is_goodbye) {
|
|||
((struct sockaddr_in*) &i->sa)->sin_family = AF_INET;
|
||||
((struct sockaddr_in*) &i->sa)->sin_port = 0;
|
||||
i->salen = sizeof(struct sockaddr_in);
|
||||
#ifdef HAVE_IPV6
|
||||
} else if (pa_startswith(t, "c=IN IP6 ")) {
|
||||
char a[64];
|
||||
size_t k;
|
||||
|
|
@ -179,6 +185,7 @@ pa_sdp_info *pa_sdp_parse(const char *t, pa_sdp_info *i, int is_goodbye) {
|
|||
((struct sockaddr_in6*) &i->sa)->sin6_family = AF_INET6;
|
||||
((struct sockaddr_in6*) &i->sa)->sin6_port = 0;
|
||||
i->salen = sizeof(struct sockaddr_in6);
|
||||
#endif
|
||||
} else if (pa_startswith(t, "m=audio ")) {
|
||||
|
||||
if (i->payload > 127) {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@
|
|||
|
||||
const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) {
|
||||
struct in_addr *in = (struct in_addr*)src;
|
||||
#ifdef HAVE_IPV6
|
||||
struct in6_addr *in6 = (struct in6_addr*)src;
|
||||
#endif
|
||||
|
||||
assert(src && dst);
|
||||
|
||||
|
|
@ -57,6 +59,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) {
|
|||
(int)(in->s_addr >> 24) & 0xff);
|
||||
#endif
|
||||
break;
|
||||
#ifdef HAVE_IPV6
|
||||
case AF_INET6:
|
||||
pa_snprintf(dst, cnt, "%x:%x:%x:%x:%x:%x:%x:%x",
|
||||
in6->s6_addr[ 0] << 8 | in6->s6_addr[ 1],
|
||||
|
|
@ -68,6 +71,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) {
|
|||
in6->s6_addr[12] << 8 | in6->s6_addr[13],
|
||||
in6->s6_addr[14] << 8 | in6->s6_addr[15]);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
errno = EAFNOSUPPORT;
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@
|
|||
|
||||
int inet_pton(int af, const char *src, void *dst) {
|
||||
struct in_addr *in = (struct in_addr*)dst;
|
||||
#ifdef HAVE_IPV6
|
||||
struct in6_addr *in6 = (struct in6_addr*)dst;
|
||||
#endif
|
||||
|
||||
assert(src && dst);
|
||||
|
||||
|
|
@ -48,8 +50,10 @@ int inet_pton(int af, const char *src, void *dst) {
|
|||
if (in->s_addr == INADDR_NONE)
|
||||
return 0;
|
||||
break;
|
||||
#ifdef HAVE_IPV6
|
||||
case AF_INET6:
|
||||
/* FIXME */
|
||||
#endif
|
||||
default:
|
||||
errno = EAFNOSUPPORT;
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,9 @@ struct acl_entry {
|
|||
PA_LLIST_FIELDS(struct acl_entry);
|
||||
int family;
|
||||
struct in_addr address_ipv4;
|
||||
#ifdef HAVE_IPV6
|
||||
struct in6_addr address_ipv6;
|
||||
#endif
|
||||
int bits;
|
||||
};
|
||||
|
||||
|
|
@ -109,6 +111,7 @@ pa_ip_acl* pa_ip_acl_new(const char *s) {
|
|||
if (e.bits < 32 && (uint32_t) (ntohl(e.address_ipv4.s_addr) << e.bits) != 0)
|
||||
pa_log_warn("Host part of ACL entry '%s/%u' is not zero!", a, e.bits);
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
} else if (inet_pton(AF_INET6, a, &e.address_ipv6) > 0) {
|
||||
|
||||
e.bits = bits == (uint32_t) -1 ? 128 : (int) bits;
|
||||
|
|
@ -138,6 +141,7 @@ pa_ip_acl* pa_ip_acl_new(const char *s) {
|
|||
if (t)
|
||||
pa_log_warn("Host part of ACL entry '%s/%u' is not zero!", a, e.bits);
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
pa_log_warn("Failed to parse address: %s", a);
|
||||
|
|
@ -183,14 +187,20 @@ int pa_ip_acl_check(pa_ip_acl *acl, int fd) {
|
|||
if (getpeername(fd, (struct sockaddr*) &sa, &salen) < 0)
|
||||
return -1;
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
if (sa.ss_family != AF_INET && sa.ss_family != AF_INET6)
|
||||
#else
|
||||
if (sa.ss_family != AF_INET)
|
||||
#endif
|
||||
return -1;
|
||||
|
||||
if (sa.ss_family == AF_INET && salen != sizeof(struct sockaddr_in))
|
||||
return -1;
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
if (sa.ss_family == AF_INET6 && salen != sizeof(struct sockaddr_in6))
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
for (e = acl->entries; e; e = e->next) {
|
||||
|
||||
|
|
@ -203,6 +213,7 @@ int pa_ip_acl_check(pa_ip_acl *acl, int fd) {
|
|||
if (e->bits == 0 || /* this needs special handling because >> takes the right-hand side modulo 32 */
|
||||
(ntohl(sai->sin_addr.s_addr ^ e->address_ipv4.s_addr) >> (32 - e->bits)) == 0)
|
||||
return 1;
|
||||
#ifdef HAVE_IPV6
|
||||
} else if (e->family == AF_INET6) {
|
||||
int i, bits ;
|
||||
struct sockaddr_in6 *sai = (struct sockaddr_in6*) &sa;
|
||||
|
|
@ -230,6 +241,7 @@ int pa_ip_acl_check(pa_ip_acl *acl, int fd) {
|
|||
if (bits == 0)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -278,7 +278,11 @@ static int sockaddr_prepare(pa_socket_client *c, const struct sockaddr *sa, size
|
|||
|
||||
pa_make_fd_cloexec(c->fd);
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
if (sa->sa_family == AF_INET || sa->sa_family == AF_INET6)
|
||||
#else
|
||||
if (sa->sa_family == AF_INET)
|
||||
#endif
|
||||
pa_make_tcp_socket_low_delay(c->fd);
|
||||
else
|
||||
pa_make_socket_low_delay(c->fd);
|
||||
|
|
@ -353,6 +357,7 @@ void pa_socket_client_set_callback(pa_socket_client *c, pa_socket_client_cb_t on
|
|||
c->userdata = userdata;
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
pa_socket_client* pa_socket_client_new_ipv6(pa_mainloop_api *m, uint8_t address[16], uint16_t port) {
|
||||
struct sockaddr_in6 sa;
|
||||
|
||||
|
|
@ -367,6 +372,7 @@ pa_socket_client* pa_socket_client_new_ipv6(pa_mainloop_api *m, uint8_t address[
|
|||
|
||||
return pa_socket_client_new_sockaddr(m, (struct sockaddr*) &sa, sizeof(sa));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBASYNCNS
|
||||
|
||||
|
|
@ -470,7 +476,15 @@ pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, const char*nam
|
|||
pa_snprintf(port, sizeof(port), "%u", (unsigned) a.port);
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = a.type == PA_PARSED_ADDRESS_TCP4 ? PF_INET : (a.type == PA_PARSED_ADDRESS_TCP6 ? PF_INET6 : PF_UNSPEC);
|
||||
if (a.type == PA_PARSED_ADDRESS_TCP4)
|
||||
hints.ai_family = PF_INET;
|
||||
#ifdef HAVE_IPV6
|
||||
else if (a.type == PA_PARSED_ADDRESS_TCP6)
|
||||
hints.ai_family = PF_INET6;
|
||||
#endif
|
||||
else
|
||||
hints.ai_family = PF_UNSPEC;
|
||||
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
#if defined(HAVE_LIBASYNCNS)
|
||||
|
|
@ -509,11 +523,13 @@ pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, const char*nam
|
|||
struct hostent *host = NULL;
|
||||
struct sockaddr_in s;
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
/* FIXME: PF_INET6 support */
|
||||
if (hints.ai_family == PF_INET6) {
|
||||
pa_log_error("IPv6 is not supported on Windows");
|
||||
goto finish;
|
||||
}
|
||||
#endif
|
||||
|
||||
host = gethostbyname(a.path_or_host);
|
||||
if (!host) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ typedef struct pa_socket_client pa_socket_client;
|
|||
typedef void (*pa_socket_client_cb_t)(pa_socket_client *c, pa_iochannel*io, void *userdata);
|
||||
|
||||
pa_socket_client* pa_socket_client_new_ipv4(pa_mainloop_api *m, uint32_t address, uint16_t port);
|
||||
#ifdef HAVE_IPV6
|
||||
pa_socket_client* pa_socket_client_new_ipv6(pa_mainloop_api *m, uint8_t address[16], uint16_t port);
|
||||
#endif
|
||||
pa_socket_client* pa_socket_client_new_unix(pa_mainloop_api *m, const char *filename);
|
||||
pa_socket_client* pa_socket_client_new_sockaddr(pa_mainloop_api *m, const struct sockaddr *sa, size_t salen);
|
||||
pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, const char *a, uint16_t default_port);
|
||||
|
|
|
|||
|
|
@ -289,6 +289,7 @@ fail:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t address[16], uint16_t port, const char *tcpwrap_service) {
|
||||
pa_socket_server *ss;
|
||||
int fd = -1;
|
||||
|
|
@ -347,6 +348,7 @@ fail:
|
|||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
pa_socket_server* pa_socket_server_new_ipv4_loopback(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service) {
|
||||
pa_assert(m);
|
||||
|
|
@ -355,12 +357,14 @@ pa_socket_server* pa_socket_server_new_ipv4_loopback(pa_mainloop_api *m, uint16_
|
|||
return pa_socket_server_new_ipv4(m, INADDR_LOOPBACK, port, tcpwrap_service);
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
pa_socket_server* pa_socket_server_new_ipv6_loopback(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service) {
|
||||
pa_assert(m);
|
||||
pa_assert(port > 0);
|
||||
|
||||
return pa_socket_server_new_ipv6(m, in6addr_loopback.s6_addr, port, tcpwrap_service);
|
||||
}
|
||||
#endif
|
||||
|
||||
pa_socket_server* pa_socket_server_new_ipv4_any(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service) {
|
||||
pa_assert(m);
|
||||
|
|
@ -369,12 +373,14 @@ pa_socket_server* pa_socket_server_new_ipv4_any(pa_mainloop_api *m, uint16_t por
|
|||
return pa_socket_server_new_ipv4(m, INADDR_ANY, port, tcpwrap_service);
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
pa_socket_server* pa_socket_server_new_ipv6_any(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service) {
|
||||
pa_assert(m);
|
||||
pa_assert(port > 0);
|
||||
|
||||
return pa_socket_server_new_ipv6(m, in6addr_any.s6_addr, port, tcpwrap_service);
|
||||
}
|
||||
#endif
|
||||
|
||||
pa_socket_server* pa_socket_server_new_ipv4_string(pa_mainloop_api *m, const char *name, uint16_t port, const char *tcpwrap_service) {
|
||||
struct in_addr ipv4;
|
||||
|
|
@ -389,6 +395,7 @@ pa_socket_server* pa_socket_server_new_ipv4_string(pa_mainloop_api *m, const cha
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
pa_socket_server* pa_socket_server_new_ipv6_string(pa_mainloop_api *m, const char *name, uint16_t port, const char *tcpwrap_service) {
|
||||
struct in6_addr ipv6;
|
||||
|
||||
|
|
@ -401,6 +408,7 @@ pa_socket_server* pa_socket_server_new_ipv6_string(pa_mainloop_api *m, const cha
|
|||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void socket_server_free(pa_socket_server*s) {
|
||||
pa_assert(s);
|
||||
|
|
@ -441,6 +449,7 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) {
|
|||
pa_assert(l > 0);
|
||||
|
||||
switch (s->type) {
|
||||
#ifdef HAVE_IPV6
|
||||
case SOCKET_SERVER_IPV6: {
|
||||
struct sockaddr_in6 sa;
|
||||
socklen_t sa_len = sizeof(sa);
|
||||
|
|
@ -476,6 +485,7 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) {
|
|||
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
case SOCKET_SERVER_IPV4: {
|
||||
struct sockaddr_in sa;
|
||||
|
|
|
|||
|
|
@ -34,13 +34,15 @@ typedef struct pa_socket_server pa_socket_server;
|
|||
pa_socket_server* pa_socket_server_new(pa_mainloop_api *m, int fd);
|
||||
pa_socket_server* pa_socket_server_new_unix(pa_mainloop_api *m, const char *filename);
|
||||
pa_socket_server* pa_socket_server_new_ipv4(pa_mainloop_api *m, uint32_t address, uint16_t port, const char *tcpwrap_service);
|
||||
pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t address[16], uint16_t port, const char *tcpwrap_service);
|
||||
pa_socket_server* pa_socket_server_new_ipv4_loopback(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service);
|
||||
pa_socket_server* pa_socket_server_new_ipv6_loopback(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service);
|
||||
pa_socket_server* pa_socket_server_new_ipv4_any(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service);
|
||||
pa_socket_server* pa_socket_server_new_ipv6_any(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service);
|
||||
pa_socket_server* pa_socket_server_new_ipv4_string(pa_mainloop_api *m, const char *name, uint16_t port, const char *tcpwrap_service);
|
||||
#ifdef HAVE_IPV6
|
||||
pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t address[16], uint16_t port, const char *tcpwrap_service);
|
||||
pa_socket_server* pa_socket_server_new_ipv6_loopback(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service);
|
||||
pa_socket_server* pa_socket_server_new_ipv6_any(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service);
|
||||
pa_socket_server* pa_socket_server_new_ipv6_string(pa_mainloop_api *m, const char *name, uint16_t port, const char *tcpwrap_service);
|
||||
#endif
|
||||
|
||||
void pa_socket_server_unref(pa_socket_server*s);
|
||||
pa_socket_server* pa_socket_server_ref(pa_socket_server *s);
|
||||
|
|
|
|||
|
|
@ -93,7 +93,9 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
|
|||
union {
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in in;
|
||||
#ifdef HAVE_IPV6
|
||||
struct sockaddr_in6 in6;
|
||||
#endif
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
struct sockaddr_un un;
|
||||
#endif
|
||||
|
|
@ -112,6 +114,7 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
|
|||
ip & 0xFF,
|
||||
ntohs(sa.in.sin_port));
|
||||
return;
|
||||
#ifdef HAVE_IPV6
|
||||
} else if (sa.sa.sa_family == AF_INET6) {
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
const char *res;
|
||||
|
|
@ -121,6 +124,7 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
|
|||
pa_snprintf(c, l, "TCP/IP client from [%s]:%u", buf, ntohs(sa.in6.sin6_port));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
} else if (sa.sa.sa_family == AF_UNIX) {
|
||||
pa_snprintf(c, l, "UNIX socket client");
|
||||
|
|
@ -298,8 +302,10 @@ pa_bool_t pa_socket_address_is_local(const struct sockaddr *sa) {
|
|||
case AF_INET:
|
||||
return ((const struct sockaddr_in*) sa)->sin_addr.s_addr == INADDR_LOOPBACK;
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
case AF_INET6:
|
||||
return memcmp(&((const struct sockaddr_in6*) sa)->sin6_addr, &in6addr_loopback, sizeof(struct in6_addr)) == 0;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
|
|
@ -311,7 +317,9 @@ pa_bool_t pa_socket_is_local(int fd) {
|
|||
union {
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in in;
|
||||
#ifdef HAVE_IPV6
|
||||
struct sockaddr_in6 in6;
|
||||
#endif
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
struct sockaddr_un un;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
struct sockaddr_in sa;
|
||||
#ifdef HAVE_IPV6
|
||||
struct sockaddr_in6 sa6;
|
||||
#endif
|
||||
int fd;
|
||||
int r;
|
||||
pa_ip_acl *acl;
|
||||
|
|
@ -87,6 +89,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
close(fd);
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
fd = socket(PF_INET6, SOCK_STREAM, 0);
|
||||
assert(fd >= 0);
|
||||
|
||||
|
|
@ -129,6 +132,7 @@ int main(int argc, char *argv[]) {
|
|||
pa_ip_acl_free(acl);
|
||||
|
||||
close(fd);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue