[kaffe] CVS kaffe (guilhem): New network classes merging, some native NIO implementation, wider IPV6 support,
Kaffe CVS
cvs-commits at kaffe.org
Tue Oct 28 04:39:02 PST 2003
PatchSet 4131
Date: 2003/10/28 12:29:25
Author: guilhem
Branch: HEAD
Tag: (none)
Log:
New network classes merging, some native NIO implementation, wider IPV6 support, DNS modularity
Members:
ChangeLog:1.1723->1.1724
configure:1.263->1.264
configure.in:1.229->1.230
config/config-net.h:1.1->1.2
include/Makefile.am:1.49->1.50
include/Makefile.in:1.124->1.125
libraries/clib/Makefile.am:1.4->1.5
libraries/clib/Makefile.in:1.74->1.75
libraries/clib/net/InetAddressImpl.c:1.19->1.20
libraries/clib/net/PlainDatagramSocketImpl.c:1.30->1.31
libraries/clib/net/PlainSocketImpl.c:1.33->1.34
libraries/clib/nio/DirectByteBufferImpl.c:INITIAL->1.1
libraries/clib/nio/Makefile.am:INITIAL->1.1
libraries/clib/nio/Makefile.in:INITIAL->1.1
libraries/clib/nio/NIOServerSocket.c:INITIAL->1.1
libraries/clib/nio/SelectorImpl.c:INITIAL->1.1
libraries/javalib/Klasses.jar.bootstrap:1.40->1.41
libraries/javalib/bootstrap.classlist:1.32->1.33
libraries/javalib/essential.files:1.29->1.30
libraries/javalib/gnu/java/net/InetAddressImpl.java:INITIAL->1.1
libraries/javalib/gnu/java/net/SysInetAddressImpl.java:INITIAL->1.1
libraries/javalib/gnu/java/nio/FileLockImpl.java:1.2->1.3
libraries/javalib/gnu/java/nio/SelectorImpl.java:1.5->1.6
libraries/javalib/java/net/Inet4Address.java:1.2->1.3
libraries/javalib/java/net/Inet6Address.java:1.1->1.2
libraries/javalib/java/net/InetAddress.java:1.17->1.18
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1723 kaffe/ChangeLog:1.1724
--- kaffe/ChangeLog:1.1723 Mon Oct 27 20:29:38 2003
+++ kaffe/ChangeLog Tue Oct 28 12:29:25 2003
@@ -1,3 +1,45 @@
+2003-10-27 Guilhem Lavaux <guilhem at kaffe.org>
+
+ * libraries/clib/nio, libraries/clib/nio/Makefile.am,
+ libraries/clib/nio/Makefile.in: New native library for NIO
+
+ * libraries/clib/nio/SelectorImpl.c,
+ libraries/clib/nio/NIOServerSocket.c,
+ libraries/clib/nio/DirectByteBufferImpl.c:
+ Native implementation for selectors and a
+ method call to pass through access verifier.
+
+ * libraries/clib/net/InetAddressImpl.c: partly moved native functions
+ from java/net/InetAddress to gnu/java/net/InetAddressImpl.
+
+ * configure.in: Build Makefile in libraries/clib/nio
+
+ * include/Makefile.am: Added gnu_java_net_SysInetAddressImpl.h,
+ gnu_java_nio_SelectorImpl.h.
+
+ * libraries/javalib/java/net/InetAddress.java,
+ libraries/javalib/java/net/Inet4Address.java,
+ libraries/javalib/java/net/Inet6Address.java,
+ libraries/javalib/gnu/java/net/InetAddressImpl.java,
+ libraries/javalib/gnu/java/net/SysInetAddressImpl.java:
+ Merged the new Classpath's implementation in. Added submitted patch
+ to make DNS calls modular.
+
+ * libraries/clib/net/PlainDatagramSocketImpl.c:
+ (bind, send, receive) IPV6 compatible, upgraded to latest
+ classpath.
+
+ * libraries/javalib/gnu/java/net/PlainSocketImpl.c:
+ (socketBind, socketAccept, socketConnect) IPV6 compatible, upgraded
+ to latest classpath.
+
+ * libraries/javalib/bootstrap.classlist:
+ Added new NIO and NET classes required by kaffeh to build includes
+ (SysInetAddressImpl, SelectorImpl, InetAddressImpl).
+
+ * configure, Makefile.in, include/Makefile.in,
+ libraries/javalib/Klasses.jar.bootstrap: Regenerated
+
2003-10-27 Motoyuki Kasahara <m-kasahr at sra.co.jp>
* configure.in:
@@ -51,7 +93,7 @@
2003-10-25 Dalibor Topic <robilad at kaffe.org>
- * FAQ/FAQ.automake: Recommend autmake 1.7.8.
+ * FAQ/FAQ.automake: Recommend automake 1.7.8.
* developers/autogen.sh: Upgraded to automake 1.7.8.
Index: kaffe/configure
diff -u kaffe/configure:1.263 kaffe/configure:1.264
--- kaffe/configure:1.263 Mon Oct 27 20:29:40 2003
+++ kaffe/configure Tue Oct 28 12:29:26 2003
@@ -42909,6 +42909,8 @@
ac_config_files="$ac_config_files libraries/clib/io/Makefile"
+ ac_config_files="$ac_config_files libraries/clib/nio/Makefile"
+
ac_config_files="$ac_config_files libraries/clib/net/Makefile"
ac_config_files="$ac_config_files libraries/clib/zip/Makefile"
@@ -43732,6 +43734,7 @@
"libraries/clib/Makefile" ) CONFIG_FILES="$CONFIG_FILES libraries/clib/Makefile" ;;
"libraries/clib/native/Makefile" ) CONFIG_FILES="$CONFIG_FILES libraries/clib/native/Makefile" ;;
"libraries/clib/io/Makefile" ) CONFIG_FILES="$CONFIG_FILES libraries/clib/io/Makefile" ;;
+ "libraries/clib/nio/Makefile" ) CONFIG_FILES="$CONFIG_FILES libraries/clib/nio/Makefile" ;;
"libraries/clib/net/Makefile" ) CONFIG_FILES="$CONFIG_FILES libraries/clib/net/Makefile" ;;
"libraries/clib/zip/Makefile" ) CONFIG_FILES="$CONFIG_FILES libraries/clib/zip/Makefile" ;;
"libraries/clib/math/Makefile" ) CONFIG_FILES="$CONFIG_FILES libraries/clib/math/Makefile" ;;
Index: kaffe/configure.in
diff -u kaffe/configure.in:1.229 kaffe/configure.in:1.230
--- kaffe/configure.in:1.229 Mon Oct 27 20:29:42 2003
+++ kaffe/configure.in Tue Oct 28 12:29:28 2003
@@ -1660,6 +1660,7 @@
AC_CONFIG_FILES([libraries/clib/Makefile])
AC_CONFIG_FILES([libraries/clib/native/Makefile])
AC_CONFIG_FILES([libraries/clib/io/Makefile])
+AC_CONFIG_FILES([libraries/clib/nio/Makefile])
AC_CONFIG_FILES([libraries/clib/net/Makefile])
AC_CONFIG_FILES([libraries/clib/zip/Makefile])
AC_CONFIG_FILES([libraries/clib/math/Makefile])
Index: kaffe/config/config-net.h
diff -u kaffe/config/config-net.h:1.1 kaffe/config/config-net.h:1.2
--- kaffe/config/config-net.h:1.1 Tue Dec 8 02:04:30 1998
+++ kaffe/config/config-net.h Tue Oct 28 12:29:29 2003
@@ -24,4 +24,11 @@
#include <netinet/tcp.h>
#endif
+typedef union {
+ struct sockaddr_in addr4;
+#if defined(HAVE_STRUCT_SOCKADDR_IN6)
+ struct sockaddr_in6 addr6;
+#endif
+} KaffeSocketAddr;
+
#endif
Index: kaffe/include/Makefile.am
diff -u kaffe/include/Makefile.am:1.49 kaffe/include/Makefile.am:1.50
--- kaffe/include/Makefile.am:1.49 Sun Sep 28 19:53:53 2003
+++ kaffe/include/Makefile.am Tue Oct 28 12:29:31 2003
@@ -77,6 +77,7 @@
java_net_NetworkInterface.h \
gnu_java_net_PlainDatagramSocketImpl.h \
gnu_java_net_PlainSocketImpl.h \
+ gnu_java_net_SysInetAddressImpl.h \
java_net_SocketAddress.h \
java_net_SocketImpl.h \
java_net_SocketOptions.h \
@@ -94,7 +95,9 @@
kaffe_applet_AudioPlayer.h \
kaffe_lang_PrimordialClassLoader.h \
kaffe_lang_ThreadStack.h \
- kaffe_management_Classpath.h
+ kaffe_management_Classpath.h \
+ java_nio_DirectByteBufferImpl.h \
+ gnu_java_nio_SelectorImpl.h
DERIVED_HDRS = $(INSTALL_DERIVED_HDRS) $(NOINSTALL_DERIVED_HDRS)
Index: kaffe/include/Makefile.in
diff -u kaffe/include/Makefile.in:1.124 kaffe/include/Makefile.in:1.125
--- kaffe/include/Makefile.in:1.124 Sat Oct 25 20:00:15 2003
+++ kaffe/include/Makefile.in Tue Oct 28 12:29:31 2003
@@ -318,6 +318,7 @@
java_net_NetworkInterface.h \
gnu_java_net_PlainDatagramSocketImpl.h \
gnu_java_net_PlainSocketImpl.h \
+ gnu_java_net_SysInetAddressImpl.h \
java_net_SocketAddress.h \
java_net_SocketImpl.h \
java_net_SocketOptions.h \
@@ -335,7 +336,9 @@
kaffe_applet_AudioPlayer.h \
kaffe_lang_PrimordialClassLoader.h \
kaffe_lang_ThreadStack.h \
- kaffe_management_Classpath.h
+ kaffe_management_Classpath.h \
+ java_nio_DirectByteBufferImpl.h \
+ gnu_java_nio_SelectorImpl.h
DERIVED_HDRS = $(INSTALL_DERIVED_HDRS) $(NOINSTALL_DERIVED_HDRS)
Index: kaffe/libraries/clib/Makefile.am
diff -u kaffe/libraries/clib/Makefile.am:1.4 kaffe/libraries/clib/Makefile.am:1.5
--- kaffe/libraries/clib/Makefile.am:1.4 Fri May 9 10:02:41 2003
+++ kaffe/libraries/clib/Makefile.am Tue Oct 28 12:29:31 2003
@@ -13,4 +13,4 @@
MAYBE_NATIVE_MATH = math
endif
-SUBDIRS = native io net zip $(MAYBE_NATIVE_MATH) security management awt
+SUBDIRS = native io nio net zip $(MAYBE_NATIVE_MATH) security management awt
Index: kaffe/libraries/clib/Makefile.in
diff -u kaffe/libraries/clib/Makefile.in:1.74 kaffe/libraries/clib/Makefile.in:1.75
--- kaffe/libraries/clib/Makefile.in:1.74 Sat Oct 25 20:00:25 2003
+++ kaffe/libraries/clib/Makefile.in Tue Oct 28 12:29:31 2003
@@ -251,7 +251,7 @@
@COND_PURE_JAVA_MATH_TRUE at MAYBE_NATIVE_MATH =
@COND_PURE_JAVA_MATH_FALSE at MAYBE_NATIVE_MATH = math
-SUBDIRS = native io net zip $(MAYBE_NATIVE_MATH) security management awt
+SUBDIRS = native io nio net zip $(MAYBE_NATIVE_MATH) security management awt
subdir = libraries/clib
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -266,7 +266,7 @@
installdirs-recursive install-recursive uninstall-recursive \
check-recursive installcheck-recursive
DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
-DIST_SUBDIRS = native io net zip math security management awt
+DIST_SUBDIRS = native io nio net zip math security management awt
all: all-recursive
.SUFFIXES:
Index: kaffe/libraries/clib/net/InetAddressImpl.c
diff -u kaffe/libraries/clib/net/InetAddressImpl.c:1.19 kaffe/libraries/clib/net/InetAddressImpl.c:1.20
--- kaffe/libraries/clib/net/InetAddressImpl.c:1.19 Wed Sep 17 14:57:40 2003
+++ kaffe/libraries/clib/net/InetAddressImpl.c Tue Oct 28 12:29:32 2003
@@ -21,6 +21,7 @@
#include "../../../kaffe/kaffevm/stringSupport.h"
#include "../../../kaffe/kaffevm/support.h"
#include "java_net_InetAddress.h"
+#include "gnu_java_net_SysInetAddressImpl.h"
#include "nets.h"
#include "jsyscall.h"
@@ -88,7 +89,7 @@
}
else
throwError(&einfo);
-
+
return addr;
}
@@ -96,7 +97,7 @@
* Get localhost name.
*/
struct Hjava_lang_String*
-java_net_InetAddress_getLocalHostName(void)
+java_net_InetAddress_getLocalHostname(void)
{
static char hostname[HOSTNMSZ] = "localhost";
static iStaticLock hostLock;
@@ -121,7 +122,9 @@
* Convert a hostname to an array of host addresses.
*/
HArrayOfArray*
-java_net_InetAddress_getHostByName(struct Hjava_lang_String* jStr)
+gnu_java_net_SysInetAddressImpl_getHostByName(
+ struct Hgnu_java_net_SysInetAddressImpl *this,
+ struct Hjava_lang_String* jStr)
{
#if defined(HAVE_GETADDRINFO)
int index = 0, count = 0, retryCount = 5, rc;
@@ -349,7 +352,9 @@
* Convert a network order address into the hostname.
*/
struct Hjava_lang_String*
-java_net_InetAddress_getHostByAddr(HArrayOfByte *addr)
+gnu_java_net_SysInetAddressImpl_getHostByAddr(
+ struct Hgnu_java_net_SysInetAddressImpl *this,
+ HArrayOfByte *addr)
{
#if defined(HAVE_GETADDRINFO)
struct Hjava_lang_String *retval = 0;
Index: kaffe/libraries/clib/net/PlainDatagramSocketImpl.c
diff -u kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.30 kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.31
--- kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.30 Sun Sep 28 19:53:54 2003
+++ kaffe/libraries/clib/net/PlainDatagramSocketImpl.c Tue Oct 28 12:29:32 2003
@@ -3,6 +3,8 @@
*
* Copyright (c) 1996, 1997
* Transvirtual Technologies, Inc. All rights reserved.
+ * Copyright (c) 2003
+ * Kaffe's team.
*
* See the file "license.terms" for information on usage and redistribution
* of this file.
@@ -28,6 +30,7 @@
#include "java_util_Vector.h"
#include "nets.h"
#include <jsyscall.h>
+#include "Arrays.h"
#include "../../../kaffe/kaffevm/debug.h"
#include "../../../kaffe/kaffevm/itypes.h"
#include "../../../kaffe/kaffevm/exception.h"
@@ -82,10 +85,30 @@
sprintf(addrbuf, "%u.%u.%u.%u", top, tmid, bmid, bottom);
return addrbuf;
}
-#endif /* KAFFE_VMDEBUG */
-
+/* Generate a string for an inet6 addr (in host form). */
+static char *
+ip62str(struct in6_addr *addr)
+{
+ static char addrbuf[255];
+ int i, count;
+ for (count=0,i=0;i<16;i++) {
+ char *format;
+
+ if (i == 0 && addr->in6_u.u6_addr8[i] != 0)
+ format = "%x";
+ else if (addr->in6_u.u6_addr8[i] != 0)
+ format = "%x:";
+ else if (i != 0)
+ format = ":";
+ else
+ format = "";
+ count += sprintf(&addrbuf[count], format, addr->in6_u.u6_addr8[i]);
+ }
+ return addrbuf;
+}
+#endif /* KAFFE_VMDEBUG */
/*
* Create a datagram socket.
*/
@@ -122,28 +145,49 @@
}
/*
- * Bind a port to the socket.
+ * Bind a port to the socket (IPV4 version).
*/
void
-gnu_java_net_PlainDatagramSocketImpl_bind(struct Hgnu_java_net_PlainDatagramSocketImpl* this, jint port, struct Hjava_net_InetAddress* laddr)
+gnu_java_net_PlainDatagramSocketImpl_bind(struct Hgnu_java_net_PlainDatagramSocketImpl* this, jint port,
+ struct Hjava_net_InetAddress* laddr)
{
int r;
- struct sockaddr_in addr;
+ KaffeSocketAddr addr;
int alen;
const int fd = unhand(unhand(this)->fd)->nativeFd;
+ memset(&addr, 0, sizeof(addr));
+ if (obj_length(unhand(laddr)->addr) == 4) {
+#if defined(BSD44)
+ addr.addr4.sin_len = sizeof(addr.addr4);
+#endif
+ addr.addr4.sin_family = AF_INET;
+ addr.addr4.sin_port = htons(port);
+ memcpy(&addr.addr4.sin_addr, unhand_byte_array(unhand(laddr)->addr),
+ sizeof(addr.addr4.sin_addr));
+
DBG(NATIVENET,
- dprintf("datagram_bind(%p, %s, %d)\n",
- this, ip2str(unhand(laddr)->address), port);
+ dprintf("datagram_bind4(%p, %s, %d)\n",
+ this, ip2str(addr.addr4.sin_addr.s_addr), port);
)
-
- memset(&addr, 0, sizeof(addr));
+#if defined(HAVE_STRUCT_SOCKADDR_IN6)
+ } else if (obj_length(unhand(laddr)->addr) == 16) {
#if defined(BSD44)
- addr.sin_len = sizeof(addr);
+ addr.addr6.sin6_len = sizeof(addr.addr6);
+#endif
+ addr.addr6.sin6_family = AF_INET6;
+ addr.addr6.sin6_port = htons(port);
+ memcpy(&addr.addr6.sin6_addr, unhand_byte_array(unhand(laddr)->addr),
+ sizeof(addr.addr6.sin6_addr));
+
+DBG(NATIVENET,
+ dprintf("datagram_bind6(%p, %s, %d)\n",
+ this, ip62str(&addr.addr6.sin6_addr), port);
+)
#endif
- addr.sin_family = AF_INET;
- addr.sin_port = htons(port);
- addr.sin_addr.s_addr = htonl(unhand(laddr)->address);
+ } else {
+ SignalError("java.net.SocketException", "Unsupported address family");
+ }
r = KBIND(fd, (struct sockaddr*)&addr, sizeof(addr));
switch( r )
@@ -166,13 +210,13 @@
if (r) {
SignalError("java.net.SocketException", SYS_ERROR(r));
}
- port = ntohs(addr.sin_port);
+ port = ntohs(addr.addr4.sin_port);
}
unhand(this)->localPort = port;
DBG(NATIVENET,
dprintf(" datagram_bind(%p, %s, -) -> (localPort: %d)\n",
- this, ip2str(unhand(laddr)->address), port);
+ this, ip2str(addr.addr4.sin_addr.s_addr), port);
)
}
@@ -181,30 +225,52 @@
{
int rc;
ssize_t bsent;
- struct sockaddr_in addr;
-
+ KaffeSocketAddr addr;
+
DBG(NATIVENET,
dprintf("datagram_send(%p, %p [%d bytes])\n",
this, pkt, unhand(pkt)->length);
)
- memset(&addr, 0, sizeof(addr));
+ memset(&addr, 0, sizeof(addr));
+ if (obj_length(unhand(unhand(pkt)->address)->addr) == 4) {
#if defined(BSD44)
- addr.sin_len = sizeof(addr);
+ addr.addr4.sin_len = sizeof(addr.addr4);
#endif
- addr.sin_family = AF_INET;
- addr.sin_port = htons(unhand(pkt)->port);
- addr.sin_addr.s_addr = htonl(unhand(unhand(pkt)->address)->address);
-
+ addr.addr4.sin_family = AF_INET;
+ addr.addr4.sin_port = htons(unhand(pkt)->port);
+ memcpy(&addr.addr4.sin_addr.s_addr, unhand_byte_array(unhand(unhand(pkt)->address)->addr),
+ 4);
DBG(NATIVENET,
dprintf(" datagram_send() to %s:%d\n",
- ip2str(unhand(unhand(pkt)->address)->address),
+ ip2str(ntohl(addr.addr4.sin_addr.s_addr)),
+ unhand(pkt)->port);
+)
+
+#if defined(HAVE_STRUCT_SOCKADDR_IN6)
+ } else if (obj_length(unhand(unhand(pkt)->address)->addr) == 16) {
+#if defined(BSD44)
+ addr.addr6.sin6_len = sizeof(addr.addr6);
+#endif
+ addr.addr6.sin6_family = AF_INET6;
+ addr.addr6.sin6_port = htons(unhand(pkt)->port);
+ memcpy(&addr.addr6.sin6_addr, unhand_byte_array(unhand(unhand(pkt)->address)->addr),
+ sizeof(addr.addr6.sin6_addr));
+
+DBG(NATIVENET,
+ dprintf(" datagram_send() to %s / %d\n",
+ ip62str(&addr.addr6.sin6_addr),
unhand(pkt)->port);
)
+#endif
+
+ } else {
+ SignalError("java.net.SocketException", "Unsupported packet internet address");
+ }
rc = KSENDTO(unhand(unhand(this)->fd)->nativeFd,
unhand_array(unhand(pkt)->buffer)->body, unhand(pkt)->length,
- 0, (struct sockaddr*)&addr, sizeof(addr), &bsent);
+ 0, (struct sockaddr *)&addr, sizeof(addr), &bsent);
DBG(NATIVENET,
dprintf(" datagram_send() -> rc=%d bsent=%ld\n", rc, (long) bsent);
@@ -220,7 +286,7 @@
{
ssize_t r;
int rc;
- struct sockaddr_in saddr;
+ KaffeSocketAddr saddr;
int alen = sizeof(saddr);
rc = KRECVFROM(unhand(unhand(this)->fd)->nativeFd,
@@ -230,8 +296,15 @@
SignalError("java.net.SocketException", SYS_ERROR(rc));
}
- unhand(addr)->address = ntohl(saddr.sin_addr.s_addr);
-
+ if (saddr.addr4.sin_family == AF_INET) {
+ memcpy(unhand_byte_array(unhand(addr)->addr), &saddr.addr4.sin_addr, sizeof(saddr.addr4.sin_addr));
+#if defined(HAVE_STRUCT_SOCKADDR_IN6)
+ } else if (saddr.addr6.sin6_family == AF_INET6) {
+ memcpy(unhand_byte_array(unhand(addr)->addr), &saddr.addr6.sin6_addr, sizeof(saddr.addr6.sin6_addr));
+#endif
+ } else {
+ SignalError("java.net.SocketException", "Unsupported address family");
+ }
return ((jint)r);
}
@@ -240,10 +313,9 @@
{
ssize_t r;
int rc;
- struct sockaddr_in addr;
+ KaffeSocketAddr addr;
int alen = sizeof(addr);
HArrayOfByte *array_address;
- int i;
int to_read, offset;
assert(this != NULL);
@@ -257,7 +329,7 @@
)
/* Which port am I receiving from */
- addr.sin_port = htons(unhand(this)->localPort);
+ addr.addr4.sin_port = htons(unhand(this)->localPort);
/* XXX should assert (unhand(pkt)->length <= unhand_array(unhand(pkt)->buf)->length), no? */
offset = unhand(pkt)->offset;
@@ -295,15 +367,29 @@
} while (rc == EINTR);
unhand(pkt)->length = r;
- unhand(pkt)->port = ntohs(addr.sin_port);
-
- array_address = (HArrayOfByte*)AllocArray(4, TYPE_Byte);
- for (i=0;i<4;i++)
- unhand_array(array_address)->body[i] = (ntohl(addr.sin_addr.s_addr) >> (8*i)) & 0xFF;
- unhand(pkt)->address = (struct Hjava_net_InetAddress*)
- execute_java_constructor("java/net/InetAddress", 0, 0, "([B)V",
- array_address);
- unhand(unhand(pkt)->address)->address = ntohl(addr.sin_addr.s_addr);
+ unhand(pkt)->port = ntohs(addr.addr4.sin_port);
+
+ if (addr.addr4.sin_family == AF_INET) {
+ array_address = (HArrayOfByte*)AllocArray(sizeof(addr.addr4.sin_addr), TYPE_Byte);
+ memcpy(unhand_byte_array(array_address), &addr.addr4.sin_addr, sizeof(addr.addr4.sin_addr));
+
+ unhand(pkt)->address = (struct Hjava_net_InetAddress*)
+ execute_java_constructor("java/net/InetAddress", 0, 0, "([B)V",
+ array_address);
+#if defined(HAVE_STRUCT_SOCKADDR_IN6)
+ } else if (addr.addr6.sin6_family == AF_INET6) {
+ array_address = (HArrayOfByte*)AllocArray(sizeof(addr.addr6.sin6_addr), TYPE_Byte);
+ memcpy(unhand_byte_array(array_address), &addr.addr6.sin6_addr, sizeof(addr.addr6.sin6_addr));
+
+ unhand(pkt)->address = (struct Hjava_net_InetAddress*)
+ execute_java_constructor("java/net/Inet6Address", 0, 0, "([BLjava/lang/String;)V",
+ array_address);
+#endif
+
+ } else {
+ SignalError("java.net.SocketException", "Unsupported address family");
+ }
+
/* zero out hostname to overwrite old name which does not match
* the new address from which the packet came.
*/
@@ -311,8 +397,8 @@
DBG(NATIVENET,
dprintf(" datagram_receive(%p, %p) -> from %s:%d; brecv=%ld\n",
- this, pkt, ip2str(ntohl(addr.sin_addr.s_addr)),
- ntohs(addr.sin_port), (long) r);
+ this, pkt, ip2str(ntohl(addr.addr4.sin_addr.s_addr)),
+ ntohs(addr.addr4.sin_port), (long) r);
)
}
Index: kaffe/libraries/clib/net/PlainSocketImpl.c
diff -u kaffe/libraries/clib/net/PlainSocketImpl.c:1.33 kaffe/libraries/clib/net/PlainSocketImpl.c:1.34
--- kaffe/libraries/clib/net/PlainSocketImpl.c:1.33 Sun Sep 28 19:53:54 2003
+++ kaffe/libraries/clib/net/PlainSocketImpl.c Tue Oct 28 12:29:32 2003
@@ -95,6 +95,7 @@
{
static char addrbuf[16];
+ addr = ntohl(addr);
sprintf(addrbuf, "%u.%u.%u.%u",
(addr >> 24) & 0xff,
(addr >> 16) & 0xff,
@@ -102,6 +103,29 @@
(addr ) & 0xff);
return addrbuf;
}
+
+/* Generate a string for an inet6 addr (in host form). */
+static char *
+ip62str(struct in6_addr *addr)
+{
+ static char addrbuf[255];
+ int i, count;
+
+ for (count=0,i=0;i<16;i++) {
+ char *format;
+
+ if (i == 0 && addr->in6_u.u6_addr8[i] != 0)
+ format = "%x";
+ else if (addr->in6_u.u6_addr8[i] != 0)
+ format = "%x:";
+ else if (i != 0)
+ format = ":";
+ else
+ format = "";
+ count += sprintf(&addrbuf[count], format, addr->in6_u.u6_addr8[i]);
+ }
+ return addrbuf;
+}
#endif /* KAFFE_VMDEBUG */
/*
@@ -150,21 +174,37 @@
{
int fd;
int r;
- struct sockaddr_in addr;
+ KaffeSocketAddr addr;
int alen;
- DBG(NATIVENET,
- dprintf("socketConnect(%p, %s, %d, %d)\n",
- this, ip2str(unhand(daddr)->address), dport, timeout);
- )
-
memset(&addr, 0, sizeof(addr));
+ if (obj_length(unhand(daddr)->addr) == 4) {
#if defined(BSD44)
- addr.sin_len = sizeof(addr);
+ addr.addr4.sin_len = sizeof(addr.addr4);
#endif
- addr.sin_family = AF_INET;
- addr.sin_port = htons(dport);
- addr.sin_addr.s_addr = htonl(unhand(daddr)->address);
+ addr.addr4.sin_family = AF_INET;
+ addr.addr4.sin_port = htons(dport);
+ memcpy(&addr.addr4.sin_addr,
+ unhand_byte_array(unhand(daddr)->addr), sizeof(addr.addr4.sin_addr));
+#if defined(HAVE_STRUCT_SOCKADDR_IN6)
+ } else if (obj_length(unhand(daddr)->addr) == 16) {
+
+#if defined(BSD44)
+ addr.addr6.sin6_len = sizeof(addr.addr6);
+#endif
+ addr.addr6.sin6_family = AF_INET6;
+ addr.addr6.sin6_port = htons(dport);
+ memcpy(&addr.addr6.sin6_addr,
+ unhand_byte_array(unhand(daddr)->addr), sizeof(addr.addr6.sin6_addr));
+#endif
+ } else {
+ SignalError("java.net.SocketException", "Unsupported address family");
+ }
+
+ DBG(NATIVENET,
+ dprintf("socketConnect(%p, %s, %d, %d)\n",
+ this, ip2str(addr.addr4.sin_addr.s_addr), dport, timeout);
+ )
fd = (int)unhand(unhand(this)->fd)->nativeFd;
r = KCONNECT(fd, (struct sockaddr*)&addr, sizeof(addr), timeout);
@@ -193,14 +233,14 @@
DBG(NATIVENET,
dprintf("socketConnect(%p, %s, %d) -> (lport: %d)\n",
- this, ip2str(unhand(daddr)->address), dport,
- ntohs(addr.sin_port)
+ this, ip2str(addr.addr4.sin_addr.s_addr), dport,
+ ntohs(addr.addr4.sin_port)
);
)
unhand(this)->address = daddr;
unhand(this)->port = dport;
- unhand(this)->localport = ntohs(addr.sin_port);
+ unhand(this)->localport = ntohs(addr.addr4.sin_port);
}
/*
@@ -212,7 +252,7 @@
jint lport)
{
int r;
- struct sockaddr_in addr;
+ KaffeSocketAddr addr;
int fd;
int on = 1;
int alen;
@@ -223,13 +263,38 @@
)
memset(&addr, 0, sizeof(addr));
+ if (obj_length(unhand(laddr)->addr) == 4) {
#if defined(BSD44)
- addr.sin_len = sizeof(addr);
+ addr.addr4.sin_len = sizeof(addr.addr4);
#endif
- addr.sin_family = AF_INET;
- addr.sin_port = htons(lport);
- addr.sin_addr.s_addr = htonl(unhand(laddr)->address);
+ addr.addr4.sin_family = AF_INET;
+ addr.addr4.sin_port = htons(lport);
+ memcpy(&addr.addr4.sin_addr,
+ unhand_byte_array(unhand(laddr)->addr), sizeof(addr.addr4.sin_addr));
+
+ DBG(NATIVENET,
+ dprintf("socketBind(%p, %s, -) -> (lport: %d)\n", this,
+ ip2str(addr.addr4.sin_addr.s_addr), lport);
+ );
+#if defined(HAVE_STRUCT_SOCKADDR_IN6)
+ } else if (obj_length(unhand(laddr)->addr) == 16) {
+#if defined(BSD44)
+ addr.addr6.sin6_len = sizeof(addr.addr6);
+#endif
+ addr.addr6.sin6_family = AF_INET6;
+ addr.addr6.sin6_port = htons(lport);
+ memcpy(&addr.addr6.sin6_addr,
+ unhand_byte_array(unhand(laddr)->addr), sizeof(addr.addr6.sin6_addr));
+
+ DBG(NATIVENET,
+ dprintf("socketBind(%p, %s, -) -> (lport: %d)\n", this,
+ ip62str(&addr.addr6.sin6_addr), lport);
+ );
+#endif
+ } else {
+ SignalError("java.net.SocketException", "Unsupported address family");
+ }
fd = (int)unhand(unhand(this)->fd)->nativeFd;
/* Allow rebinding to socket - ignore errors */
@@ -257,14 +322,9 @@
if (r) {
SignalError("java.io.IOException", SYS_ERROR(r));
}
- lport = ntohs(addr.sin_port);
+ lport = ntohs(addr.addr4.sin_port);
}
unhand(this)->localport = lport;
-
- DBG(NATIVENET,
- dprintf("socketBind(%p, %s, -) -> (lport: %d)\n", this,
- ip2str(unhand(laddr)->address), lport);
- );
}
/*
@@ -305,14 +365,14 @@
addr.sin_family = AF_INET;
addr.sin_port = htons(unhand(sock)->localport);
/* I guess the next line is too much as unhand(sock)->address is not supposed
- * to be initilized.
+ * to be initialized.
* addr.sin_addr.s_addr = htonl(unhand(unhand(sock)->address)->address);
*/
addr.sin_addr.s_addr = INADDR_ANY;
DBG(NATIVENET,
dprintf("socketAccept(%p, localport=%d, addr=%s)\n",
- this, ntohs(addr.sin_port), ip2str(ntohl(addr.sin_addr.s_addr)));
+ this, ntohs(addr.sin_port), ip2str(addr.sin_addr.s_addr));
)
alen = sizeof(addr);
@@ -371,7 +431,7 @@
DBG(NATIVENET,
dprintf("socketAccept(%p, localport=-, addr=-) -> (sock: %p; addr: %s; port:%d)\n",
- this, sock, ip2str(ntohl(addr.sin_addr.s_addr)), ntohs(addr.sin_port));
+ this, sock, ip2str(addr.sin_addr.s_addr), ntohs(addr.sin_port));
)
}
===================================================================
Checking out kaffe/libraries/clib/nio/DirectByteBufferImpl.c
RCS: /home/cvs/kaffe/kaffe/libraries/clib/nio/DirectByteBufferImpl.c,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/clib/nio/DirectByteBufferImpl.c Tue Oct 28 12:31:41 2003
@@ -0,0 +1,38 @@
+/*
+ * DirectByteBufferImpl.c
+ *
+ * Copyright (c) 2003 Kaffe's team.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#include "config.h"
+#include "config-std.h"
+#include "kaffe/jmalloc.h"
+#include "java_nio_DirectByteBufferImpl.h"
+
+struct Hgnu_classpath_RawData*
+java_nio_DirectByteBufferImpl_allocateImpl(jint bytes)
+{
+ return (struct Hgnu_classpath_RawData*)jmalloc(bytes);
+}
+
+void
+java_nio_DirectByteBufferImpl_freeImpl(struct Hgnu_classpath_RawData* data)
+{
+ jfree(data);
+}
+
+jbyte
+java_nio_DirectByteBufferImpl_getImpl(struct Hjava_nio_DirectByteBufferImpl* this, jint index)
+{
+ return ((jbyte *)unhand(this)->address)[index];
+}
+
+void
+java_nio_DirectByteBufferImpl_putImpl(struct Hjava_nio_DirectByteBufferImpl* this, jint index,
+ jbyte b)
+{
+ ((jbyte *)unhand(this)->address)[index] = b;
+}
===================================================================
Checking out kaffe/libraries/clib/nio/Makefile.am
RCS: /home/cvs/kaffe/kaffe/libraries/clib/nio/Makefile.am,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/clib/nio/Makefile.am Tue Oct 28 12:31:41 2003
@@ -0,0 +1,17 @@
+# New IO subsystem (NIO) support for Java libraries
+#
+# Copyright (c) 2003 Kaffe's team
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file.
+
+AM_CPPFLAGS = -I$(top_builddir)/include
+native_LTLIBRARIES = libnio.la
+
+libnio_la_LDFLAGS = $(KLIBFLAGS) -module -release $(KVER) -export-symbols-regex "^([Jj]ava|kaffe)_"
+libnio_la_SOURCES = \
+ DirectByteBufferImpl.c \
+ SelectorImpl.c \
+ NIOServerSocket.c
+
+CLEANFILES = so_locations
===================================================================
Checking out kaffe/libraries/clib/nio/Makefile.in
RCS: /home/cvs/kaffe/kaffe/libraries/clib/nio/Makefile.in,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/clib/nio/Makefile.in Tue Oct 28 12:31:42 2003
@@ -0,0 +1,562 @@
+# Makefile.in generated by automake 1.7.8 from Makefile.am.
+# @configure_input@
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+# New IO subsystem (NIO) support for Java libraries
+#
+# Copyright (c) 2003 Kaffe's team
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file.
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ../../..
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_triplet = @host@
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AWT_DIR = @AWT_DIR@
+AWT_LIBS = @AWT_LIBS@
+BCEL_JAR = @BCEL_JAR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CCLD = @CCLD@
+CFLAGS = @CFLAGS@
+CFLAGS_WITHOUT_PG = @CFLAGS_WITHOUT_PG@
+COND_PURE_JAVA_MATH_FALSE = @COND_PURE_JAVA_MATH_FALSE@
+COND_PURE_JAVA_MATH_TRUE = @COND_PURE_JAVA_MATH_TRUE@
+COND_SOUND_ALSA_FALSE = @COND_SOUND_ALSA_FALSE@
+COND_SOUND_ALSA_TRUE = @COND_SOUND_ALSA_TRUE@
+COND_SOUND_ESD_FALSE = @COND_SOUND_ESD_FALSE@
+COND_SOUND_ESD_TRUE = @COND_SOUND_ESD_TRUE@
+CONFIG_JIT_MD_H = @CONFIG_JIT_MD_H@
+CONFIG_MD_H = @CONFIG_MD_H@
+CONFIG_XPROFILE_MD_H = @CONFIG_XPROFILE_MD_H@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DIRSEP = @DIRSEP@
+DLOPEN_JAVA_LIBS = @DLOPEN_JAVA_LIBS@
+DNSJAVA_JAR = @DNSJAVA_JAR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ENABLE_JVMPI_FALSE = @ENABLE_JVMPI_FALSE@
+ENABLE_JVMPI_TRUE = @ENABLE_JVMPI_TRUE@
+ENABLE_XPROF_FALSE = @ENABLE_XPROF_FALSE@
+ENABLE_XPROF_TRUE = @ENABLE_XPROF_TRUE@
+ENGINE_NAME = @ENGINE_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+HAVE_BCEL_FALSE = @HAVE_BCEL_FALSE@
+HAVE_BCEL_TRUE = @HAVE_BCEL_TRUE@
+HAVE_CONFIG_JIT_MD_H = @HAVE_CONFIG_JIT_MD_H@
+HAVE_DNSJAVA_FALSE = @HAVE_DNSJAVA_FALSE@
+HAVE_DNSJAVA_TRUE = @HAVE_DNSJAVA_TRUE@
+HAVE_GCJ_SUPPORT_FALSE = @HAVE_GCJ_SUPPORT_FALSE@
+HAVE_GCJ_SUPPORT_TRUE = @HAVE_GCJ_SUPPORT_TRUE@
+HAVE_JASMIN_FALSE = @HAVE_JASMIN_FALSE@
+HAVE_JASMIN_TRUE = @HAVE_JASMIN_TRUE@
+HAVE_JIKES_FALSE = @HAVE_JIKES_FALSE@
+HAVE_JIKES_TRUE = @HAVE_JIKES_TRUE@
+HAVE_MKTEMP_FALSE = @HAVE_MKTEMP_FALSE@
+HAVE_MKTEMP_TRUE = @HAVE_MKTEMP_TRUE@
+HAVE_ZIP_FALSE = @HAVE_ZIP_FALSE@
+HAVE_ZIP_TRUE = @HAVE_ZIP_TRUE@
+INCLUDED_EXTENSIONS = @INCLUDED_EXTENSIONS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JASMIN = @JASMIN@
+JAVA_LIBS = @JAVA_LIBS@
+JIKES = @JIKES@
+JIKESPROG = @JIKESPROG@
+KAFFEH = @KAFFEH@
+KAFFEVM_ICODE_H = @KAFFEVM_ICODE_H@
+KAFFEVM_JIT_DEF = @KAFFEVM_JIT_DEF@
+KAFFEVM_MD_C = @KAFFEVM_MD_C@
+KAFFEVM_TRAMPOLINES_C = @KAFFEVM_TRAMPOLINES_C@
+KAFFE_ARCHOS = @KAFFE_ARCHOS@
+KAFFE_LIBS = @KAFFE_LIBS@
+KLIBFLAGS = @KLIBFLAGS@
+KPREFIX = @KPREFIX@
+KVER = @KVER@
+KVMBINFLAGS = @KVMBINFLAGS@
+KVMLIBFLAGS = @KVMLIBFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBLTDL = @LIBLTDL@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBTOOL_DEPS = @LIBTOOL_DEPS@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAKEINFO = @MAKEINFO@
+MAKE_KAFFEH = @MAKE_KAFFEH@
+MATH_LIB = @MATH_LIB@
+MATH_LIBS = @MATH_LIBS@
+MKTEMP = @MKTEMP@
+MOC = @MOC@
+M_LIBS = @M_LIBS@
+NEED_LIBXPROF_FALSE = @NEED_LIBXPROF_FALSE@
*** Patch too long, truncated ***
More information about the kaffe
mailing list