[kaffe] CVS kaffe (guilhem): FreeBSD NET fixes.

Kaffe CVS cvs-commits at kaffe.org
Tue Nov 4 12:45:02 PST 2003


PatchSet 4156 
Date: 2003/11/04 20:42:39
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
FreeBSD NET fixes.

Members: 
	ChangeLog:1.1748->1.1749 
	libraries/clib/net/PlainDatagramSocketImpl.c:1.34->1.35 
	libraries/clib/net/PlainSocketImpl.c:1.35->1.36 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1748 kaffe/ChangeLog:1.1749
--- kaffe/ChangeLog:1.1748	Mon Nov  3 05:57:40 2003
+++ kaffe/ChangeLog	Tue Nov  4 20:42:39 2003
@@ -1,4 +1,15 @@
+2003-11-04  Guilhem Lavaux <guilhem at kaffe.org>
+
+	* libraries/clib/net/PlainDatagramSocketImpl.c:
+	(bind, send) Compute the exact address length to pass to syscalls.
+	This is required for FreeBSD as reported by
+	Ito Kazumitsu <kaz at maczuka.gcd.org>.
+
+	* libraries/clib/net/PlainSocketImpl.c:
+	(bind, connect) Same commentary.
+
 2003-11-03  Dalibor Topic  <robilad at kaffe.org>
+
 	* kaffe/kaffeh/support.c:
 	(kaffeh_findClass) Changed type of buf to unsigned char* to
 	fix -pedantic warnings.
Index: kaffe/libraries/clib/net/PlainDatagramSocketImpl.c
diff -u kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.34 kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.35
--- kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.34	Thu Oct 30 16:49:50 2003
+++ kaffe/libraries/clib/net/PlainDatagramSocketImpl.c	Tue Nov  4 20:42:41 2003
@@ -141,6 +141,7 @@
 
 	memset(&addr, 0, sizeof(addr));
 	if (obj_length(unhand(laddr)->addr) == 4) {
+		alen = sizeof(addr.addr4);
 #if defined(BSD44)
 		addr.addr4.sin_len = sizeof(addr.addr4);
 #endif
@@ -155,6 +156,7 @@
 )
 #if defined(HAVE_STRUCT_SOCKADDR_IN6)
 	} else if (obj_length(unhand(laddr)->addr) == 16) {
+		alen = sizeof(addr.addr6);
 #if defined(BSD44)
 		addr.addr6.sin6_len = sizeof(addr.addr6);
 #endif
@@ -172,7 +174,7 @@
 		SignalError("java.net.SocketException", "Unsupported address family");
 	}
 
-	r = KBIND(fd, (struct sockaddr*)&addr, sizeof(addr));
+	r = KBIND(fd, (struct sockaddr*)&addr, alen);
 	switch( r )
 	{
 	case 0:
@@ -209,6 +211,7 @@
 	int rc;
 	ssize_t bsent;
 	KaffeSocketAddr addr;
+	int alen;
 	
 DBG(NATIVENET,
 	dprintf("datagram_send(%p, %p [%d bytes])\n",
@@ -217,6 +220,7 @@
 
         memset(&addr, 0, sizeof(addr));
         if (obj_length(unhand(unhand(pkt)->address)->addr) == 4) {
+	    alen = sizeof(addr.addr4);
 #if defined(BSD44)
 	    addr.addr4.sin_len = sizeof(addr.addr4);
 #endif
@@ -232,6 +236,7 @@
 
 #if defined(HAVE_STRUCT_SOCKADDR_IN6)
 	} else if (obj_length(unhand(unhand(pkt)->address)->addr) == 16) {
+	    alen = sizeof(addr.addr6);
 #if defined(BSD44)
 	    addr.addr6.sin6_len = sizeof(addr.addr6);
 #endif
@@ -253,7 +258,7 @@
 
 	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, alen, &bsent);
 
 DBG(NATIVENET,
 	dprintf("  datagram_send() -> rc=%d bsent=%ld\n", rc, (long) bsent);
Index: kaffe/libraries/clib/net/PlainSocketImpl.c
diff -u kaffe/libraries/clib/net/PlainSocketImpl.c:1.35 kaffe/libraries/clib/net/PlainSocketImpl.c:1.36
--- kaffe/libraries/clib/net/PlainSocketImpl.c:1.35	Thu Oct 30 08:16:05 2003
+++ kaffe/libraries/clib/net/PlainSocketImpl.c	Tue Nov  4 20:42:41 2003
@@ -179,6 +179,7 @@
 
 	memset(&addr, 0, sizeof(addr));
 	if (obj_length(unhand(daddr)->addr) == 4) {
+	        alen = sizeof(addr.addr4); 
 #if defined(BSD44)
 		addr.addr4.sin_len = sizeof(addr.addr4);
 #endif
@@ -188,7 +189,7 @@
 		       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) {
-
+	        alen = sizeof(addr.addr6);
 #if defined(BSD44)
 		addr.addr6.sin6_len = sizeof(addr.addr6);
 #endif
@@ -207,7 +208,7 @@
 	    )
 
 	fd = (int)unhand(unhand(this)->fd)->nativeFd;
-	r = KCONNECT(fd, (struct sockaddr*)&addr, sizeof(addr), timeout);
+	r = KCONNECT(fd, (struct sockaddr*)&addr, alen, timeout);
 	if (r == EINTR) {
 		SignalError("java.io.InterruptedIOException", 
 			    "Connect was interrupted");
@@ -264,6 +265,7 @@
 
 	memset(&addr, 0, sizeof(addr));
 	if (obj_length(unhand(laddr)->addr) == 4) {
+	        alen = sizeof(addr.addr4);
 #if defined(BSD44)
 		addr.addr4.sin_len = sizeof(addr.addr4);
 #endif
@@ -278,7 +280,7 @@
 		    );
 #if defined(HAVE_STRUCT_SOCKADDR_IN6)
 	} else if (obj_length(unhand(laddr)->addr) == 16) {
-
+	        alen = sizeof(addr.addr6);
 #if defined(BSD44)
 		addr.addr6.sin6_len = sizeof(addr.addr6);
 #endif
@@ -299,7 +301,7 @@
 
 	/* Allow rebinding to socket - ignore errors */
 	(void)KSETSOCKOPT(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof(on));
-	r = KBIND(fd, (struct sockaddr*)&addr, sizeof(addr));
+	r = KBIND(fd, (struct sockaddr*)&addr, alen);
 	switch( r )
 	{
 	case 0:




More information about the kaffe mailing list