[pulseaudio-discuss] ticket #79 - disable IPv6 support
Iain Hibbert
plunky at rya-online.net
Thu Feb 12 05:26:39 PST 2009
Lennart Poettering wrote:
> On Wed, 11.02.09 11:12, Iain Hibbert (plunky at rya-online.net) wrote:
>
> Patch looks mostly good. Except this:
>
> > - 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 (connect(fd, (struct sockaddr*) &sa6, sizeof(sa6)) < 0) {
> > + pa_log("connect() failed: %s", pa_cstrerror(errno));
> > + goto fail;
> > +#endif
> > }
>
> In the first if evaluates to FALSE then the second one will be
> excuted -- resulting on connect() being called twice if IPv4 worked
> fine.
Ah yes, fixed by requiring af == AF_INET6 for second.
> Please #ifdef out the functions in the header files as well.
done.
> Also, please make sure to follow our indentation rules:
>
> http://pulseaudio.org/wiki/CodingStyle
Ok done. I think it was just tab->spaces? (I blame vi :)
I found some ipv6 in another file "src/modules/module-protocol-stub.c"
that have also #ifdef'd out - that file used indented ifdefs so I used the
same (other places not that I saw, so I kept them consistent?)
> If you fix these few issues I will merge the patch. If you hurry up I
> will even include it in 0.9.15.
most excellent!
updated patch attached
thanks,
iain
-------------- next part --------------
diff -ur orig/pulseaudio-0.9.14/config.h.in pulseaudio-0.9.14/config.h.in
--- orig/pulseaudio-0.9.14/config.h.in 2009-01-12 23:45:57.000000000 +0000
+++ pulseaudio-0.9.14/config.h.in 2009-02-12 12:10:33.000000000 +0000
@@ -131,6 +131,9 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
+/* Define this to enable IPv6 connection support */
+#undef HAVE_IPV6
+
/* Define if your <locale.h> file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
diff -ur orig/pulseaudio-0.9.14/configure.ac pulseaudio-0.9.14/configure.ac
--- orig/pulseaudio-0.9.14/configure.ac 2009-01-12 23:44:27.000000000 +0000
+++ pulseaudio-0.9.14/configure.ac 2009-02-12 12:10:33.000000000 +0000
@@ -1000,6 +1000,26 @@
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
+
### Build and Install man pages ###
AC_ARG_ENABLE(manpages,
AS_HELP_STRING([--disable-manpages],[Disable building and installation of man pages]),
@@ -1201,6 +1221,11 @@
ENABLE_POLKIT=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
@@ -1232,6 +1257,7 @@
Enable TCP Wrappers: ${ENABLE_TCPWRAP}
Enable libsamplerate: ${ENABLE_LIBSAMPLERATE}
Enable PolicyKit: ${ENABLE_POLKIT}
+ Enable IPv6: ${ENABLE_IPV6}
System User: ${PA_SYSTEM_USER}
System Group: ${PA_SYSTEM_GROUP}
Realtime Group: ${PA_REALTIME_GROUP}
diff -ur orig/pulseaudio-0.9.14/src/modules/module-protocol-stub.c pulseaudio-0.9.14/src/modules/module-protocol-stub.c
--- orig/pulseaudio-0.9.14/src/modules/module-protocol-stub.c 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/modules/module-protocol-stub.c 2009-02-12 12:42:00.000000000 +0000
@@ -211,7 +211,9 @@
#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 @@
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 @@
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 @@
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 @@
#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);
diff -ur orig/pulseaudio-0.9.14/src/modules/rtp/module-rtp-recv.c pulseaudio-0.9.14/src/modules/rtp/module-rtp-recv.c
--- orig/pulseaudio-0.9.14/src/modules/rtp/module-rtp-recv.c 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/modules/rtp/module-rtp-recv.c 2009-02-12 12:10:33.000000000 +0000
@@ -373,11 +373,13 @@
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 @@
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 @@
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;
diff -ur orig/pulseaudio-0.9.14/src/modules/rtp/module-rtp-send.c pulseaudio-0.9.14/src/modules/rtp/module-rtp-send.c
--- orig/pulseaudio-0.9.14/src/modules/rtp/module-rtp-send.c 2009-01-12 23:11:38.000000000 +0000
+++ pulseaudio-0.9.14/src/modules/rtp/module-rtp-send.c 2009-02-12 12:10:33.000000000 +0000
@@ -177,7 +177,9 @@
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 @@
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 @@
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 @@
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 @@
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);
diff -ur orig/pulseaudio-0.9.14/src/modules/rtp/sap.c pulseaudio-0.9.14/src/modules/rtp/sap.c
--- orig/pulseaudio-0.9.14/src/modules/rtp/sap.c 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/modules/rtp/sap.c 2009-02-12 12:10:33.000000000 +0000
@@ -83,18 +83,31 @@
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);
diff -ur orig/pulseaudio-0.9.14/src/modules/rtp/sdp.c pulseaudio-0.9.14/src/modules/rtp/sdp.c
--- orig/pulseaudio-0.9.14/src/modules/rtp/sdp.c 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/modules/rtp/sdp.c 2009-02-12 12:10:33.000000000 +0000
@@ -48,7 +48,12 @@
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 @@
((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 @@
((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) {
diff -ur orig/pulseaudio-0.9.14/src/pulsecore/inet_ntop.c pulseaudio-0.9.14/src/pulsecore/inet_ntop.c
--- orig/pulseaudio-0.9.14/src/pulsecore/inet_ntop.c 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/pulsecore/inet_ntop.c 2009-02-12 12:10:33.000000000 +0000
@@ -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 @@
(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 @@
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;
diff -ur orig/pulseaudio-0.9.14/src/pulsecore/inet_pton.c pulseaudio-0.9.14/src/pulsecore/inet_pton.c
--- orig/pulseaudio-0.9.14/src/pulsecore/inet_pton.c 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/pulsecore/inet_pton.c 2009-02-12 12:10:33.000000000 +0000
@@ -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 @@
if (in->s_addr == INADDR_NONE)
return 0;
break;
+#ifdef HAVE_IPV6
case AF_INET6:
/* FIXME */
+#endif
default:
errno = EAFNOSUPPORT;
return -1;
diff -ur orig/pulseaudio-0.9.14/src/pulsecore/ipacl.c pulseaudio-0.9.14/src/pulsecore/ipacl.c
--- orig/pulseaudio-0.9.14/src/pulsecore/ipacl.c 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/pulsecore/ipacl.c 2009-02-12 12:10:33.000000000 +0000
@@ -62,7 +62,9 @@
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 @@
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 @@
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 @@
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 @@
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 @@
if (bits == 0)
return 1;
}
+#endif
}
}
diff -ur orig/pulseaudio-0.9.14/src/pulsecore/socket-client.c pulseaudio-0.9.14/src/pulsecore/socket-client.c
--- orig/pulseaudio-0.9.14/src/pulsecore/socket-client.c 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/pulsecore/socket-client.c 2009-02-12 12:10:33.000000000 +0000
@@ -278,7 +278,11 @@
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 @@
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 @@
return pa_socket_client_new_sockaddr(m, (struct sockaddr*) &sa, sizeof(sa));
}
+#endif
#ifdef HAVE_LIBASYNCNS
@@ -470,7 +476,15 @@
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 @@
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) {
diff -ur orig/pulseaudio-0.9.14/src/pulsecore/socket-client.h pulseaudio-0.9.14/src/pulsecore/socket-client.h
--- orig/pulseaudio-0.9.14/src/pulsecore/socket-client.h 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/pulsecore/socket-client.h 2009-02-12 12:10:33.000000000 +0000
@@ -35,7 +35,9 @@
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);
diff -ur orig/pulseaudio-0.9.14/src/pulsecore/socket-server.c pulseaudio-0.9.14/src/pulsecore/socket-server.c
--- orig/pulseaudio-0.9.14/src/pulsecore/socket-server.c 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/pulsecore/socket-server.c 2009-02-12 12:10:33.000000000 +0000
@@ -289,6 +289,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
return NULL;
}
+#endif
static void socket_server_free(pa_socket_server*s) {
pa_assert(s);
@@ -441,6 +449,7 @@
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 @@
return c;
}
+#endif
case SOCKET_SERVER_IPV4: {
struct sockaddr_in sa;
diff -ur orig/pulseaudio-0.9.14/src/pulsecore/socket-server.h pulseaudio-0.9.14/src/pulsecore/socket-server.h
--- orig/pulseaudio-0.9.14/src/pulsecore/socket-server.h 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/pulsecore/socket-server.h 2009-02-12 12:10:33.000000000 +0000
@@ -34,13 +34,15 @@
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);
diff -ur orig/pulseaudio-0.9.14/src/pulsecore/socket-util.c pulseaudio-0.9.14/src/pulsecore/socket-util.c
--- orig/pulseaudio-0.9.14/src/pulsecore/socket-util.c 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/pulsecore/socket-util.c 2009-02-12 12:10:33.000000000 +0000
@@ -93,7 +93,9 @@
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 @@
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 @@
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");
@@ -294,8 +298,10 @@
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;
@@ -307,7 +313,9 @@
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
diff -ur orig/pulseaudio-0.9.14/src/tests/ipacl-test.c pulseaudio-0.9.14/src/tests/ipacl-test.c
--- orig/pulseaudio-0.9.14/src/tests/ipacl-test.c 2009-01-12 23:10:34.000000000 +0000
+++ pulseaudio-0.9.14/src/tests/ipacl-test.c 2009-02-12 12:10:33.000000000 +0000
@@ -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 @@
close(fd);
+#ifdef HAVE_IPV6
fd = socket(PF_INET6, SOCK_STREAM, 0);
assert(fd >= 0);
@@ -129,6 +132,7 @@
pa_ip_acl_free(acl);
close(fd);
+#endif
return 0;
}
More information about the pulseaudio-discuss
mailing list