diff options
Diffstat (limited to 'contrib/apr/network_io/unix/multicast.c')
-rw-r--r-- | contrib/apr/network_io/unix/multicast.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/contrib/apr/network_io/unix/multicast.c b/contrib/apr/network_io/unix/multicast.c index 67ab245..3767bfd 100644 --- a/contrib/apr/network_io/unix/multicast.c +++ b/contrib/apr/network_io/unix/multicast.c @@ -193,36 +193,39 @@ static apr_status_t do_mcast(int type, apr_socket_t *sock, return rv; } +/* Set the IP_MULTICAST_TTL or IP_MULTICAST_LOOP option, or IPv6 + * equivalents, for the socket, to the given value. Note that this + * function *only works* for those particular option types. */ static apr_status_t do_mcast_opt(int type, apr_socket_t *sock, apr_byte_t value) { apr_status_t rv = APR_SUCCESS; if (sock_is_ipv4(sock)) { + /* For the IP_MULTICAST_* options, this must be a (char *) + * pointer. */ if (setsockopt(sock->socketdes, IPPROTO_IP, type, (const void *) &value, sizeof(value)) == -1) { rv = errno; } } #if APR_HAVE_IPV6 - else if (sock_is_ipv6(sock) && type == IP_MULTICAST_LOOP) { - unsigned int loopopt = value; - type = IPV6_MULTICAST_LOOP; - if (setsockopt(sock->socketdes, IPPROTO_IPV6, type, - (const void *) &loopopt, sizeof(loopopt)) == -1) { - rv = errno; - } - } else if (sock_is_ipv6(sock)) { + /* For the IPV6_* options, an (int *) pointer must be used. */ + int ivalue = value; + if (type == IP_MULTICAST_TTL) { type = IPV6_MULTICAST_HOPS; } + else if (type == IP_MULTICAST_LOOP) { + type = IPV6_MULTICAST_LOOP; + } else { return APR_ENOTIMPL; } if (setsockopt(sock->socketdes, IPPROTO_IPV6, type, - &value, sizeof(value)) == -1) { + (const void *) &ivalue, sizeof(ivalue)) == -1) { rv = errno; } } |