This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

MulticastSocket.getInterface() implemented


Included is the ChangeLog entry and patch to implement getting the
current IP_MULTICAST_IF via java.net.MulticastSocket.getInterface().
This same code is used by MulticastSocket.getOption(IP_MULTICAST_IF).

Note that configure was rebuilt with a different (later?) autoconf
version than was apparently used on the previously checked in configure.
Rather than including a huge diff (which mainly shows only line numbers 
differences), I've shown just the significant configure patch below. 
--warrenl


1999-07-02  Warren Levy  <warrenl@cygnus.com>

	* configure: Rebuilt.
	* configure.in: Added inet_ntoa to AC_CHECK_FUNCS.
	* include/config.h.in: Rebuilt.
	* java/net/natPlainDatagramSocketImpl.cc: Added header checking.
	(mcastGrp): Updated FIXME comments.
	(setOption): Fixed typo.
	(getOption):Implemented IP_MULTICAST_IF.

Index: libjava/configure
===================================================================
RCS file: /cvs/cvsfiles/devo/libjava/configure,v
retrieving revision 1.52.2.8
diff -u -p -c -2 -p -r1.52.2.8 configure
*** configure	1999/06/21 20:08:26	1.52.2.8
--- configure	1999/07/03 01:13:58
*************** fi
*** 3334,3338 ****
  done
  
!    for ac_func in inet_pton uname
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
--- 3334,3338 ----
  done
  
!    for ac_func in inet_pton uname inet_ntoa
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
Index: configure.in
===================================================================
RCS file: /cvs/cvsfiles/devo/libjava/configure.in,v
retrieving revision 1.64
diff -u -p -c -2 -p -r1.64 configure.in
*** configure.in	1999/06/25 03:35:04	1.64
--- configure.in	1999/07/03 00:49:03
*************** else
*** 302,306 ****
     AC_CHECK_FUNCS(access stat mkdir rename rmdir unlink realpath)
     AC_CHECK_FUNCS(inet_aton inet_addr, break)
!    AC_CHECK_FUNCS(inet_pton uname)
  
     AC_CHECK_FUNCS(gethostbyname_r, [
--- 302,306 ----
     AC_CHECK_FUNCS(access stat mkdir rename rmdir unlink realpath)
     AC_CHECK_FUNCS(inet_aton inet_addr, break)
!    AC_CHECK_FUNCS(inet_pton uname inet_ntoa)
  
     AC_CHECK_FUNCS(gethostbyname_r, [
Index: include/config.h.in
===================================================================
RCS file: /cvs/cvsfiles/devo/libjava/include/config.h.in,v
retrieving revision 1.23
diff -u -p -c -2 -p -r1.23 config.h.in
*** config.h.in	1999/06/25 03:35:05	1.23
--- config.h.in	1999/07/03 00:49:03
***************
*** 146,149 ****
--- 146,152 ----
  #undef HAVE_INET_ATON
  
+ /* Define if you have the inet_ntoa function.  */
+ #undef HAVE_INET_NTOA
+ 
  /* Define if you have the inet_pton function.  */
  #undef HAVE_INET_PTON
Index: java/net/natPlainDatagramSocketImpl.cc
===================================================================
RCS file: /cvs/cvsfiles/devo/libjava/java/net/natPlainDatagramSocketImpl.cc,v
retrieving revision 1.12
diff -u -p -c -2 -p -r1.12 natPlainDatagramSocketImpl.cc
*** natPlainDatagramSocketImpl.cc	1999/07/02 10:55:21	1.12
--- natPlainDatagramSocketImpl.cc	1999/07/03 00:49:04
*************** details.  */
*** 9,17 ****
--- 9,28 ----
  #include <config.h>
  
+ #ifdef HAVE_SYS_TYPES_H
  #include <sys/types.h>
+ #endif
+ #ifdef HAVE_SYS_SOCKET_H
  #include <sys/socket.h>
+ #endif
  #include <sys/time.h>
+ #ifdef HAVE_SYS_SELECT_H
  #include <sys/select.h>
+ #endif
+ #ifdef HAVE_NETINET_IN_H
  #include <netinet/in.h>
+ #endif
+ #ifdef HAVE_ARPA_INET_H
+ #include <arpa/inet.h>
+ #endif
  #include <errno.h>
  #include <stdio.h>
*************** java::net::PlainDatagramSocketImpl::mcas
*** 320,323 ****
--- 331,335 ----
        memcpy (&u.mreq.imr_multiaddr, bytes, len);
        // FIXME:  If a non-default interface is set, use it; see Stevens p. 501.
+       // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
        u.mreq.imr_interface.s_addr = htonl (INADDR_ANY); 
        len = sizeof (struct ip_mreq);
*************** java::net::PlainDatagramSocketImpl::mcas
*** 331,334 ****
--- 343,347 ----
        memcpy (&u.mreq6.ipv6mr_multiaddr, bytes, len);
        // FIXME:  If a non-default interface is set, use it; see Stevens p. 501.
+       // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
        u.mreq6.ipv6mr_interface = 0;
        len = sizeof (struct ipv6_mreq);
*************** java::net::PlainDatagramSocketImpl::setO
*** 432,436 ****
  	    opname = IPV6_MULTICAST_IF;
  	    memcpy (&u.addr6, bytes, len);
! 	    len = sizeof (struct in_addr6);
  	    ptr = (const char *) &u.addr6;
  	  }
--- 445,449 ----
  	    opname = IPV6_MULTICAST_IF;
  	    memcpy (&u.addr6, bytes, len);
! 	    len = sizeof (struct in6_addr);
  	    ptr = (const char *) &u.addr6;
  	  }
*************** java::net::PlainDatagramSocketImpl::getO
*** 525,531 ****
  	break;
        case _Jv_IP_MULTICAST_IF_ :
! 	// FIXME: TODO - Implement IP_MULTICAST_IF.
! 	JvThrow (new java::lang::InternalError (
! 	  JvNewStringUTF ("IP_MULTICAST_IF: option not implemented")));
  	break;
        case _Jv_SO_TIMEOUT_ :
--- 538,558 ----
  	break;
        case _Jv_IP_MULTICAST_IF_ :
! #ifdef HAVE_INET_NTOA
! 	struct in_addr inaddr;
!   	socklen_t inaddr_len;
! 	char *bytes;
! 
!   	inaddr_len = sizeof(inaddr);
! 	if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_IF, (char *) &inaddr,
! 	    &inaddr_len) != 0)
! 	  goto error;
! 
! 	bytes = inet_ntoa (inaddr);
! 
! 	return java::net::InetAddress::getByName (JvNewStringLatin1 (bytes));
! #else
! 	JvThrow (new java::net::SocketException (
! 	  JvNewStringUTF ("IP_MULTICAST_IF: not available - no inet_ntoa()")));
! #endif
  	break;
        case _Jv_SO_TIMEOUT_ :

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]