You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by jo...@apache.org on 2013/05/30 11:28:22 UTC

svn commit: r1487796 - /apr/apr/trunk/network_io/unix/multicast.c

Author: jorton
Date: Thu May 30 09:28:22 2013
New Revision: 1487796

URL: http://svn.apache.org/r1487796
Log:
* network_io/unix/multicast.c (do_mcast_opt): Fix regression in
  handling IPv4 options introduced in r1309386.

Modified:
    apr/apr/trunk/network_io/unix/multicast.c

Modified: apr/apr/trunk/network_io/unix/multicast.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/unix/multicast.c?rev=1487796&r1=1487795&r2=1487796&view=diff
==============================================================================
--- apr/apr/trunk/network_io/unix/multicast.c (original)
+++ apr/apr/trunk/network_io/unix/multicast.c Thu May 30 09:28:22 2013
@@ -196,12 +196,17 @@ static apr_status_t do_mcast(int type, a
     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_uint32_t value)
+                                 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;
@@ -209,6 +214,9 @@ static apr_status_t do_mcast_opt(int typ
     }
 #if APR_HAVE_IPV6
     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;
         }
@@ -220,7 +228,7 @@ static apr_status_t do_mcast_opt(int typ
         }
 
         if (setsockopt(sock->socketdes, IPPROTO_IPV6, type,
-                       (const void *) &value, sizeof(value)) == -1) {
+                       (const void *) &ivalue, sizeof(ivalue)) == -1) {
             rv = errno;
         }
     }