Patch: IP_MULTICAST_LOOP support

Anthony Green green@redhat.com
Fri Jan 28 21:45:00 GMT 2005


I don't really understand networking, but a little app I was trying to
run a while ago complained about this missing support.  This is my best
guess at the right thing to do.  Comments?


2005-01-28  Anthony Green  <green@redhat.com>

	* gnu/java/net/natPlainDatagramSocketImplPosix.cc (setOption): 
	Support IP_MULTICAST_LOOP.

Index: libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc,v
retrieving revision 1.7
diff -c -u -p -r1.7 natPlainDatagramSocketImplPosix.cc
--- libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc	17 Mar 2004 08:10:28 -0000	1.7
+++ libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc	28 Jan 2005 21:42:45 -0000
@@ -602,9 +602,24 @@ gnu::java::net::PlainDatagramSocketImpl:
         return;
 	
       case _Jv_IP_MULTICAST_LOOP_ :
-        throw new ::java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_LOOP: not yet implemented"));
-        return;
+	jbyteArray haddress = inetaddr->addr;
+	jbyte *bytes = elements (haddress);
+	int len = haddress->length;
+	int level, opname;
+	if (len == 4)
+	  {
+	    level = IPPROTO_IP;
+	    opname = IP_MULTICAST_LOOP;
+	  }
+	else
+	  {
+	    level = IPPROTO_IPV6;
+	    opname = IPV6_MULTICAST_LOOP;
+	  }
+	if (::setsockopt (native_fd, level, opname, (char *) &val,
+			  val_len) != 0)
+	  goto error;
+	return;
 	
       case _Jv_IP_TOS_ :
         if (::setsockopt (native_fd, SOL_SOCKET, IP_TOS, (char *) &val,




More information about the Java-patches mailing list