Bug#561977: Patch to make Netris IPv6-enabled

2010-03-05 Thread Mats Erik Andersson
Clearly the network stack in the Linux kernel or the glibc has undergone
important changes since Lenny and linux-image_2.6.26-2-686.

The original patch was developped on a Lenny system. I now send a modified
patch that works with any combination of client and server from

Debian Lenny kernel 2.6.26-2-686,

Debian testing/squeeze kernel 2.6.30-2-686

FreeBSD 6.4

The use of AI_V4MAPPED had to go since FreeBSD must have AF_INET6
for that flag to avoid throwing a runtime exception.

Contrary to the statements in getaddrinfo(2) it was necessary to
specify AF_INET6 for the passive listening socket for kernel 2.6.30;
with AF_UNSPEC the only listener sat with IPv4. I am much disturbed
with this fact, since I now cannot foresee how a Linux machine
using a IPv4-only stack will behave.
 
fredag den  5 mars 2010 klockan 10:35 skrev Gerfried Fuchs detta:
> 
> >
> > Similar but different - I use multiple sockets rather than mapped
> > address (so that it can run on other systems such as *BSDs or
> > Solaris).
> 
>  Then I guess I'll have to give your patch a try and not use Mats
> because we also have kFreeBSD these days in Debian. :)
> 
>  Will try to extract it - but it might take some days until I get around
> to give it a proper test.

-- 
Mats Erik Andersson, fil. dr

Abbonerar på: debian-mentors, debian-devel-games, debian-perl, debian-ipv6
diff -u netris-0.52/debian/changelog netris-0.52/debian/changelog
--- netris-0.52/debian/changelog
+++ netris-0.52/debian/changelog
@@ -1,3 +1,11 @@
+netris (0.52-7.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Implement support for IPv6:
+- debian/patches/09_inet.c-ipv6
+
+ -- Mats Erik Andersson   Wed, 03 Mar 2010 11:33:17 +0100
+
 netris (0.52-7) unstable; urgency=low
 
   * The "once every release" release.
diff -u netris-0.52/debian/patches/series netris-0.52/debian/patches/series
--- netris-0.52/debian/patches/series
+++ netris-0.52/debian/patches/series
@@ -8,0 +9 @@
+09_inet.c-ipv6
only in patch2:
unchanged:
--- netris-0.52.orig/debian/patches/09_inet.c-ipv6
+++ netris-0.52/debian/patches/09_inet.c-ipv6
@@ -0,0 +1,205 @@
+Description: Implement capability for IPv6.
+ Migration to 'getaddrinfo()' and 'struct sockaddr_storage'
+ make both address families AF_INET and AF_INET6 viable.
+ .
+ The preferred form of a port is as a string value in getaddrinfo(),
+ so named ports are no possible, alongside numerical ports.
+ .
+ The goto statement is left because the previous code enforced
+ a similar construct. It should really be removed.
+Author: Mats Erik Andersson 
+Forwarded: no
+Last-Updated: 2010-03-05
+--- netris-0.52/inet.c.debian
 netris-0.52/inet.c
+@@ -49,32 +49,60 @@
+ 
+ ExtFunc int WaitForConnection(char *portStr)
+ {
+-	struct sockaddr_in addr;
+-	struct hostent *host;
+-	int sockListen;
++	struct sockaddr_storage addr;
++	struct sockaddr_in *sa4 = (struct sockaddr_in *) &addr;
++	struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *) &addr;
++	struct hostent *host = NULL;
++	struct addrinfo hints, *ai, *aiptr;
++	char portStrDef[12];
++	int sockListen, status;
+ 	socklen_t addrLen;
+-	short port;
+ 	int val1;
+ 	struct linger val2;
+ 
+-	if (portStr)
+-		port = atoi(portStr);	/* XXX Error checking */
+-	else
+-		port = DEFAULT_PORT;
+-	memset(&addr, 0, sizeof(addr));
+-	addr.sin_family = AF_INET;
+-	addr.sin_addr.s_addr = htonl(INADDR_ANY);
+-	addr.sin_port = htons(port);
+-	sockListen = socket(AF_INET, SOCK_STREAM, 0);
+-	if (sockListen < 0)
++	if (!portStr || !strlen(portStr)) {
++		snprintf(portStrDef, sizeof(portStrDef), "%u", DEFAULT_PORT);
++		portStr = portStrDef;
++	}
++	/* XXX Error checking of port string. */
++
++	memset(&hints, 0, sizeof(hints));
++	hints.ai_family = AF_INET6;
++	hints.ai_socktype = SOCK_STREAM;
++	hints.ai_flags = AI_PASSIVE;
++
++	if ( (status = getaddrinfo(NULL, portStr, &hints, &ai)) ) {
++		fprintf(stderr, "getaddrinfo() failed: %s\n",
++gai_strerror(status));
++		die("getaddrinfo");
++	}
++
++	for (aiptr = ai; aiptr; aiptr = aiptr->ai_next) {
++		if ( (sockListen = socket(aiptr->ai_family,
++		aiptr->ai_socktype,
++		aiptr->ai_protocol))
++< 0 )
++			continue;
++
++		val1 = 1;
++		setsockopt(sockListen, SOL_SOCKET, SO_REUSEADDR,
++(void *)&val1, sizeof(val1));
++		val1 = 0;
++		setsockopt(sockListen, IPPROTO_IPV6, IPV6_V6ONLY,
++(void *)&val1, sizeof(val1));
++
++		if ( bind(sockListen, aiptr->ai_addr, aiptr->ai_addrlen)
++== 0 )
++			if ( listen(sockListen, 1) >= 0 )
++break;
++
++		close(sockListen);
++	}
++
++	freeaddrinfo(ai);
++	if (aiptr == NULL)
+ 		die("socket");
+-	val1 = 1;
+-	setsockopt(sockListen, SOL_SOCKET, SO_REUSEADDR,
+-			(void *)&val1, sizeof(val1));
+-	if (bind(sockListen, (struct sockaddr *)&addr, sizeof(addr)) < 0)
+-		die("bind");
+-	if (listen(sockListen, 1) < 0)
+-		die("listen");
++
+ 	addrLen = sizeof(addr);
+ 	sock = accept(sockListen, (struct sockaddr *)&addr, &addrLen);
+ 	if (sock < 0)
+@@ -86,13 +114,18 @@
+ 			(void *)&val2, sizeof

Bug#561977: Patch to make Netris IPv6-enabled

2010-03-05 Thread Gerfried Fuchs
Hi!

* YOSHIFUJI Hideaki  [2010-03-05 10:29:04 CET]:
> (2010/03/05 17:55), Gerfried Fuchs wrote:
>> * YOSHIFUJI Hideaki  [2010-03-05 07:27:07 CET]:
>>> Or via git/gitweb:
>>> git://git.linux-ipv6.org/gitroot/yoshfuji/netris.git
>>> http://www.linux-ipv6.org/gitweb/gitweb.cgi?p=gitroot/yoshfuji/netris.git
>>
>>   Is the patch you have in there different from the one that Mats did
>> send in? Does the repository also contain other changes that might be
>> relevant?
>
> Similar but different - I use multiple sockets rather than mapped
> address (so that it can run on other systems such as *BSDs or
> Solaris).

 Then I guess I'll have to give your patch a try and not use Mats
because we also have kFreeBSD these days in Debian. :)

 Will try to extract it - but it might take some days until I get around
to give it a proper test.

 Thanks,
Rhonda



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#561977: Patch to make Netris IPv6-enabled

2010-03-05 Thread YOSHIFUJI Hideaki

(2010/03/05 17:55), Gerfried Fuchs wrote:

 Hi!

* YOSHIFUJI Hideaki  [2010-03-05 07:27:07 CET]:

Maybe because of AI_ADDRCONFIG flag.
Do you have IPv6 global address?


  Yes, I did have one and some collegue was able to ping6 me, so it was
also reachable.


Hmm


BTW, my 9-year-old tree is available via anoncvs/viewcvs/ftp:
cvs -d :pserver:anon...@cvs.linux-ipv6.org:/cvsroot/apps co netris
http://www.linux-ipv6.org/cvsweb/netris/?cvsroot=usagi-apps
ftp://ftp.linux-ipv6.org/pub/ftp.v6.linux.or.jp/IPv6-2/IPv6_Patched_Apps/netris/

Or via git/gitweb:
git://git.linux-ipv6.org/gitroot/yoshfuji/netris.git
http://www.linux-ipv6.org/gitweb/gitweb.cgi?p=gitroot/yoshfuji/netris.git


  Is the patch you have in there different from the one that Mats did
send in? Does the repository also contain other changes that might be
relevant?


Similar but different - I use multiple sockets rather than mapped
address (so that it can run on other systems such as *BSDs or
Solaris).

My patch is basically about 9 years old (I did it in 1999-2000) and
it does not contain other changes than ipv6 bits.
(Note use --enable-ipv6 when you run Configure script.)

Regards,

--yoshfuji



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#561977: Patch to make Netris IPv6-enabled

2010-03-05 Thread Gerfried Fuchs
Hi!

* YOSHIFUJI Hideaki  [2010-03-05 07:27:07 CET]:
> Maybe because of AI_ADDRCONFIG flag.
> Do you have IPv6 global address?

 Yes, I did have one and some collegue was able to ping6 me, so it was
also reachable.

> BTW, my 9-year-old tree is available via anoncvs/viewcvs/ftp:
> cvs -d :pserver:anon...@cvs.linux-ipv6.org:/cvsroot/apps co netris
> http://www.linux-ipv6.org/cvsweb/netris/?cvsroot=usagi-apps
> ftp://ftp.linux-ipv6.org/pub/ftp.v6.linux.or.jp/IPv6-2/IPv6_Patched_Apps/netris/
>
> Or via git/gitweb:
> git://git.linux-ipv6.org/gitroot/yoshfuji/netris.git
> http://www.linux-ipv6.org/gitweb/gitweb.cgi?p=gitroot/yoshfuji/netris.git

 Is the patch you have in there different from the one that Mats did
send in? Does the repository also contain other changes that might be
relevant?

 Thanks,
Rhonda



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#561977: Patch to make Netris IPv6-enabled

2010-03-04 Thread YOSHIFUJI Hideaki

Maybe because of AI_ADDRCONFIG flag.
Do you have IPv6 global address?

BTW, my 9-year-old tree is available via anoncvs/viewcvs/ftp:
cvs -d :pserver:anon...@cvs.linux-ipv6.org:/cvsroot/apps co netris
http://www.linux-ipv6.org/cvsweb/netris/?cvsroot=usagi-apps
ftp://ftp.linux-ipv6.org/pub/ftp.v6.linux.or.jp/IPv6-2/IPv6_Patched_Apps/netris/

Or via git/gitweb:
git://git.linux-ipv6.org/gitroot/yoshfuji/netris.git
http://www.linux-ipv6.org/gitweb/gitweb.cgi?p=gitroot/yoshfuji/netris.git

Regards,

--yoshfuji

(2010/03/05 6:07), Gerfried Fuchs wrote:

Hi!

* Gerfried Fuchs  [2010-03-03 12:51:31 CET]:

* Mats Erik Andersson  [2010-03-03 12:03:07 CET]:

I submit an NMU-formed difference file that adds capability
to Netris for using IPv6 as well as IPv4. It is a Quilt patch
that implements this capability.


  Sweet!!  Thanks, I'll give it a try and hopefully will be able to
upload within the next week or such. I expect you also tested it with
disabled ipv6 module?


  Unfortunately the patch doesn't seem to be complete. "netris -w" binds
with that patch still only to tcp 0.0.0.0:port and not to tcp6. Can
someone go over the patch again and give it some deeper looks?

  Thanks!
Rhonda







--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#561977: Patch to make Netris IPv6-enabled

2010-03-04 Thread Mats Erik Andersson
torsdag den  4 mars 2010 klockan 22:07 skrev Gerfried Fuchs detta:
>   Hi!
> 
> * Gerfried Fuchs  [2010-03-03 12:51:31 CET]:
> > * Mats Erik Andersson  [2010-03-03 12:03:07 
> > CET]:
> > > I submit an NMU-formed difference file that adds capability
> > > to Netris for using IPv6 as well as IPv4. It is a Quilt patch
> > > that implements this capability.
> > 
> >  Sweet!!  Thanks, I'll give it a try and hopefully will be able to
> > upload within the next week or such. I expect you also tested it with
> > disabled ipv6 module?
> 
>  Unfortunately the patch doesn't seem to be complete. "netris -w" binds
> with that patch still only to tcp 0.0.0.0:port and not to tcp6. Can
> someone go over the patch again and give it some deeper looks?
> 

It does bind tcp6 to ':::9284' on my machine.

-- 
Mats Erik Andersson, fil. dr



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#561977: Patch to make Netris IPv6-enabled

2010-03-04 Thread Gerfried Fuchs
Hi!

* Gerfried Fuchs  [2010-03-03 12:51:31 CET]:
> * Mats Erik Andersson  [2010-03-03 12:03:07 
> CET]:
> > I submit an NMU-formed difference file that adds capability
> > to Netris for using IPv6 as well as IPv4. It is a Quilt patch
> > that implements this capability.
> 
>  Sweet!!  Thanks, I'll give it a try and hopefully will be able to
> upload within the next week or such. I expect you also tested it with
> disabled ipv6 module?

 Unfortunately the patch doesn't seem to be complete. "netris -w" binds
with that patch still only to tcp 0.0.0.0:port and not to tcp6. Can
someone go over the patch again and give it some deeper looks?

 Thanks!
Rhonda



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#561977: Patch to make Netris IPv6-enabled

2010-03-03 Thread Gerfried Fuchs
Hi!

* Mats Erik Andersson  [2010-03-03 12:03:07 CET]:
> I submit an NMU-formed difference file that adds capability
> to Netris for using IPv6 as well as IPv4. It is a Quilt patch
> that implements this capability.

 Sweet!!  Thanks, I'll give it a try and hopefully will be able to
upload within the next week or such. I expect you also tested it with
disabled ipv6 module?

 Have fun!
Rhonda



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#561977: Patch to make Netris IPv6-enabled

2010-03-03 Thread Mats Erik Andersson
package netris
tags 561977 + patch
thanks

I submit an NMU-formed difference file that adds capability
to Netris for using IPv6 as well as IPv4. It is a Quilt patch
that implements this capability.

-- 
Mats Erik Andersson, fil. dr


Abbonerar på: debian-mentors, debian-devel-games, debian-perl, debian-ipv6
diff -u netris-0.52/debian/changelog netris-0.52/debian/changelog
--- netris-0.52/debian/changelog
+++ netris-0.52/debian/changelog
@@ -1,3 +1,11 @@
+netris (0.52-7.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Implement support for IPv6:
+- debian/patches/09_inet.c-ipv6
+
+ -- Mats Erik Andersson   Wed, 03 Mar 2010 11:33:17 +0100
+
 netris (0.52-7) unstable; urgency=low
 
   * The "once every release" release.
diff -u netris-0.52/debian/patches/series netris-0.52/debian/patches/series
--- netris-0.52/debian/patches/series
+++ netris-0.52/debian/patches/series
@@ -8,0 +9 @@
+09_inet.c-ipv6
only in patch2:
unchanged:
--- netris-0.52.orig/debian/patches/09_inet.c-ipv6
+++ netris-0.52/debian/patches/09_inet.c-ipv6
@@ -0,0 +1,205 @@
+Description: Implement capability for IPv6.
+ Migration to 'getaddrinfo()' and 'struct sockaddr_storage'
+ make both address families AF_INET and AF_INET6 viable.
+ .
+ The preferred form of a port is as a string value in getaddrinfo(),
+ so named ports are no possible, alongside numerical ports.
+ .
+ The goto statement is left because the previous code enforced
+ a similar construct. It should really be removed.
+Author: Mats Erik Andersson 
+Forwarded: no
+Last-Updated: 2010-03-03
+--- netris-0.52/inet.c.debian
 netris-0.52/inet.c
+@@ -49,32 +49,60 @@
+ 
+ ExtFunc int WaitForConnection(char *portStr)
+ {
+-	struct sockaddr_in addr;
+-	struct hostent *host;
+-	int sockListen;
++	struct sockaddr_storage addr;
++	struct sockaddr_in *sa4 = (struct sockaddr_in *) &addr;
++	struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *) &addr;
++	struct hostent *host = NULL;
++	struct addrinfo hints, *ai, *aiptr;
++	char portStrDef[12];
++	int sockListen, status;
+ 	socklen_t addrLen;
+-	short port;
+ 	int val1;
+ 	struct linger val2;
+ 
+-	if (portStr)
+-		port = atoi(portStr);	/* XXX Error checking */
+-	else
+-		port = DEFAULT_PORT;
+-	memset(&addr, 0, sizeof(addr));
+-	addr.sin_family = AF_INET;
+-	addr.sin_addr.s_addr = htonl(INADDR_ANY);
+-	addr.sin_port = htons(port);
+-	sockListen = socket(AF_INET, SOCK_STREAM, 0);
+-	if (sockListen < 0)
++	if (!portStr || !strlen(portStr)) {
++		snprintf(portStrDef, sizeof(portStrDef), "%u", DEFAULT_PORT);
++		portStr = portStrDef;
++	}
++	/* XXX Error checking of port string. */
++
++	memset(&hints, 0, sizeof(hints));
++	hints.ai_family = AF_UNSPEC;
++	hints.ai_socktype = SOCK_STREAM;
++	hints.ai_flags = AI_PASSIVE | AI_V4MAPPED | AI_ADDRCONFIG;
++
++	if ( (status = getaddrinfo(NULL, portStr, &hints, &ai)) ) {
++		fprintf(stderr, "getaddrinfo() failed: %s\n",
++gai_strerror(status));
++		die("getaddrinfo");
++	}
++
++	for (aiptr = ai; aiptr; aiptr = aiptr->ai_next) {
++		if ( (sockListen = socket(aiptr->ai_family,
++		aiptr->ai_socktype,
++		aiptr->ai_protocol))
++< 0 )
++			continue;
++
++		val1 = 1;
++		setsockopt(sockListen, SOL_SOCKET, SO_REUSEADDR,
++(void *)&val1, sizeof(val1));
++		val1 = 0;
++		setsockopt(sockListen, IPPROTO_IPV6, IPV6_V6ONLY,
++(void *)&val1, sizeof(val1));
++
++		if ( bind(sockListen, aiptr->ai_addr, aiptr->ai_addrlen)
++== 0 )
++			if ( listen(sockListen, 1) >= 0 )
++break;
++
++		close(sockListen);
++	}
++
++	freeaddrinfo(ai);
++	if (aiptr == NULL)
+ 		die("socket");
+-	val1 = 1;
+-	setsockopt(sockListen, SOL_SOCKET, SO_REUSEADDR,
+-			(void *)&val1, sizeof(val1));
+-	if (bind(sockListen, (struct sockaddr *)&addr, sizeof(addr)) < 0)
+-		die("bind");
+-	if (listen(sockListen, 1) < 0)
+-		die("listen");
++
+ 	addrLen = sizeof(addr);
+ 	sock = accept(sockListen, (struct sockaddr *)&addr, &addrLen);
+ 	if (sock < 0)
+@@ -86,13 +114,18 @@
+ 			(void *)&val2, sizeof(val2));
+ 	netGen.fd = sock;
+ 	strcpy(opponentHost, "???");
+-	if (addr.sin_family == AF_INET) {
+-		host = gethostbyaddr((void *)&addr.sin_addr,
+-sizeof(struct in_addr), AF_INET);
+-		if (host) {
+-			strncpy(opponentHost, host->h_name, sizeof(opponentHost)-1);
+-			opponentHost[sizeof(opponentHost)-1] = 0;
+-		}
++	switch (addr.ss_family) {
++		case AF_INET6:
++			host = gethostbyaddr((void *)&sa6->sin6_addr,
++sizeof(struct in6_addr), addr.ss_family);
++			break;
++		case AF_INET:
++			host = gethostbyaddr((void *)&sa4->sin_addr,
++sizeof(struct in_addr), addr.ss_family);
++	}
++	if (host) {
++		strncpy(opponentHost, host->h_name, sizeof(opponentHost)-1);
++		opponentHost[sizeof(opponentHost)-1] = 0;
+ 	}
+ 	AddEventGen(&netGen);
+ 	isServer = 1;
+@@ -101,36 +134,54 @@
+ 
+ ExtFunc int InitiateConnection(char *hostStr, char *portStr)
+ {
+-	struct sockaddr_in addr;
+-	struct hostent *host;
+-	short port;
+-	int mySock;
+-
+-	if (portStr)
+-		port = atoi(portStr);	/* XXX Error checking */
+-	else