From chris@leishman.org  Sun Dec  8 00:34:07 2002
Return-Path: <chris@leishman.org>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from oulu.fi (ousrvr.oulu.fi [130.231.240.1])
	by liston.ferrara.linux.it (Postfix) with ESMTP id E51081F7049
	for <ds6-devel@deepspace6.net>; Sun,  8 Dec 2002 00:34:06 +0100 (CET)
Received: from leishman.org (angela-dsl.oulu.fi [130.231.168.252])
	by oulu.fi (8.8.5/8.8.5) with ESMTP id BAA04407
	for <ds6-devel@deepspace6.net>; Sun, 8 Dec 2002 01:34:06 +0200 (EET)
Date: Sun, 8 Dec 2002 01:34:07 +0200
Mime-Version: 1.0 (Apple Message framework v548)
Content-Type: text/plain; delsp=yes; charset=US-ASCII; format=flowed
From: Chris Leishman <chris@leishman.org>
To: ds6-devel@deepspace6.net
Content-Transfer-Encoding: 7bit
Message-Id: <611D54FA-0A3C-11D7-BD8D-003065F97418@leishman.org>
X-Mailer: Apple Mail (2.548)
Subject: [ds6-devel] cvs log problems
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Sat, 07 Dec 2002 23:34:07 -0000

Hi,

The cvs log setup has some issues.  Or should I just subscribe  
chris@deepspace6.net and unsubscribe my current address?

Regards,
Chris

Begin forwarded message:

> From: ds6-devel-bounces@deepspace6.net
> Date: Sun Dec 8, 2002  1:13:15 AM Europe/Helsinki
> To: chris@deepspace6.net
> Subject: Your message to ds6-devel awaits moderator approval
>
> Your mail to 'ds6-devel' with the subject
>
>     nc6/src network.c,1.2,1.3
>
> Is being held until the list moderator can review it for approval.
>
> The reason it is being held:
>
>     Post by non-member to a members-only list
>
> Either the message will get posted to the list, or you will receive
> notification of the moderator's decision.  If you would like to cancel
> this posting, please visit the following URL:
>
>      
> http://lists.deepspace6.net/confirm/ds6-devel/ 
> a694c9b0ab66bd9ca591fe025590dabbb0075652
>

From chris@deepspace6.net  Sat Dec  7 01:14:07 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id 86B7F1F7049
	for <ds6-devel@deepspace6.net>; Sat,  7 Dec 2002 01:14:07 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021207001407.86B7F1F7049@liston.ferrara.linux.it>
Date: Sat,  7 Dec 2002 01:14:07 +0100 (CET)
X-Mailman-Approved-At: Sun, 08 Dec 2002 14:03:56 +0100
Subject: [ds6-devel] nc6 configure.in,1.5,1.6
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Sat, 07 Dec 2002 00:14:07 -0000

Update of /cvs/nc6

Modified Files:
	configure.in 
Log Message:
Cleaned up configure.in to correctly define (or not) flags like
HAVE_GETADDRINFO_AI_ADDRCONFIG.

The problem was that AC_DEFINE([blah], 0) will still put a #define into
config.h, albeit with a value of 0, but this will cause #ifdef's to return true
in the code.

Instead, AC_DEFINE should only be used when we actually want to define the
variable.  autoheader will still pick up the define regardless of where it it
in configure.in

Tested: darwin (osx, with ipv6), linux (no ipv6)


Index: configure.in
===================================================================
RCS file: /cvs/nc6/configure.in,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- configure.in	28 Nov 2002 23:13:02 -0000	1.5
+++ configure.in	7 Dec 2002 00:14:05 -0000	1.6
@@ -17,45 +17,28 @@
 # The CFLAGS to always use
 CFLAGS="-pipe -W -Wall -Wpointer-arith -Wstrict-prototypes -Wcast-qual -Wcast-align"
 
-# Check for IPv6 stuff
-AC_ARG_ENABLE(debug,AC_HELP_STRING([--enable-debug],[Enable debugging - useful only for developers]),
-    [case "${enable_debug}" in
-    yes)
-	AC_DEFINE(DEBUG,1)
-	CFLAGS="${CFLAGS} -g -O0"
-	;;
-    no) 
-        AC_DEFINE(NDEBUG,1)
-	CFLAGS="${CFLAGS} -O2 -finline-functions"
-	;;
-    *)	
-        AC_MSG_ERROR(bad value ${enable_debug} for --enable-debug option) 
-	;;
-    esac],
-    AC_DEFINE(NDEBUG,1))
+# Add extra flags if in debug mode
+AC_ARG_ENABLE(debug,
+  AC_HELP_STRING(
+    [--enable-debug],
+    [Enable debugging - useful only for developers]
+  ),
+  [case "${enable_debug}" in
+  yes)
+    AC_DEFINE(DEBUG, 1, [Define if nc6 is to be build with debug information.])
+    CFLAGS="${CFLAGS} -g -O0"
+    ;;
+  no) 
+    AC_DEFINE(NDEBUG, 1, [Define if nc6 is to be build without debug information.])
+    CFLAGS="${CFLAGS} -O2 -finline-functions"
+    ;;
+  *)    
+    AC_MSG_ERROR(bad value ${enable_debug} for --enable-debug option) 
+    ;;
+  esac],
+  AC_DEFINE(NDEBUG,1)
+)
     
-AC_ARG_ENABLE(stack-guess,AC_HELP_STRING([--enable-stack-guess],[Enable guess of IPv6 stack (default)]),
-    [case "${enable_stack_guess}" in
-    yes)	
-        guess=yes
-	;;
-    no) 
-        guess=no
-	;;
-    *)	
-        AC_MSG_ERROR(bad value ${enable_stack_guess} for --enable-stack-guess option) 
-	;;
-    esac],
-    [guess=yes])
-
-IN6_ENABLE_IPV6(AC_DEFINE(INET6,1),[ipv6=no])
-
-if test "X$guess" != "Xno" -a "X$ipv6" != "Xno"; then
-    IN6_GUESS_STACK(ipv6, ipv6libdir, ipv6lib)
-    CFLAGS="$CFLAGS $INET6_CFLAGS"
-    LIBS="$INET6_LIBS $LIBS"
-fi
-
 # Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS([errno.h fcntl.h limits.h netdb.h netinet/in.h signal.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
@@ -64,18 +47,6 @@
 AC_C_CONST
 AC_TYPE_SIZE_T
 
-AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE], 0, [Define if the system supports struct sockaddr_storage.])
-AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY], 0, [Define if struct sockaddr_storage has the ss_family member.])
-AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE__SS_FAMILY], 0, [Define if struct sockaddr_storage has the __ss_family member.])
-AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6], 0, [Define if the system supports struct sockaddr_in6.])
-AC_DEFINE([HAVE_STRUCT_SOCKADDR_SA_LEN], 0, [Define if struct sockaddr has the sa_len member.])
-AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID], 0, [Define if struct sockaddr_in6 has the sin6_scope_id member.])
-AC_DEFINE([HAVE_GETADDRINFO], 0, [Define if the system implements the getaddrinfo function.])
-AC_DEFINE([HAVE_GETADDRINFO_AI_ADDRCONFIG], 0, [Define if getaddrinfo supports AI_ADDRCONFIG flag.])
-AC_DEFINE([INET6], 0, [Define if the system is IPv6-enabled.])
-AC_DEFINE([DEBUG], 0, [Define if nc6 is to be build with debug information.])
-AC_DEFINE([NDEBUG], 0, [Define if nc6 is to be build without debug information.])
- 						
 # From the autoconf 2.13 documentation:
 #
 #  - Macro: AC_HEADER_TIME
@@ -87,7 +58,7 @@
 #      timeval' or `struct timezone' as well as `struct tm'.  It is best
 #      used in conjunction with `HAVE_SYS_TIME_H', which can be checked
 #      for using `AC_CHECK_HEADERS(sys/time.h)'.
-# 					 
+#                                        
 #           #if TIME_WITH_SYS_TIME
 #           # include <sys/time.h>
 #           # include <time.h>
@@ -102,16 +73,77 @@
 AC_HEADER_TIME
 SOCKLEN_T
 
+# Configure IPv6 support
+AC_ARG_ENABLE(stack-guess,
+  AC_HELP_STRING(
+    [--enable-stack-guess],
+    [Enable guess of IPv6 stack (default)]
+  ),
+  [case "${enable_stack_guess}" in
+  yes)  
+    guess=yes
+    ;;
+  no) 
+    guess=no
+    ;;
+  *)    
+    AC_MSG_ERROR(bad value ${enable_stack_guess} for --enable-stack-guess option) 
+    ;;
+  esac],
+  [guess=yes]
+)
+
+IN6_ENABLE_IPV6(
+  AC_DEFINE(INET6, 1, [Define if the system is IPv6-enabled.]),
+  [ipv6=no]
+)
+
+if test "X$guess" != "Xno" -a "X$ipv6" != "Xno"; then
+  IN6_GUESS_STACK(ipv6, ipv6libdir, ipv6lib)
+  CFLAGS="$CFLAGS $INET6_CFLAGS"
+  LIBS="$INET6_LIBS $LIBS"
+fi
+
 # Check for IPv6 structures, only if needed
 if test "X$ipv6" != "Xno"; then
-    IN6_STRUCT_SOCKADDR_STORAGE(AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1),
-      [AC_MSG_ERROR([Your system does not support struct sockaddr_storage, which is needed to compile nc6])])
-    IN6_STRUCT_SOCKADDR_STORAGE_SS_FAMILY(AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY, 1))
-    IN6_STRUCT_SOCKADDR_STORAGE___SS_FAMILY(AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE__SS_FAMILY, 1))
-    IN6_STRUCT_SOCKADDR_IN6(AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1),
-      [AC_MSG_ERROR([Your system does not support struct sockaddr_in6, which is needed to compile nc6])])
-    IN6_STRUCT_SOCKADDR_SA_LEN(AC_DEFINE(HAVE_STRUCT_SOCKADDR_SA_LEN, 1))
-    IN6_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID(AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID, 1))
+  IN6_STRUCT_SOCKADDR_STORAGE(
+    AC_DEFINE(
+      [HAVE_STRUCT_SOCKADDR_STORAGE], 1,
+      [Define if the system supports struct sockaddr_storage.]
+    ),
+    [AC_MSG_ERROR([Your system does not support struct sockaddr_storage, which is needed to compile nc6])]
+  )
+  IN6_STRUCT_SOCKADDR_STORAGE_SS_FAMILY(
+    AC_DEFINE(
+      [HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY], 1,
+      [Define if struct sockaddr_storage has the ss_family member.]
+    )
+  )
+  IN6_STRUCT_SOCKADDR_STORAGE___SS_FAMILY(
+    AC_DEFINE(
+      [HAVE_STRUCT_SOCKADDR_STORAGE__SS_FAMILY], 1,
+      [Define if struct sockaddr_storage has the __ss_family member.]
+    )
+  )
+  IN6_STRUCT_SOCKADDR_IN6(
+    AC_DEFINE(
+      [HAVE_STRUCT_SOCKADDR_IN6], 1,
+      [Define if the system supports struct sockaddr_in6.]
+    ),
+    [AC_MSG_ERROR([Your system does not support struct sockaddr_in6, which is needed to compile nc6])]
+  )
+  IN6_STRUCT_SOCKADDR_SA_LEN(
+    AC_DEFINE(
+      [HAVE_STRUCT_SOCKADDR_SA_LEN], 1,
+      [Define if struct sockaddr has the sa_len member.]
+    )
+  )
+  IN6_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID(
+    AC_DEFINE(
+      [HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID], 1,
+      [Define if struct sockaddr_in6 has the sin6_scope_id member.]
+    )
+  )
 fi
 
 # Checks for library functions.
@@ -121,14 +153,24 @@
 AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([bzero gettimeofday memset select socket strerror strrchr strtol signal fcntl])
-IN6_FUNC_GETADDRINFO(AC_DEFINE(HAVE_GETADDRINFO,1),
-	[AC_MSG_ERROR([Your system does not support getaddrinfo, which is needed to compile nc6])])
-IN6_FUNC_GETADDRINFO_AI_ADDRCONFIG(AC_DEFINE(HAVE_GETADDRINFO_AI_ADDRCONFIG,1))
+
+IN6_FUNC_GETADDRINFO(
+    AC_DEFINE(
+      [HAVE_GETADDRINFO], 1,
+      [Define if the system implements the getaddrinfo function.]
+    ),
+    [AC_MSG_ERROR([Your system does not support getaddrinfo, which is needed to compile nc6])]
+)
+
+IN6_FUNC_GETADDRINFO_AI_ADDRCONFIG(
+    AC_DEFINE(
+      [HAVE_GETADDRINFO_AI_ADDRCONFIG], 1, 
+      [Define if getaddrinfo supports AI_ADDRCONFIG flag.]
+    )
+)
+
 AC_CHECK_FUNCS([freeaddrinfo gai_strerror getnameinfo getipnodebyname getipnodebyaddr freehostent])
 
-# These tests are not needed
-# IN6_FUNC_SA_LEN
-# IN6X_FUNC_GETIFADDRS(AC_DEFINE(HAVE_GETIFADDRS))
 
 AC_SUBST(ac_aux_dir)
 

From chris@deepspace6.net  Sat Dec  7 01:15:20 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id D63141F7049
	for <ds6-devel@deepspace6.net>; Sat,  7 Dec 2002 01:15:20 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021207001520.D63141F7049@liston.ferrara.linux.it>
Date: Sat,  7 Dec 2002 01:15:20 +0100 (CET)
X-Mailman-Approved-At: Sun, 08 Dec 2002 14:03:56 +0100
Subject: [ds6-devel] nc6/docs nc6.1,1.2,1.3
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Sat, 07 Dec 2002 00:15:21 -0000

Update of /cvs/nc6/docs

Modified Files:
	nc6.1 
Log Message:
Removed outdated section on tcp/udp separation.


Index: nc6.1
===================================================================
RCS file: /cvs/nc6/docs/nc6.1,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- nc6.1	14 Jun 2002 10:16:01 -0000	1.2
+++ nc6.1	7 Dec 2002 00:15:18 -0000	1.3
@@ -75,21 +75,6 @@
 UDP support in 
 .B netcat6
 is really advanced and works very well in both connect and in listen mode.
-.P 
-Netcat used to have a very bad UDP support, as its code was written upon
-the illogic assumption that some system calls which were designed to work 
-for stream sockets (like read and write) would have worked with datagram 
-sockets too. So, the same code was used for both datagram and stream sockets.
-This certainly works in Linux and in BSD systems, as the kernel translates 
-the calls to write and read upon a datagram socket into calls to sendmsg 
-and recvmsg. Unfortunately, this does work only in a few UNIX systems. 
-Even worse, this approach does not work with UDP server sockets.
-.P 
-Instead, from the 0.2pre2 release,
-.B netcat6
-features a working UDP support, with code for stream sockets and datagram 
-sockets being completely separated one from the other, in order to achieve 
-the best UDP support, even in listen mode!
 .SH COPYRIGHT
 GPL. 
 .SH AUTHOR

From chris@deepspace6.net  Sun Dec  8 00:13:15 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id 2D2D81F7049
	for <ds6-devel@deepspace6.net>; Sun,  8 Dec 2002 00:13:15 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021207231315.2D2D81F7049@liston.ferrara.linux.it>
Date: Sun,  8 Dec 2002 00:13:15 +0100 (CET)
X-Mailman-Approved-At: Sun, 08 Dec 2002 14:03:56 +0100
Subject: [ds6-devel] nc6/src network.c,1.2,1.3
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Sat, 07 Dec 2002 23:13:15 -0000

Update of /cvs/nc6/src

Modified Files:
	network.c 
Log Message:
Various fixes:

- Fixed some show-stoppers (like calling fatal for the "connected" message ;) )
- Changed verbose messages to be more netcat like
- Cleaned up reverse DNS code, while still ensuring errors in inverse lookup
  is non-fatal.
- Reworked the "double bind" issue:

On systems that do "double binding" for ipv6 listening sockets, binding to an
ipv4 address will fail if the ipv6 address is already bound (and vice versa).
However, ipv6 sockets will still accept connections targeted for the ipv4
equivalent address - but not the other way around.

So, to ensure portability (at least in function), care is taken to always bind
to ipv6 sockets first - that way all connections will still work.  The only 
limitation to this approach is that the second bind will be reported as a
failure in verbose mode.  At some point a autoconf test should be written for
this and platforms that do double binding should suppress the error message.


Index: network.c
===================================================================
RCS file: /cvs/nc6/src/network.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- network.c	28 Nov 2002 20:24:48 -0000	1.2
+++ network.c	7 Dec 2002 23:13:13 -0000	1.3
@@ -38,66 +38,52 @@
 
 
 
-static bool have_both_ipv4_and_ipv6_addresses(const struct addrinfo *ai)
+static struct addrinfo* order_ipv6_first(struct addrinfo *ai)
 {
-	bool have_ipv4_addresses = FALSE;
-	bool have_ipv6_addresses = FALSE;
-	const struct addrinfo *ptr;
-	
-	for (ptr = ai; ptr != NULL; ptr = ptr->ai_next) {
-		switch (ptr->ai_family) {
-			case AF_INET:
-				if (have_ipv6_addresses == TRUE) return TRUE;
-				have_ipv4_addresses = TRUE;
-				break;
-			case AF_INET6:
-				if (have_ipv4_addresses == TRUE) return TRUE;
-				have_ipv6_addresses = TRUE;
-				break;
-			default:
-				/* should this be a fatal error? i don't think so */
-				warn("unknown address family");
+	struct addrinfo* ptr;
+	struct addrinfo* lastv6 = NULL;
+	struct addrinfo* tmp;
+
+	assert(ai != NULL);
+
+	/* Move all ipv6 addresses to the start of the list - keeping
+	 * them in original order */
+
+	if (ai->ai_family == AF_INET6)
+		lastv6 = ai;
+
+	for (ptr = ai; ptr && ptr->ai_next; ptr = ptr->ai_next) {
+		if (ptr->ai_next->ai_family == AF_INET6) {
+			tmp = ptr->ai_next;
+			ptr->ai_next = tmp->ai_next;
+			if (lastv6) {
+				tmp->ai_next = lastv6->ai_next;
+				lastv6->ai_next = tmp;
+			} else {
+				tmp->ai_next = ai;
+				ai = tmp;
+			}
+			lastv6 = tmp;
 		}
 	}
 
-	return FALSE;
+	return ai;
 }
 
 
 
-void do_connect(const address *remote, const address *local,
+void connection_attributes_to_addrinfo(struct addrinfo *ainfo,
 		const connection_attributes *attrs)
 {
-	io_stream remote_stream, local_stream;
-	int err, fd = -1;
-	struct addrinfo hints, *res = NULL, *ptr;
-	bool have_rev = FALSE;
-	bool connect_attempted = FALSE;
-	char hbuf_rev[NI_MAXHOST + 1]; /* MAX_IP_ADDRLEN + 1 should be enough */
-	char hbuf_num[NI_MAXHOST + 1];
-	char sbuf_rev[NI_MAXSERV + 1]; /* MAX_PORTLEN + 1 should be enough */
-	char sbuf_num[NI_MAXSERV + 1];
-
-	/* make sure that all the preconditions are respected */
-	assert(remote != NULL);
-	assert(remote->address != NULL);
-	assert(remote->port != NULL);
-	assert(local == NULL || ((local->address == NULL || strlen(local->address) > 0) &&
-	                         (local->port    == NULL || strlen(local->port)    > 0)));
-	assert(attrs != NULL);
-	
-	/* setup hints structure to be passed to getaddrinfo */
-	memset(&hints, 0, sizeof(hints));
-
 	switch (attrs->proto) {
 		case PROTO_IPv6:
-			hints.ai_family = AF_INET6;
+			ainfo->ai_family = AF_INET6;
 			break;
 		case PROTO_IPv4:
-			hints.ai_family = AF_INET;
+			ainfo->ai_family = AF_INET;
 			break;
 		case PROTO_UNSPECIFIED:
-			hints.ai_family = AF_UNSPEC;
+			ainfo->ai_family = AF_UNSPEC;
 			break;
 		default:
 			fatal("internal error: unknown socket domain");
@@ -105,14 +91,42 @@
 	
 	switch (attrs->type) {
 		case UDP_SOCKET:
-			hints.ai_socktype = SOCK_DGRAM;
+			ainfo->ai_socktype = SOCK_DGRAM;
 			break;
 		case TCP_SOCKET:
-			hints.ai_socktype = SOCK_STREAM;
+			ainfo->ai_socktype = SOCK_STREAM;
 			break;
 		default:
 			fatal("internal error: unknown socket type");
 	}
+}
+
+
+
+void do_connect(const address *remote, const address *local,
+		const connection_attributes *attrs)
+{
+	io_stream remote_stream, local_stream;
+	int err, fd = -1;
+	struct addrinfo hints, *res = NULL, *ptr;
+	bool connect_attempted = FALSE;
+	char hbuf_rev[NI_MAXHOST + 1];
+	char hbuf_num[NI_MAXHOST + 1];
+	char sbuf_rev[NI_MAXSERV + 1];
+	char sbuf_num[NI_MAXSERV + 1];
+
+	/* make sure that all the preconditions are respected */
+	assert(remote != NULL);
+	assert(remote->address != NULL);
+	assert(remote->port != NULL);
+	assert(local == NULL ||
+	    ((local->address == NULL || strlen(local->address) > 0) &&
+	     (local->port    == NULL || strlen(local->port)    > 0)));
+	assert(attrs != NULL);
+	
+	/* setup hints structure to be passed to getaddrinfo */
+	memset(&hints, 0, sizeof(hints));
+	connection_attributes_to_addrinfo(&hints, attrs);
 
 #ifdef HAVE_GETADDRINFO_AI_ADDRCONFIG
 	hints.ai_flags |= AI_ADDRCONFIG;
@@ -133,9 +147,6 @@
 	/* try connecting to any of the addresses returned by getaddrinfo */
 	for (ptr = res; ptr != NULL; ptr = ptr->ai_next) {
 
-		/* reset have_rev */
-		have_rev = FALSE;
-		
 		/* only accept socktypes we can handle */
 		if (ptr->ai_socktype != SOCK_STREAM && ptr->ai_socktype != SOCK_DGRAM)
 			continue;
@@ -145,29 +156,33 @@
 
 		/* get the numeric name for this destination as a string */
 		err = getnameinfo(ptr->ai_addr, ptr->ai_addrlen,
-		                  hbuf_num, sizeof(hbuf_num), sbuf_num, 
-				  sizeof(sbuf_num), NI_NUMERICHOST | NI_NUMERICSERV);
+		        hbuf_num, sizeof(hbuf_num), sbuf_num, 
+		        sizeof(sbuf_num), NI_NUMERICHOST | NI_NUMERICSERV);
 
 		/* this should never happen */
-		if(err != 0)
+		if (err != 0)
 			fatal("getnameinfo failed: %s", gai_strerror(err));
 
 		/* get the real name for this destination as a string */
-		if ((is_flag_set(NUMERIC_MODE) == FALSE) && 
-		    (is_flag_set(VERY_VERBOSE_MODE) == TRUE)) { /* should this be VERBOSE_MODE? */
-			
-			/* try reverse dns lookup */
+		if ((is_flag_set(VERBOSE_MODE) == TRUE) &&
+		    (is_flag_set(NUMERIC_MODE) == FALSE)) 
+		{
+			/* get the real name for this destination as a string */
 			err = getnameinfo(ptr->ai_addr, ptr->ai_addrlen,
-				          hbuf_rev, sizeof(hbuf_rev), sbuf_rev, 
-				          sizeof(sbuf_rev), 0);
-			if(err != 0) {
-				/* this is not a fatal error */
+					hbuf_rev, sizeof(hbuf_rev), sbuf_rev, 
+					sizeof(sbuf_rev), 0);
+
+			if(err != 0)
 				warn("inverse lookup failed for %s: %s",
-				     hbuf_num, gai_strerror(err));
-			} else {
-				/* we have reverse dns information */
-				have_rev = TRUE; 
-			}
+					 hbuf_num, gai_strerror(err));
+		} else {
+			err = 1;
+		}
+
+		if (err != 0) {
+			/* just make the real name the numeric string */
+			strcpy(hbuf_rev, hbuf_num);
+			strcpy(sbuf_rev, sbuf_num);
 		}
 
 		/* create the socket */
@@ -201,7 +216,7 @@
 			/* get the IP address of the local end of the connection */
 			err = getaddrinfo(local->address, local->port, &hints, &src_res);
 			if(err != 0) {
-				warn("forward host lookup failed for local endpoint %s: %s",
+				warn("forward host lookup failed for source address %s: %s",
 				     local->address, gai_strerror(err));
 				close(fd);
 				fd = -1;
@@ -212,7 +227,7 @@
 			assert(src_res != NULL);
 
 			/* try binding to any of the addresses returned by getaddrinfo */
-			for (src_ptr = src_res; src_ptr != NULL; src_ptr = src_ptr->ai_next) {
+			for (src_ptr = src_res; src_ptr; src_ptr = src_ptr->ai_next) {
 				err = bind(fd, src_ptr->ai_addr, src_ptr->ai_addrlen);
 				if (err == 0)
 					break;
@@ -223,21 +238,12 @@
 				 * getaddrinfo */
 				assert(src_ptr->ai_next == NULL);
 				
-				/* print error message */
-				if (have_rev == TRUE) {
-					warn("bind to source addr/port failed when "
-					     "connecting to %s (addr. %s, rev. name %s) "
-					     "port %s (number %s, name %s): %s",
-					     remote->address, hbuf_num, hbuf_rev, 
-					     remote->port, sbuf_num, sbuf_rev, strerror(errno));
-				} else {
-					warn("bind to source addr/port failed when "
-					     "connecting to %s (addr. %s) "
-					     "port %s (number %s): %s",
-					     remote->address, hbuf_num,  
-					     remote->port, sbuf_num, strerror(errno));
+				if (is_flag_set(VERBOSE_MODE) == TRUE) {
+					warn("bind to source addr/port failed "
+						 "when connecting %s [%s] %s (%s): %s",
+						 hbuf_rev, hbuf_num, sbuf_num, sbuf_rev,
+						 strerror(errno));
 				}
-				
 				freeaddrinfo(src_res);
 				close(fd);
 				fd = -1;
@@ -251,17 +257,8 @@
 		err = connect(fd, ptr->ai_addr, ptr->ai_addrlen);
 		if (err != 0) {
 			if (is_flag_set(VERBOSE_MODE) == TRUE) {
-				if (have_rev == TRUE) {
-					warn("connection to %s (addr. %s, rev. name %s) "
-					     "port %s (number %s, name %s) failed: %s",
-					     remote->address, hbuf_num, hbuf_rev, 
-					     remote->port, sbuf_num, sbuf_rev, strerror(errno));
-				} else {
-					warn("connection to %s (addr. %s) "
-					     "port %s (number %s) failed: %s",
-					     remote->address, hbuf_num,  
-					     remote->port, sbuf_num, strerror(errno));
-				}
+				warn("%s [%s] %s (%s): %s",
+				    hbuf_rev, hbuf_num, sbuf_num, sbuf_rev, strerror(errno));
 			}
 			close(fd);
 			fd = -1;
@@ -276,12 +273,9 @@
 	
 	/* if the connection failed, output an error message */
 	if (ptr == NULL) {
-		if (connect_attempted == FALSE) {
+		if (connect_attempted == FALSE)
 			fatal("forward lookup returned no usable socket types");
-		} else {
-			fatal("cannot connect to %s port %s", 
-			      remote->address, remote->port);
-		}
+		exit(EXIT_FAILURE);
 	}
 
 	/* cleanup addrinfo structure */
@@ -289,17 +283,7 @@
 
 	/* let the user know the connection has been established */
 	if (is_flag_set(VERBOSE_MODE)) {
-		if (have_rev == TRUE) {
-			warn("connection to %s (addr. %s, rev. name %s) "
-			     "port %s (number %s, name %s) opened",
-			     remote->address, hbuf_num, hbuf_rev, 
-			     remote->port, sbuf_num, sbuf_rev);
-		} else {
-			warn("connection to %s (addr. %s) "
-			     "port %s (number %s) opened",
-			     remote->address, hbuf_num,  
-			     remote->port, sbuf_num);
-		}
+		warn("%s [%s] %s (%s) open", hbuf_rev, hbuf_num, sbuf_num, sbuf_rev);
 	}
 
 	/* create io_streams for the local and remote streams */
@@ -318,85 +302,58 @@
 	io_stream remote_stream, local_stream;
 	int nfd, i, fd, err, ns = -1, maxfd = -1;
 	struct addrinfo hints, *res = NULL, *ptr;
-	char hbuf_num[NI_MAXHOST + 1], sbuf_num[NI_MAXSERV + 1];
-#if 0 /* REVERSE_DNS */
-	cher hbuf_rev[NI_MAXHOST + 1], sbuf_rev[NI_MAXSERV + 1];
-#endif
+	char hbuf_rev[NI_MAXHOST + 1];
+	char hbuf_num[NI_MAXHOST + 1];
+	char sbuf_rev[NI_MAXSERV + 1];
+	char sbuf_num[NI_MAXSERV + 1];
 	fd_set accept_fdset;
-	char *address;
 
 	/* make sure all the preconditions are respected */
 	assert(attrs != NULL);
 	assert(local != NULL);
 	assert(local->address == NULL || strlen(local->address) > 0);
 	assert(local->port != NULL && strlen(local->port) > 0);
-	assert(remote == NULL || ((remote->address == NULL || strlen(remote->address) > 0) &&
-	                          (remote->port    == NULL || strlen(remote->port)    > 0)));
-	
-	/* setup this once for all */
-	address = (local->address != NULL ? local->address : "UNSPECIFIED ADDRESS");
+	assert(remote == NULL ||
+	    ((remote->address == NULL || strlen(remote->address) > 0) &&
+	     (remote->port    == NULL || strlen(remote->port)    > 0)));
 	
 	/* initialize accept_fdset */
 	FD_ZERO(&accept_fdset);
 	
 	/* setup hints structure to be passed to getaddrinfo */
 	memset(&hints, 0, sizeof(hints));
-
-	switch (attrs->proto) {
-		case PROTO_IPv6:
-			hints.ai_family = AF_INET6;
-			break;
-		case PROTO_IPv4:
-			hints.ai_family = AF_INET;
-			break;
-		case PROTO_UNSPECIFIED:
-			hints.ai_family = AF_UNSPEC;
-			break;
-		default:
-			fatal("internal error: unknown socket domain");
-	}
-	
-	switch (attrs->type) {
-		case UDP_SOCKET:
-			hints.ai_socktype = SOCK_DGRAM;
-			break;
-		case TCP_SOCKET:
-			hints.ai_socktype = SOCK_STREAM;
-			break;
-		default:
-			fatal("internal error: unknown socket type");
-	}
+	connection_attributes_to_addrinfo(&hints, attrs);
 
 	hints.ai_flags = AI_PASSIVE;
-
 	if (is_flag_set(NUMERIC_MODE) == TRUE)
 		hints.ai_flags |= AI_NUMERICHOST;
 
 	/* get the IP address of the local end of the connection */
 	err = getaddrinfo(local->address, local->port, &hints, &res);
 	if (err != 0) 
-		fatal("forward host lookup failed for local endpoint %s port %s: %s",
-		      address, local->port, gai_strerror(err));
+		fatal("forward host lookup failed for local endpoint %s (%s): %s",
+		      local->address? local->address : "[unspecified]",
+			  local->port, gai_strerror(err));
 		
 	/* check the results of getaddrinfo */
 	assert(res != NULL);
 
-#ifndef CAN_DOUBLE_BIND
-	/* workaround for those systems that don't allow double binding */
-	if (local->address == NULL && have_both_ipv4_and_ipv6_addresses(res) == TRUE)
-		fatal("your host does not support indipendent double binding."
-		      "Please specify the IP protocol version to use with -4 or -6.");
-#endif
-	
-	nfd = 0;	
-	
+	/* Some systems (eg. linux) will bind to both ipv6 AND ipv4 when
+	 * listening.  Connections will still be accepted from either ipv6 or
+	 * ipv4 clients (ipv4 will be mapped into ipv6).  However, this means
+	 * that we MUST bind the ipv6 address ONLY for these hosts.
+	 *
+	 * TODO: until we add a configure check to determine if the current
+	 * host does this double binding, we will just ensure that ipv6
+	 * sockets are bound first and then attempt to bind the ipv4 ones.  On
+	 * systems that double bind ipv6/ipv4 the ipv4 bind will simply fail.
+	 */
+	res = order_ipv6_first(res);
+
 	/* try binding to all of the addresses returned by getaddrinfo */
+	nfd = 0;	
 	for (ptr = res; ptr != NULL; ptr = ptr->ai_next) {
 
-#if 0 /* REVERSE_DNS */
-		have_rev = FALSE;
-#endif
-		
 		/* only accept socktypes we can handle */
 		if (ptr->ai_socktype != SOCK_STREAM && ptr->ai_socktype != SOCK_DGRAM)
 			continue;
@@ -407,32 +364,33 @@
 
 		/* get the numeric name for this source as a string */
 		err = getnameinfo(ptr->ai_addr, ptr->ai_addrlen,
-				  hbuf_num, sizeof(hbuf_num), sbuf_num, 
-				  sizeof(sbuf_num), NI_NUMERICHOST | NI_NUMERICSERV);
+		        hbuf_num, sizeof(hbuf_num), sbuf_num, 
+		        sizeof(sbuf_num), NI_NUMERICHOST | NI_NUMERICSERV);
 
 		/* this should never happen */
-		if(err != 0)
+		if (err != 0)
 			fatal("getnameinfo failed: %s", gai_strerror(err));
 
-#if 0 /* REVERSE_DNS */
 		/* get the real name for this destination as a string */
 		if ((is_flag_set(NUMERIC_MODE) == FALSE) && 
-		    (is_flag_set(VERY_VERBOSE_MODE) == TRUE)) { /* should this be VERBOSE_MODE? */
-			
+		    (is_flag_set(VERY_VERBOSE_MODE) == TRUE))
+		{
 			/* try reverse dns lookup */
 			err = getnameinfo(ptr->ai_addr, ptr->ai_addrlen,
 				          hbuf_rev, sizeof(hbuf_rev), sbuf_rev, 
 				          sizeof(sbuf_rev), 0);
-			if(err != 0) {
-				/* this is not a fatal error */
+			if(err != 0)
 				warn("inverse lookup failed for %s: %s",
 				     hbuf_num, gai_strerror(err));
-			} else {
-				/* we have reverse dns information */
-				have_rev = TRUE; 
-			}
+		} else {
+			err = 1;
+		}
+
+		if (err != 0) {
+			/* just make the real name the numeric string */
+			strcpy(hbuf_rev, hbuf_num);
+			strcpy(sbuf_rev, sbuf_num);
 		}
-#endif 
 
 		/* create the socket */
 		fd = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
@@ -448,7 +406,7 @@
 #endif 
 	
 		/* set the reuse address socket option */
-		if (is_flag_set(DONT_REUSE_ADDR) == FALSE) {
+		if (!(is_flag_set(DONT_REUSE_ADDR) == TRUE)) {
 			int on = 1;
 			/* in case of error, we will go on anyway... */
 			err = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
@@ -458,25 +416,8 @@
 		/* bind to the local address */
 		err = bind(fd, ptr->ai_addr, ptr->ai_addrlen);
 		if (err != 0) {
-			/* print error message */
-#if 0 /* REVERSE_DNS */
-			if (have_rev == TRUE) {
-				warn("bind to source addr/port failed when "
-				     "connecting to %s (addr. %s, rev. name %s) "
-				     "port %s (number %s, name %s): %s",
-				     remote->address, hbuf_num, hbuf_rev, 
-				     remote->port, sbuf_num, sbuf_rev, strerror(errno));
-			} else {
-				warn("bind to source addr/port failed when "
-				     "connecting to %s (addr. %s) "
-				     "port %s (number %s): %s",
-				     remote->address, hbuf_num,  
-				     remote->port, sbuf_num, strerror(errno));
-			}
-#else
-			warn("bind to source address %s (%s) port %s (%s) failed: %s",
-			     address, hbuf_num, remote->port, sbuf_num, strerror(errno));
-#endif
+			warn("bind to source %s [%s] %s (%s) failed: %s",
+			     hbuf_rev, hbuf_num, sbuf_num, sbuf_rev, strerror(errno));
 			close(fd);
 			continue;
 		}
@@ -488,13 +429,13 @@
 		if (ptr->ai_socktype == SOCK_STREAM) {
 			err = listen(fd, 5);
 			if (err != 0)
-				fatal("cannot listen on source address %s (%s) port %s (%s): %s",
-				      address, hbuf_num, remote->port, sbuf_num, strerror(errno));
+				fatal("cannot listen on %s [%s] %s (%s): %s",
+				      hbuf_rev, hbuf_num, sbuf_num, sbuf_rev, strerror(errno));
 		}
 
 		if (is_flag_set(VERBOSE_MODE) == TRUE)
-			fatal("listening on source address %s (%s) port %s (%s)",
-			      address, hbuf_num, remote->port, sbuf_num, strerror(errno));
+			warn("listening on %s [%s] %s (%s) ...",
+			      hbuf_rev, hbuf_num, sbuf_num, sbuf_rev, strerror(errno));
 
 		/* add fd to accept_fdset */
 		FD_SET(fd, &accept_fdset);
@@ -512,6 +453,9 @@
 		fd_set tmp_ap_fdset;
 		struct sockaddr_storage dest;
 		socklen_t destlen;
+		char c_hbuf_rev[NI_MAXHOST + 1];
+		char c_hbuf_num[NI_MAXHOST + 1];
+		char c_sbuf_num[NI_MAXSERV + 1];
 
 		/* make a copy of accept_fdset before passing to select */
 		memcpy(&tmp_ap_fdset, &accept_fdset, sizeof(fd_set));
@@ -525,11 +469,11 @@
 		}
 
 		/* find the ready filedescriptor */
-		for (i = 0; i < maxfd && !FD_ISSET(i, &tmp_ap_fdset); ++i)
+		for (i = 0; i <= maxfd && !FD_ISSET(i, &tmp_ap_fdset); ++i)
 			;
 
 		/* if none were ready, loop to select again */
-		if (i == maxfd)
+		if (i > maxfd)
 			continue;
 
 		destlen = sizeof(dest);	
@@ -541,20 +485,19 @@
 			if (ns < 0)
 				fatal("cannot accept connection: %s", strerror(errno));
 		} else {
-			err = recvfrom(i, NULL, 0, MSG_PEEK, (struct sockaddr*)&dest, &destlen);
+			err = recvfrom(i, NULL, 0, MSG_PEEK,
+			        (struct sockaddr*)&dest, &destlen);
 			if (err < 0)
 				fatal("cannot recv from socket: %s", strerror(errno));
 
 			ns = dup(i);
 			if (ns < 0)
-				fatal("cannot duplicate file descriptor %d: %s", i, strerror(errno));
+				fatal("cannot duplicate file descriptor %d: %s",
+				      i, strerror(errno));
 		}
 
-#if 0 /* REVERSE_DNS */
 		/* get names for each end of the connection */
 		if (is_flag_set(VERBOSE_MODE) == TRUE) {
-			char c_hbuf[NI_MAXHOST + 1], c_hbuf_n[NI_MAXHOST + 1];
-			char c_sbuf_n[NI_MAXSERV + 1];
 			struct sockaddr_storage src;
 			socklen_t srclen = sizeof(src);
 
@@ -565,8 +508,8 @@
 
 			/* get the numeric name for this source as a string */
 			err = getnameinfo((struct sockaddr *)&src, srclen,
-				          hbuf_num, sizeof(hbuf_num), NULL, 0,
-				          NI_NUMERICHOST | NI_NUMERICSERV);
+			        hbuf_num, sizeof(hbuf_num), NULL, 0,
+			        NI_NUMERICHOST | NI_NUMERICSERV);
 
 			/* this should never happen */
 			if(err != 0)
@@ -574,58 +517,58 @@
 
 			/* get the numeric name for this client as a string */
 			err = getnameinfo((struct sockaddr *)&dest, destlen,
-				          c_hbuf_n, sizeof(c_hbuf_n), c_sbuf_n, 
-					  sizeof(c_sbuf_n), NI_NUMERICHOST | NI_NUMERICSERV);
+			        c_hbuf_num, sizeof(c_hbuf_num), c_sbuf_num, 
+					  sizeof(c_sbuf_num), NI_NUMERICHOST | NI_NUMERICSERV);
 			if(err != 0)
 				fatal("getnameinfo failed: %s", gai_strerror(err));
 
 			/* get the real name for this client as a string */
 			if (is_flag_set(NUMERIC_MODE) == FALSE) {
 				err = getnameinfo((struct sockaddr *)&dest, destlen,
-					c_hbuf, sizeof(c_hbuf), NULL, 0, 0);
+					c_hbuf_rev, sizeof(c_hbuf_rev), NULL, 0, 0);
 				if(err != 0)
-					fatal("inverse lookup failed for %s: %s",
-					c_hbuf_n, gai_strerror(err));
+					warn("inverse lookup failed for %s: %s",
+					      c_hbuf_num, gai_strerror(err));
 			} else {
-				strcpy(c_hbuf, c_hbuf_n);
+				err = 1;
+			}
+
+			if (err != 0) {
+				strcpy(c_hbuf_rev, c_hbuf_num);
 			}
 		}
-#endif
 
 		/* check if connections from this client are allowed */
 		if ((remote == NULL) ||
 		    (remote->address == NULL && remote->port == NULL) ||
 		    (is_allowed((struct sockaddr*)&dest, remote, attrs) == TRUE)) {
 
-			if (ptr->ai_socktype == SOCK_DGRAM) {
+			if (attrs->type == SOCK_DGRAM) {
 				/* connect the socket to ensure we only talk with this client */
 				err = connect(ns, (struct sockaddr*)&dest, destlen);
 				if (err != 0)
-					fatal("cannot connect datagram socket: %s", strerror(errno));
+					fatal("cannot connect datagram socket: %s",
+					      strerror(errno));
 			}
 
-#if 0 /* REVERSE_DNS */
 			if (is_flag_set(VERBOSE_MODE) == TRUE) {
-				warn("connect to [%s] from %s [%s] %s",
-				hbuf_n, c_hbuf, c_hbuf_n, c_sbuf_n);
+				warn("connect to %s (%s) from %s [%s] %s",
+				      hbuf_num, sbuf_num, c_hbuf_rev, c_hbuf_num, c_sbuf_num);
 			}
-#endif
 
 			break;
 		} else {
-			if (ptr->ai_socktype == SOCK_DGRAM) {
+			if (attrs->type == SOCK_DGRAM) {
 				/* the connection wasn't accepted - remove the queued packet */
 				recvfrom(ns, NULL, 0, 0, NULL, 0);
 			}
 			close(ns);
 			ns = -1;
 
-#if 0 /* REVERSE_DNS */
 			if (is_flag_set(VERBOSE_MODE) == TRUE) {
-				warn("refused connect to [%s] from %s [%s] %s",
-					hbuf, c_hbuf, c_hbuf_n, c_sbuf_n);
+				warn("refused connect to %s (%s) from %s [%s] %s",
+					hbuf_num, sbuf_num, c_hbuf_rev, c_hbuf_num, c_sbuf_num);
 			}
-#endif
 		}
 	}
 
@@ -636,7 +579,7 @@
 
 	/* create io_streams for the local and remote streams */
 	stdio_to_io_stream(&local_stream);
-	socket_to_io_stream(&remote_stream, ns, ptr->ai_socktype);
+	socket_to_io_stream(&remote_stream, ns, attrs->type);
 
 	/* read and write from the streams until they are closed */
 	readwrite(&remote_stream, &local_stream);

From chris@deepspace6.net  Sun Dec  8 00:31:21 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id 0E6D21F7049
	for <ds6-devel@deepspace6.net>; Sun,  8 Dec 2002 00:31:21 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021207233121.0E6D21F7049@liston.ferrara.linux.it>
Date: Sun,  8 Dec 2002 00:31:21 +0100 (CET)
X-Mailman-Approved-At: Sun, 08 Dec 2002 14:03:56 +0100
Subject: [ds6-devel] nc6/src network.c,1.3,1.4
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Sat, 07 Dec 2002 23:31:21 -0000

Update of /cvs/nc6/src

Modified Files:
	network.c 
Log Message:
Changed fail of source address lookup from warn to fatal.


Index: network.c
===================================================================
RCS file: /cvs/nc6/src/network.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- network.c	7 Dec 2002 23:13:13 -0000	1.3
+++ network.c	7 Dec 2002 23:31:19 -0000	1.4
@@ -215,13 +215,9 @@
 		
 			/* get the IP address of the local end of the connection */
 			err = getaddrinfo(local->address, local->port, &hints, &src_res);
-			if(err != 0) {
-				warn("forward host lookup failed for source address %s: %s",
+			if (err != 0)
+				fatal("forward host lookup failed for source address %s: %s",
 				     local->address, gai_strerror(err));
-				close(fd);
-				fd = -1;
-				continue;
-			}
 
 			/* check the results of getaddrinfo */
 			assert(src_res != NULL);

From chris@deepspace6.net  Sun Dec  8 00:35:22 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id 7225F1F7049
	for <ds6-devel@deepspace6.net>; Sun,  8 Dec 2002 00:35:22 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021207233522.7225F1F7049@liston.ferrara.linux.it>
Date: Sun,  8 Dec 2002 00:35:22 +0100 (CET)
X-Mailman-Approved-At: Sun, 08 Dec 2002 14:03:56 +0100
Subject: [ds6-devel] nc6/src readwrite.c,1.7,1.8 readwrite.h,1.4,1.5
	tcp.h,1.2,NONE udp.h,1.3,NONE
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Sat, 07 Dec 2002 23:35:22 -0000

Update of /cvs/nc6/src

Modified Files:
	readwrite.c readwrite.h 
Removed Files:
	tcp.h udp.h 
Log Message:
Removed deprecated tcp.h & udp.h


Index: readwrite.c
===================================================================
RCS file: /cvs/nc6/src/readwrite.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- readwrite.c	28 Nov 2002 20:24:48 -0000	1.7
+++ readwrite.c	7 Dec 2002 23:35:20 -0000	1.8
@@ -36,7 +36,6 @@
 #include "parser.h"
 #include "readwrite.h"
 #include "timeout.h"
-#include "udp.h"
 
 /* buffer size is 8kb */
 static const size_t BUFFER_SIZE = 8192;
@@ -53,9 +52,7 @@
 static int local_sent, net_sent; 
 
 static void shutdown_io_stream(io_stream *ios, int how);
-#if 0
 static void nonblock(int fd);
-#endif
 
 
 
@@ -429,7 +426,7 @@
 
 void socket_to_io_stream(io_stream *ios, int fd, int socktype)
 {
-	/* nonblock(fd); */
+	nonblock(fd);
 	ios->fd_in  = fd;
 	ios->fd_out = fd;
 	ios->socktype = socktype;
@@ -447,8 +444,8 @@
 		fatal("error in duplicating stdout file descriptor: %s", 
 		      strerror(errno));
 
-	/* nonblock(ios->fd_in); */
-	/* nonblock(ios->fd_out); */
+	nonblock(ios->fd_in);
+	nonblock(ios->fd_out);
 
 	ios->socktype = SOCK_STREAM;   /* pretend stdio is a stream socket */
 }
@@ -491,7 +488,6 @@
 
 
 
-#if 0
 static void nonblock(int fd)
 {
 	int arg;
@@ -504,4 +500,3 @@
 		fatal("error setting flag O_NONBLOCK on file descriptor",
 			strerror(errno));
 }
-#endif
Index: readwrite.h
===================================================================
RCS file: /cvs/nc6/src/readwrite.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- readwrite.h	28 Nov 2002 20:24:48 -0000	1.4
+++ readwrite.h	7 Dec 2002 23:35:20 -0000	1.5
@@ -23,7 +23,6 @@
 #define READWRITE_H
 
 #include "misc.h"
-#include "udp.h"
 
 typedef struct io_stream_t
 {
--- tcp.h DELETED ---
--- udp.h DELETED ---

From chris@deepspace6.net  Sun Dec  8 00:38:28 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id 3387B1F7049
	for <ds6-devel@deepspace6.net>; Sun,  8 Dec 2002 00:38:28 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021207233828.3387B1F7049@liston.ferrara.linux.it>
Date: Sun,  8 Dec 2002 00:38:28 +0100 (CET)
X-Mailman-Approved-At: Sun, 08 Dec 2002 14:03:56 +0100
Subject: [ds6-devel] nc6/src readwrite.c,1.7,1.8
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Sat, 07 Dec 2002 23:38:28 -0000

Update of /cvs/nc6/src

Modified Files:
	readwrite.c 
Log Message:
Removed deprecated tcp.h & udp.h


Index: readwrite.c
===================================================================
RCS file: /cvs/nc6/src/readwrite.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- readwrite.c	28 Nov 2002 20:24:48 -0000	1.7
+++ readwrite.c	7 Dec 2002 23:38:26 -0000	1.8
@@ -36,7 +36,6 @@
 #include "parser.h"
 #include "readwrite.h"
 #include "timeout.h"
-#include "udp.h"
 
 /* buffer size is 8kb */
 static const size_t BUFFER_SIZE = 8192;

From pioppo@ferrara.linux.it  Sun Dec  8 14:05:21 2002
Return-Path: <pioppo@ferrara.linux.it>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from flug.ferrara.linux.it (flug.4net.it [194.243.234.21])
	by liston.ferrara.linux.it (Postfix) with ESMTP id 2BDE71F7049
	for <ds6-devel@deepspace6.net>; Sun,  8 Dec 2002 14:05:21 +0100 (CET)
Received: from abulafia.casa (fe-d-22.4net.it [194.243.234.52])
	by flug.ferrara.linux.it (Postfix) with ESMTP
	id B0A9038057; Sun,  8 Dec 2002 14:05:20 +0100 (CET)
Date: Sun, 8 Dec 2002 14:05:09 +0100
From: Simone Piunno <pioppo@ferrara.linux.it>
To: Chris Leishman <chris@leishman.org>
Subject: Re: [ds6-devel] cvs log problems
Message-ID: <20021208130508.GC6990@ferrara.linux.it>
References: <611D54FA-0A3C-11D7-BD8D-003065F97418@leishman.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <611D54FA-0A3C-11D7-BD8D-003065F97418@leishman.org>
User-Agent: Mutt/1.3.28i
Sender: <pioppo@ferrara.linux.it>
Errors-To: <pioppo@ferrara.linux.it>
Organization: Ferrara LUG
X-Operating-System: Linux 2.4.19+i2c_sensors
X-Message: GnuPG/PGP5 are welcome
X-Key-ID: 860314FC/C09E842C
X-Key-FP: 9C15F0D3E3093593AC952C92A0CD52B4860314FC
X-Key-URL: http://members.ferrara.linux.it/pioppo/mykey.asc
cc: ds6-devel@deepspace6.net
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Sun, 08 Dec 2002 13:05:21 -0000

On Sun, Dec 08, 2002 at 01:34:07AM +0200, Chris Leishman wrote:

> The cvs log setup has some issues.  Or should I just subscribe  
> chris@deepspace6.net and unsubscribe my current address?

You are right... actually this list setup had the issue.
Now *@deepspace6.net is accepted for postings.

Thanks
-- 
Adde parvum parvo magnus acervus erit.
Simone Piunno, FerraraLUG - http://members.ferrara.linux.it/pioppo
From mauro@deepspace6.net  Sun Dec  8 15:43:52 2002
Return-Path: <mauro@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from smtp3.libero.it (smtp3.libero.it [193.70.192.127])
	by liston.ferrara.linux.it (Postfix) with ESMTP id 3CE811F7049
	for <ds6-devel@deepspace6.net>; Sun,  8 Dec 2002 15:43:52 +0100 (CET)
Received: from trantor.ferrara.linux.it (151.26.186.85) by smtp3.libero.it
	(6.7.015)        id 3DF0A6F4000D0D2B; Sun, 8 Dec 2002 15:43:52 +0100
Received: by trantor.ferrara.linux.it (Postfix, from userid 501)
	id C6A6B18F09; Sun,  8 Dec 2002 15:36:18 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
	by trantor.ferrara.linux.it (Postfix) with ESMTP
	id 67B6A18F05; Sun,  8 Dec 2002 15:36:18 +0100 (CET)
Date: Sun, 8 Dec 2002 15:36:18 +0100 (CET)
From: Mauro Tortonesi <mauro@deepspace6.net>
To: Chris Leishman <chris@leishman.org>
Subject: Re: [ds6-devel] cvs log problems
In-Reply-To: <611D54FA-0A3C-11D7-BD8D-003065F97418@leishman.org>
Message-ID: <Pine.LNX.4.44.0212081535430.11392-100000@trantor.ferrara.linux.it>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
cc: ds6-devel@deepspace6.net
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Sun, 08 Dec 2002 14:43:52 -0000

On Sun, 8 Dec 2002, Chris Leishman wrote:

> Hi,
> 
> The cvs log setup has some issues.  Or should I just subscribe  
> chris@deepspace6.net and unsubscribe my current address?

you should subscribe chris@deepspace6.net and unsubscribe your current 
address ;-)

-- 
Aequam memento rebus in arduis servare mentem...

Mauro Tortonesi			mauro@deepspace6.net
				mauro@ferrara.linux.it
Deep Space 6 - IPv6 on Linux	http://www.deepspace6.net
Ferrara Linux Users Group	http://www.ferrara.linux.it

From pioppo@ferrara.linux.it  Sun Dec  8 15:56:40 2002
Return-Path: <pioppo@ferrara.linux.it>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from flug.ferrara.linux.it (flug.4net.it [194.243.234.21])
	by liston.ferrara.linux.it (Postfix) with ESMTP
	id 2A0FB1F7049; Sun,  8 Dec 2002 15:56:40 +0100 (CET)
Received: from abulafia.casa (fe-d-22.4net.it [194.243.234.52])
	by flug.ferrara.linux.it (Postfix) with ESMTP
	id 903F938057; Sun,  8 Dec 2002 15:56:39 +0100 (CET)
Date: Sun, 8 Dec 2002 15:56:33 +0100
From: Simone Piunno <pioppo@ferrara.linux.it>
To: Mauro Tortonesi <mauro@deepspace6.net>
Subject: Re: [ds6-devel] cvs log problems
Message-ID: <20021208145633.GA14096@ferrara.linux.it>
References: <611D54FA-0A3C-11D7-BD8D-003065F97418@leishman.org>
	<Pine.LNX.4.44.0212081535430.11392-100000@trantor.ferrara.linux.it>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <Pine.LNX.4.44.0212081535430.11392-100000@trantor.ferrara.linux.it>
User-Agent: Mutt/1.3.28i
Sender: <pioppo@ferrara.linux.it>
Errors-To: <pioppo@ferrara.linux.it>
Organization: Ferrara LUG
X-Operating-System: Linux 2.4.19+i2c_sensors
X-Message: GnuPG/PGP5 are welcome
X-Key-ID: 860314FC/C09E842C
X-Key-FP: 9C15F0D3E3093593AC952C92A0CD52B4860314FC
X-Key-URL: http://members.ferrara.linux.it/pioppo/mykey.asc
cc: ds6-devel@deepspace6.net
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Sun, 08 Dec 2002 14:56:40 -0000

On Sun, Dec 08, 2002 at 03:36:18PM +0100, Mauro Tortonesi wrote:

> > The cvs log setup has some issues.  Or should I just subscribe  
> > chris@deepspace6.net and unsubscribe my current address?
> 
> you should subscribe chris@deepspace6.net and unsubscribe your current 
> address ;-)

I don't think so.

Your way he would be forced to send emails with 
From: chris@deepspace6.net
e.g. reconfiguring his mailer.

IMHO Chris can do that, be it should be because he wants, 
not because he is forced.

-- 
Adde parvum parvo magnus acervus erit.
Simone Piunno, FerraraLUG - http://members.ferrara.linux.it/pioppo
From mauro@deepspace6.net  Sun Dec  8 16:06:29 2002
Return-Path: <mauro@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from smtp1.libero.it (smtp1.libero.it [193.70.192.51])
	by liston.ferrara.linux.it (Postfix) with ESMTP id 33E261F7049
	for <ds6-devel@deepspace6.net>; Sun,  8 Dec 2002 16:06:29 +0100 (CET)
Received: from trantor.ferrara.linux.it (151.26.186.85) by smtp1.libero.it
	(6.7.015)        id 3DE22B81005B3308; Sun, 8 Dec 2002 16:06:25 +0100
Received: by trantor.ferrara.linux.it (Postfix, from userid 501)
	id B97ED18F05; Sun,  8 Dec 2002 16:03:30 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
	by trantor.ferrara.linux.it (Postfix) with ESMTP
	id B70BB18ECE; Sun,  8 Dec 2002 16:03:30 +0100 (CET)
Date: Sun, 8 Dec 2002 16:03:30 +0100 (CET)
From: Mauro Tortonesi <mauro@deepspace6.net>
To: Simone Piunno <pioppo@ferrara.linux.it>
Subject: Re: [ds6-devel] cvs log problems
In-Reply-To: <20021208145633.GA14096@ferrara.linux.it>
Message-ID: <Pine.LNX.4.44.0212081603010.11392-100000@trantor.ferrara.linux.it>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
cc: ds6-devel@deepspace6.net
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Sun, 08 Dec 2002 15:06:29 -0000

On Sun, 8 Dec 2002, Simone Piunno wrote:

> On Sun, Dec 08, 2002 at 03:36:18PM +0100, Mauro Tortonesi wrote:
> 
> > > The cvs log setup has some issues.  Or should I just subscribe  
> > > chris@deepspace6.net and unsubscribe my current address?
> > 
> > you should subscribe chris@deepspace6.net and unsubscribe your current 
> > address ;-)
> 
> I don't think so.
> 
> Your way he would be forced to send emails with 
> From: chris@deepspace6.net
> e.g. reconfiguring his mailer.
> 
> IMHO Chris can do that, be it should be because he wants, 
> not because he is forced.

as always, you're right ;-)

-- 
Aequam memento rebus in arduis servare mentem...

Mauro Tortonesi			mauro@deepspace6.net
				mauro@ferrara.linux.it
Deep Space 6 - IPv6 on Linux	http://www.deepspace6.net
Ferrara Linux Users Group	http://www.ferrara.linux.it

From chris@deepspace6.net  Mon Dec  9 23:03:08 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id 8DC2E1F7049
	for <ds6-devel@deepspace6.net>; Mon,  9 Dec 2002 23:03:08 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021209220308.8DC2E1F7049@liston.ferrara.linux.it>
Date: Mon,  9 Dec 2002 23:03:08 +0100 (CET)
Subject: [ds6-devel] nc6/src network.c,1.4,1.5
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Mon, 09 Dec 2002 22:03:08 -0000

Update of /cvs/nc6/src

Modified Files:
	network.c 
Log Message:
Stop doing reverse lookup on local address in listen mode


Index: network.c
===================================================================
RCS file: /cvs/nc6/src/network.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- network.c	7 Dec 2002 23:31:19 -0000	1.4
+++ network.c	9 Dec 2002 22:03:06 -0000	1.5
@@ -298,9 +298,7 @@
 	io_stream remote_stream, local_stream;
 	int nfd, i, fd, err, ns = -1, maxfd = -1;
 	struct addrinfo hints, *res = NULL, *ptr;
-	char hbuf_rev[NI_MAXHOST + 1];
 	char hbuf_num[NI_MAXHOST + 1];
-	char sbuf_rev[NI_MAXSERV + 1];
 	char sbuf_num[NI_MAXSERV + 1];
 	fd_set accept_fdset;
 
@@ -367,27 +365,6 @@
 		if (err != 0)
 			fatal("getnameinfo failed: %s", gai_strerror(err));
 
-		/* get the real name for this destination as a string */
-		if ((is_flag_set(NUMERIC_MODE) == FALSE) && 
-		    (is_flag_set(VERY_VERBOSE_MODE) == TRUE))
-		{
-			/* try reverse dns lookup */
-			err = getnameinfo(ptr->ai_addr, ptr->ai_addrlen,
-				          hbuf_rev, sizeof(hbuf_rev), sbuf_rev, 
-				          sizeof(sbuf_rev), 0);
-			if(err != 0)
-				warn("inverse lookup failed for %s: %s",
-				     hbuf_num, gai_strerror(err));
-		} else {
-			err = 1;
-		}
-
-		if (err != 0) {
-			/* just make the real name the numeric string */
-			strcpy(hbuf_rev, hbuf_num);
-			strcpy(sbuf_rev, sbuf_num);
-		}
-
 		/* create the socket */
 		fd = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
 		if(fd < 0) fatal("cannot create the socket: %s", strerror(errno));
@@ -412,8 +389,8 @@
 		/* bind to the local address */
 		err = bind(fd, ptr->ai_addr, ptr->ai_addrlen);
 		if (err != 0) {
-			warn("bind to source %s [%s] %s (%s) failed: %s",
-			     hbuf_rev, hbuf_num, sbuf_num, sbuf_rev, strerror(errno));
+			warn("bind to source %s (%s) failed: %s",
+			     hbuf_num, sbuf_num, strerror(errno));
 			close(fd);
 			continue;
 		}
@@ -425,13 +402,13 @@
 		if (ptr->ai_socktype == SOCK_STREAM) {
 			err = listen(fd, 5);
 			if (err != 0)
-				fatal("cannot listen on %s [%s] %s (%s): %s",
-				      hbuf_rev, hbuf_num, sbuf_num, sbuf_rev, strerror(errno));
+				fatal("cannot listen on %s (%s): %s",
+				      hbuf_num, sbuf_num, strerror(errno));
 		}
 
 		if (is_flag_set(VERBOSE_MODE) == TRUE)
-			warn("listening on %s [%s] %s (%s) ...",
-			      hbuf_rev, hbuf_num, sbuf_num, sbuf_rev, strerror(errno));
+			warn("listening on %s (%s) ...",
+			      hbuf_num, sbuf_num, strerror(errno));
 
 		/* add fd to accept_fdset */
 		FD_SET(fd, &accept_fdset);

From chris@deepspace6.net  Mon Dec  9 23:16:41 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id 3BF161F7049
	for <ds6-devel@deepspace6.net>; Mon,  9 Dec 2002 23:16:41 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021209221641.3BF161F7049@liston.ferrara.linux.it>
Date: Mon,  9 Dec 2002 23:16:41 +0100 (CET)
Subject: [ds6-devel] nc6/src circ_buf.c,1.4,1.5 circ_buf.h,1.5,1.6
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Mon, 09 Dec 2002 22:16:41 -0000

Update of /cvs/nc6/src

Modified Files:
	circ_buf.c circ_buf.h 
Log Message:
Added a clear_cb function


Index: circ_buf.c
===================================================================
RCS file: /cvs/nc6/src/circ_buf.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- circ_buf.c	28 Nov 2002 20:24:48 -0000	1.4
+++ circ_buf.c	9 Dec 2002 22:16:39 -0000	1.5
@@ -290,6 +290,15 @@
 
 
 
+void clear_cb(circ_buf *cb)
+{
+	assert(cb);
+	cb->ptr = cb->buf;
+	cb->data_size = 0;
+}
+
+
+
 circ_buf *alloc_cb(size_t size)
 {
 	circ_buf *cb;
Index: circ_buf.h
===================================================================
RCS file: /cvs/nc6/src/circ_buf.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- circ_buf.h	28 Nov 2002 20:24:48 -0000	1.5
+++ circ_buf.h	9 Dec 2002 22:16:39 -0000	1.6
@@ -41,6 +41,7 @@
 int copy_to_cb(const uint8_t *buf, size_t len, circ_buf *cb);
 int write_from_cb(int fd, circ_buf *cb);
 int send_from_cb(int fd, circ_buf *cb, struct sockaddr *dest, size_t destlen);
+void clear_cb(circ_buf *cb);
 circ_buf *alloc_cb(size_t size);
 void free_cb(circ_buf **cb);
 

From chris@deepspace6.net  Mon Dec  9 23:19:25 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id C58201F7049
	for <ds6-devel@deepspace6.net>; Mon,  9 Dec 2002 23:19:25 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021209221925.C58201F7049@liston.ferrara.linux.it>
Date: Mon,  9 Dec 2002 23:19:25 +0100 (CET)
Subject: [ds6-devel] nc6/src readwrite.c,1.8,1.9
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Mon, 09 Dec 2002 22:19:26 -0000

Update of /cvs/nc6/src

Modified Files:
	readwrite.c 
Log Message:
Added cleaner handling of EPIPE errors for writes


Index: readwrite.c
===================================================================
RCS file: /cvs/nc6/src/readwrite.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- readwrite.c	7 Dec 2002 23:38:26 -0000	1.8
+++ readwrite.c	9 Dec 2002 22:19:23 -0000	1.9
@@ -160,6 +160,8 @@
 	 * 
 	 * 1) the local or the remote input streams has been closed
 	 * 2) the timeout set by the user is expired 
+	 *
+	 * a pipe error when writing either stream will also exit the loop.
 	 */
 	while(((timeout_mode == FALSE) && (ios1->fd_in >= 0)) ||
 	      ((timeout_mode == TRUE) && (((ios1->fd_in >= 0) || 
@@ -327,8 +329,20 @@
 			} else if (rr < 0 && errno != EAGAIN) {
 				/* error while writing to ios1->fd_out:
 				 * print an error message and exit. */
-				fatal("error writing to fd %d: %s",
-					ios1->fd_out, strerror(errno));
+				if (errno != EPIPE)
+					fatal("error writing to fd %d: %s",
+						ios1->fd_out, strerror(errno));
+				
+				/* the pipe is broken, clear buffer and stop the loop */
+#ifndef NDEBUG
+				if (is_flag_set(VERY_VERBOSE_MODE) == TRUE)
+					warn("received SIGPIPE on ios1 (%d)", ios1->fd_out);
+#endif
+
+				clear_cb(buf2);
+
+				/* exit the main loop */
+				break;
 			}
 		}
 
@@ -364,8 +378,20 @@
 			} else if (rr < 0 && errno != EAGAIN) {
 				/* error while writing to ios1->fd_out:
 				 * print an error message and exit. */
-				fatal("error writing to fd %d: %s",
-					ios2->fd_out, strerror(errno));
+				if (errno != EPIPE)
+					fatal("error writing to fd %d: %s",
+						ios2->fd_out, strerror(errno));
+				
+				/* the pipe is broken, clear buffer and stop the loop */
+#ifndef NDEBUG
+				if (is_flag_set(VERY_VERBOSE_MODE) == TRUE)
+					warn("received SIGPIPE on ios2 (%d)", ios2->fd_out);
+#endif
+
+				clear_cb(buf1);
+
+				/* exit the main loop */
+				break;
 			}
 		}
 	}

From chris@leishman.org  Tue Dec 10 00:01:08 2002
Return-Path: <chris@leishman.org>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from oulu.fi (ousrvr.oulu.fi [130.231.240.1])
	by liston.ferrara.linux.it (Postfix) with ESMTP id A1B4A1F7049
	for <ds6-devel@deepspace6.net>; Tue, 10 Dec 2002 00:01:07 +0100 (CET)
Received: from leishman.org (angela-dsl.oulu.fi [130.231.168.252])
	by oulu.fi (8.8.5/8.8.5) with ESMTP id BAA25666
	for <ds6-devel@deepspace6.net>; Tue, 10 Dec 2002 01:01:06 +0200 (EET)
Date: Tue, 10 Dec 2002 01:01:11 +0200
Mime-Version: 1.0 (Apple Message framework v548)
Content-Type: text/plain; charset=US-ASCII; format=flowed
From: Chris Leishman <chris@leishman.org>
To: ds6-devel@deepspace6.net
Content-Transfer-Encoding: 7bit
Message-Id: <1BE9BFB4-0BCA-11D7-AE36-003065F97418@leishman.org>
X-Mailer: Apple Mail (2.548)
Subject: [ds6-devel] Timeouts in nc6
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Mon, 09 Dec 2002 23:01:08 -0000

Hi,

Currently, at the end of the read/write loop in nc6, it attempts to 
flush as much of the buffer as possible (until the socket would block - 
then it stops).  I don't really like this behavior, since it could 
potentially fail to write data to the remote host before exiting (in 
file transfer mode for instance).

I can rework the read/write loop so that it continues until the buffers 
are flushed out - but this would potentially add the situation where 
nc6 blocks indefinitely waiting to flush the buffers.  This isn't an 
issue in the normal situation, but I'm not sure how it applies to 
timeouts.

The timeouts are currently implemented as a way of closing the transfer 
(reading and writing) N seconds after a given stream (local and/or 
remote) can no longer be read from - regardless of pending writes.  But 
I'm wondering if it should be that all reads stop after N seconds - and 
writes can still continue?

Opinions?

Also - should a timeout be an error (eg. make nc6 return a non-zero 
error code)?

Regards,
Chris

From mauro@deepspace6.net  Tue Dec 10 00:34:03 2002
Return-Path: <mauro@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from smtp3.libero.it (smtp3.libero.it [193.70.192.127])
	by liston.ferrara.linux.it (Postfix) with ESMTP id 012D01F7049
	for <ds6-devel@deepspace6.net>; Tue, 10 Dec 2002 00:34:02 +0100 (CET)
Received: from trantor.ferrara.linux.it (151.26.184.167) by smtp3.libero.it
	(6.7.015)        id 3DF0A6F40019C4C9; Tue, 10 Dec 2002 00:34:03 +0100
Received: by trantor.ferrara.linux.it (Postfix, from userid 501)
	id 88EFC18ECB; Tue, 10 Dec 2002 00:30:29 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
	by trantor.ferrara.linux.it (Postfix) with ESMTP
	id A717F18ECA; Tue, 10 Dec 2002 00:30:29 +0100 (CET)
Date: Tue, 10 Dec 2002 00:30:28 +0100 (CET)
From: Mauro Tortonesi <mauro@deepspace6.net>
To: Chris Leishman <chris@leishman.org>
Subject: Re: [ds6-devel] Timeouts in nc6
In-Reply-To: <1BE9BFB4-0BCA-11D7-AE36-003065F97418@leishman.org>
Message-ID: <Pine.LNX.4.44.0212100021180.12052-100000@trantor.ferrara.linux.it>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
cc: ds6-devel@deepspace6.net
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Mon, 09 Dec 2002 23:34:03 -0000

On Tue, 10 Dec 2002, Chris Leishman wrote:

> Hi,
> 
> Currently, at the end of the read/write loop in nc6, it attempts to 
> flush as much of the buffer as possible (until the socket would block - 
> then it stops).  I don't really like this behavior, since it could 
> potentially fail to write data to the remote host before exiting (in 
> file transfer mode for instance).

that's why i changed the read and writes to sockets from nonblocking to 
blocking - it used to break file transfer mode.

moreover, as we use select to do writes and reads only when the socket 
is ready, there is really no reason to set the socket status to 
nonblocking.

did i miss something?

> I can rework the read/write loop so that it continues until the buffers 
> are flushed out - but this would potentially add the situation where 
> nc6 blocks indefinitely waiting to flush the buffers.  This isn't an 
> issue in the normal situation, but I'm not sure how it applies to 
> timeouts.

i'll take a look at this tomorrow.

> The timeouts are currently implemented as a way of closing the transfer 
> (reading and writing) N seconds after a given stream (local and/or 
> remote) can no longer be read from - regardless of pending writes.  But 
> I'm wondering if it should be that all reads stop after N seconds - and 
> writes can still continue?
> 
> Opinions?

we can add a --noexit option to support even this behaviour.

> Also - should a timeout be an error (eg. make nc6 return a non-zero 
> error code)?

IMVHO, no. the user explicitly sets timeout.

-- 
Aequam memento rebus in arduis servare mentem...

Mauro Tortonesi			mauro@deepspace6.net
				mauro@ferrara.linux.it
Deep Space 6 - IPv6 on Linux	http://www.deepspace6.net
Ferrara Linux Users Group	http://www.ferrara.linux.it

From chris@leishman.org  Tue Dec 10 01:00:20 2002
Return-Path: <chris@leishman.org>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from oulu.fi (ousrvr.oulu.fi [130.231.240.1])
	by liston.ferrara.linux.it (Postfix) with ESMTP
	id D99EF1F7049; Tue, 10 Dec 2002 01:00:19 +0100 (CET)
Received: from leishman.org (angela-dsl.oulu.fi [130.231.168.252])
	by oulu.fi (8.8.5/8.8.5) with ESMTP id CAA27968;
	Tue, 10 Dec 2002 02:00:19 +0200 (EET)
Date: Tue, 10 Dec 2002 02:00:23 +0200
Subject: Re: [ds6-devel] Timeouts in nc6
Content-Type: text/plain; charset=US-ASCII; format=flowed
Mime-Version: 1.0 (Apple Message framework v548)
To: Mauro Tortonesi <mauro@deepspace6.net>
From: Chris Leishman <chris@leishman.org>
In-Reply-To: <Pine.LNX.4.44.0212100021180.12052-100000@trantor.ferrara.linux.it>
Message-Id: <61350420-0BD2-11D7-AE36-003065F97418@leishman.org>
Content-Transfer-Encoding: 7bit
X-Mailer: Apple Mail (2.548)
cc: ds6-devel@deepspace6.net
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Tue, 10 Dec 2002 00:00:20 -0000


On Tuesday, December 10, 2002, at 01:30 AM, Mauro Tortonesi wrote:

> On Tue, 10 Dec 2002, Chris Leishman wrote:
>
>> Hi,
>>
>> Currently, at the end of the read/write loop in nc6, it attempts to
>> flush as much of the buffer as possible (until the socket would block 
>> -
>> then it stops).  I don't really like this behavior, since it could
>> potentially fail to write data to the remote host before exiting (in
>> file transfer mode for instance).
>
> that's why i changed the read and writes to sockets from nonblocking to
> blocking - it used to break file transfer mode.
>
> moreover, as we use select to do writes and reads only when the socket
> is ready, there is really no reason to set the socket status to
> nonblocking.
>
> did i miss something?

Not at all.  The nonblock is only needed to ensure that flushing is 
non-blocking.  In the body of the loop it doesn't matter.


>> I can rework the read/write loop so that it continues until the 
>> buffers
>> are flushed out - but this would potentially add the situation where
>> nc6 blocks indefinitely waiting to flush the buffers.  This isn't an
>> issue in the normal situation, but I'm not sure how it applies to
>> timeouts.
>
> i'll take a look at this tomorrow.

No need to look at it - I know how it behaves now - but I'm not sure if 
it's desired (see next comment).

>> The timeouts are currently implemented as a way of closing the 
>> transfer
>> (reading and writing) N seconds after a given stream (local and/or
>> remote) can no longer be read from - regardless of pending writes.  
>> But
>> I'm wondering if it should be that all reads stop after N seconds - 
>> and
>> writes can still continue?
>>
>> Opinions?
>
> we can add a --noexit option to support even this behaviour.

I'm not sure what you mean.  My question is more whether the timeouts 
SHOULD simply abort the transfer regardless of whether there is 
unwritten data in the buffer or not - or if it should try to write this 
data out before exiting (and potentially block while doing so).

>> Also - should a timeout be an error (eg. make nc6 return a non-zero
>> error code)?
>
> IMVHO, no. the user explicitly sets timeout.

Ok.  I just thought that since this situation means the user has no way 
of knowing whether the any pending data was successfully written or 
not, it might be wise to indicate that in the return status.


Let me clarify what I'm asking with an example.

A "hold timeout" is set on the remote stream (say 4 sec).

1) The remote sides closes read (EOF), then the local side closes 
(before the timeout).
Result: success
Local buffer flushed: YES
Remote buffer flushed: YES

2) The remote side closes read, local side is still sending and 4 
seconds elapses and timeout occurs (there is still data in the local 
buffer to be written to the remote stream).
Result: ?
Local buffer flushed: ?
Remote buffer flushed: ?

3) The remote side closes read, data is still waiting to be written to 
local stream (in remote buffer) and 4 seconds elapses.
Result: ?
Local buffer flushed: ?
Remote buffer flushed: ?


I think I'm of the opinion that the "hold timeout" should simply cause 
all reading to be aborted, but writes to continue until all buffers are 
flushed or an error occurs.

I'm not sure about the error status.  On one hand it could be 
considered "desired behavior" and on the other I feel that the user 
should know if there is no guarantee that data was actually 
send/received (which will still be the case regardless of buffer 
flushing).

Regards,
Chris

From mauro@deepspace6.net  Tue Dec 10 01:10:53 2002
Return-Path: <mauro@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from smtp1.libero.it (smtp1.libero.it [193.70.192.51])
	by liston.ferrara.linux.it (Postfix) with ESMTP
	id 50FD41F7049; Tue, 10 Dec 2002 01:10:53 +0100 (CET)
Received: from trantor.ferrara.linux.it (151.26.184.167) by smtp1.libero.it
	(6.7.015)        id 3DE22B810067E820; Tue, 10 Dec 2002 01:10:49 +0100
Received: by trantor.ferrara.linux.it (Postfix, from userid 501)
	id 274E118ECB; Tue, 10 Dec 2002 01:08:14 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
	by trantor.ferrara.linux.it (Postfix) with ESMTP
	id 0F94718ECA; Tue, 10 Dec 2002 01:08:14 +0100 (CET)
Date: Tue, 10 Dec 2002 01:08:14 +0100 (CET)
From: Mauro Tortonesi <mauro@deepspace6.net>
To: Chris Leishman <chris@leishman.org>
Subject: Re: [ds6-devel] Timeouts in nc6
In-Reply-To: <61350420-0BD2-11D7-AE36-003065F97418@leishman.org>
Message-ID: <Pine.LNX.4.44.0212100100030.12052-100000@trantor.ferrara.linux.it>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
cc: ds6-devel@deepspace6.net
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Tue, 10 Dec 2002 00:10:53 -0000

On Tue, 10 Dec 2002, Chris Leishman wrote:

> 
> On Tuesday, December 10, 2002, at 01:30 AM, Mauro Tortonesi wrote:
> 
> > On Tue, 10 Dec 2002, Chris Leishman wrote:
> >
> >> Hi,
> >>
> >> Currently, at the end of the read/write loop in nc6, it attempts to
> >> flush as much of the buffer as possible (until the socket would block 
> >> -
> >> then it stops).  I don't really like this behavior, since it could
> >> potentially fail to write data to the remote host before exiting (in
> >> file transfer mode for instance).
> >
> > that's why i changed the read and writes to sockets from nonblocking to
> > blocking - it used to break file transfer mode.
> >
> > moreover, as we use select to do writes and reads only when the socket
> > is ready, there is really no reason to set the socket status to
> > nonblocking.
> >
> > did i miss something?
> 
> Not at all.  The nonblock is only needed to ensure that flushing is 
> non-blocking.  In the body of the loop it doesn't matter.

so, IMVHO we should use blocking sockets. personally, i don't care if 
there are even a few seconds of blocking wait for the flush of the 
buffers at the end of the program (after the loop).

what do you say?

> >> The timeouts are currently implemented as a way of closing the 
> >> transfer
> >> (reading and writing) N seconds after a given stream (local and/or
> >> remote) can no longer be read from - regardless of pending writes.  
> >> But
> >> I'm wondering if it should be that all reads stop after N seconds - 
> >> and
> >> writes can still continue?
> >>
> >> Opinions?
> >
> > we can add a --noexit option to support even this behaviour.
> 
> I'm not sure what you mean.  My question is more whether the timeouts 
> SHOULD simply abort the transfer regardless of whether there is 
> unwritten data in the buffer or not - or if it should try to write this 
> data out before exiting (and potentially block while doing so).

i would go for the second - try to write as much as we can.

> >> Also - should a timeout be an error (eg. make nc6 return a non-zero
> >> error code)?
> >
> > IMVHO, no. the user explicitly sets timeout.
> 
> Ok.  I just thought that since this situation means the user has no way 
> of knowing whether the any pending data was successfully written or 
> not, it might be wise to indicate that in the return status.
> 
> 
> Let me clarify what I'm asking with an example.
> 
> A "hold timeout" is set on the remote stream (say 4 sec).
> 
> 1) The remote sides closes read (EOF), then the local side closes 
> (before the timeout).
> Result: success
> Local buffer flushed: YES
> Remote buffer flushed: YES
> 
> 2) The remote side closes read, local side is still sending and 4 
> seconds elapses and timeout occurs (there is still data in the local 
> buffer to be written to the remote stream).
> Result: ?
> Local buffer flushed: ?
> Remote buffer flushed: ?
> 
> 3) The remote side closes read, data is still waiting to be written to 
> local stream (in remote buffer) and 4 seconds elapses.
> Result: ?
> Local buffer flushed: ?
> Remote buffer flushed: ?
> 
> 
> I think I'm of the opinion that the "hold timeout" should simply cause 
> all reading to be aborted, but writes to continue until all buffers are 
> flushed or an error occurs.

right.

> I'm not sure about the error status.  On one hand it could be 
> considered "desired behavior" and on the other I feel that the user 
> should know if there is no guarantee that data was actually 
> send/received (which will still be the case regardless of buffer 
> flushing).

what about setting a well-defined error status?

-- 
Aequam memento rebus in arduis servare mentem...

Mauro Tortonesi			mauro@deepspace6.net
				mauro@ferrara.linux.it
Deep Space 6 - IPv6 on Linux	http://www.deepspace6.net
Ferrara Linux Users Group	http://www.ferrara.linux.it

From chris@leishman.org  Tue Dec 10 01:17:53 2002
Return-Path: <chris@leishman.org>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from oulu.fi (ousrvr.oulu.fi [130.231.240.1])
	by liston.ferrara.linux.it (Postfix) with ESMTP
	id 0DDBA1F7049; Tue, 10 Dec 2002 01:17:53 +0100 (CET)
Received: from leishman.org (angela-dsl.oulu.fi [130.231.168.252])
	by oulu.fi (8.8.5/8.8.5) with ESMTP id CAA28543;
	Tue, 10 Dec 2002 02:17:52 +0200 (EET)
Date: Tue, 10 Dec 2002 02:17:56 +0200
Subject: Re: [ds6-devel] Timeouts in nc6
Content-Type: text/plain; charset=US-ASCII; format=flowed
Mime-Version: 1.0 (Apple Message framework v548)
To: Mauro Tortonesi <mauro@deepspace6.net>
From: Chris Leishman <chris@leishman.org>
In-Reply-To: <Pine.LNX.4.44.0212100100030.12052-100000@trantor.ferrara.linux.it>
Message-Id: <D4DCE53B-0BD4-11D7-AE36-003065F97418@leishman.org>
Content-Transfer-Encoding: 7bit
X-Mailer: Apple Mail (2.548)
cc: ds6-devel@deepspace6.net
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Tue, 10 Dec 2002 00:17:53 -0000


On Tuesday, December 10, 2002, at 02:08 AM, Mauro Tortonesi wrote:
<snip>
> so, IMVHO we should use blocking sockets. personally, i don't care if
> there are even a few seconds of blocking wait for the flush of the
> buffers at the end of the program (after the loop).
>
> what do you say?

I agree.  I'll make it so.

<snip>
> i would go for the second - try to write as much as we can.

Ok.  Again, I'll add this in.


> what about setting a well-defined error status?

We'll just have to think about what that should be.  For now I'll just 
leave it as no-error, but make it trivial to change.

Regards,
Chris

From chris@leishman.org  Tue Dec 10 01:33:38 2002
Return-Path: <chris@leishman.org>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from oulu.fi (ousrvr.oulu.fi [130.231.240.1])
	by liston.ferrara.linux.it (Postfix) with ESMTP id B50401F7049
	for <ds6-devel@deepspace6.net>; Tue, 10 Dec 2002 01:33:37 +0100 (CET)
Received: from leishman.org (angela-dsl.oulu.fi [130.231.168.252])
	by oulu.fi (8.8.5/8.8.5) with ESMTP id CAA29073
	for <ds6-devel@deepspace6.net>; Tue, 10 Dec 2002 02:33:36 +0200 (EET)
Date: Tue, 10 Dec 2002 02:33:40 +0200
Mime-Version: 1.0 (Apple Message framework v548)
Content-Type: text/plain; charset=US-ASCII; format=flowed
From: Chris Leishman <chris@leishman.org>
To: ds6-devel@deepspace6.net
Content-Transfer-Encoding: 7bit
Message-Id: <07C4F984-0BD7-11D7-AE36-003065F97418@leishman.org>
X-Mailer: Apple Mail (2.548)
Subject: [ds6-devel] nc6 refactor
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Tue, 10 Dec 2002 00:33:38 -0000

Hi all,

I've done some more cleaning and reorganising of the nc6 code.  
Apologies if I'm stepping on any toes, but I think these cleanups will 
really help.

I'm committing the changes to a branch "chris_refactor_101202" so that 
you can give me your comments.  Then hopefully I can merge them into 
the main branch.

The following changes have been made:

- Reorganised execution flow so that each stage of processing (parsing 
args, opening connections, readwrite loop) are separate and called from 
main, rather than being called depth wise (parser->connect->readwrite). 
  This makes the code easier to follow and allows us some flexibility 
for doing things like INET modes, etc.

- Moved io_stream code into it's own header/source and added additional 
"methods" to act upon the stream.

- Moved connection_attributes into it's own header/source and added the 
remote&local addresses and streams to it.  This allows the parser stage 
to configure everything and then return it to main.

- Removed the timeout header/source and instead added a "hold_time" to 
the io_stream.
This makes the function of the timer very clear and allows for better 
control of timers.  It also significantly simplifies the exit 
conditions in the read/write loop.  The updated io_stream interface 
supplies a method to retrieve the time until the next timeout, allowing 
the readwrite loop to accurately trigger timeouts without the need to 
poll.  It also allows for the addition of other timeouts, such as an 
idle timeout, trivially.

The simplification of the read/write loop exit conditions also allows 
for socket "shutdowns" to be correctly handled (as per what I 
originally wanted from netcat way back when) simply by supplying 
"infinite" hold times.

- Renamed "port" in struct address_t to "service" to better reflect 
it's usage.

- Reorganised include order for consistency across project files.

- Various other cleanups.


Please review and give your opinions asap.  If there's no issues I'd 
like to merge this stuff before I do any of the fixes to the timeouts 
we have just discussed.

Regards,
Chris

From chris@deepspace6.net  Tue Dec 10 01:36:38 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id 557721F7049
	for <ds6-devel@deepspace6.net>; Tue, 10 Dec 2002 01:36:38 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021210003638.557721F7049@liston.ferrara.linux.it>
Date: Tue, 10 Dec 2002 01:36:38 +0100 (CET)
Subject: [ds6-devel] nc6/src readwrite.c,1.9.2.1,1.9.2.2
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Tue, 10 Dec 2002 00:36:38 -0000

Update of /cvs/nc6/src

Modified Files:
      Tag: chris_refactor_101202
	readwrite.c 
Log Message:
As discussed, timeout shouldn't be a failure (for now).


Index: readwrite.c
===================================================================
RCS file: /cvs/nc6/src/readwrite.c,v
retrieving revision 1.9.2.1
retrieving revision 1.9.2.2
diff -u -d -r1.9.2.1 -r1.9.2.2
--- readwrite.c	10 Dec 2002 00:34:10 -0000	1.9.2.1
+++ readwrite.c	10 Dec 2002 00:36:36 -0000	1.9.2.2
@@ -178,7 +178,6 @@
 
 		/* stop if either ios has timed out */
 		if ((tvp1 && !timerisset(tvp1)) || (tvp2 && !timerisset(tvp2))) {
-			retval = -1;
 			break;
 		}
 

From mauro@deepspace6.net  Wed Dec 11 01:01:03 2002
Return-Path: <mauro@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from smtp0.libero.it (smtp0.libero.it [193.70.192.33])
	by liston.ferrara.linux.it (Postfix) with ESMTP id 1EAC81F7049
	for <ds6-devel@deepspace6.net>; Wed, 11 Dec 2002 01:01:03 +0100 (CET)
Received: from trantor.ferrara.linux.it (151.26.186.36) by smtp0.libero.it
	(6.7.015)        id 3DE22A34006F6FA9; Wed, 11 Dec 2002 01:01:03 +0100
Received: by trantor.ferrara.linux.it (Postfix, from userid 501)
	id 71EBE18F09; Wed, 11 Dec 2002 00:57:51 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
	by trantor.ferrara.linux.it (Postfix) with ESMTP
	id 6F69A18F05; Wed, 11 Dec 2002 00:57:51 +0100 (CET)
Date: Wed, 11 Dec 2002 00:57:51 +0100 (CET)
From: Mauro Tortonesi <mauro@deepspace6.net>
To: ds6-devel@deepspace6.net, <chris@leishman.org>
Message-ID: <Pine.LNX.4.44.0212110053170.12443-100000@trantor.ferrara.linux.it>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Subject: [ds6-devel] refactoring
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Wed, 11 Dec 2002 00:01:03 -0000


hi chris, 

	i was looking at the refactoring you've done with nc6. it's 
another impressive work! i am _really_ enthusiast with it. 

	but, please, wait at least until tomorrow (when i will be able to 
take a better look at the code and do a better report) to make the 
refactoring tree the default one.

-- 
Aequam memento rebus in arduis servare mentem...

Mauro Tortonesi			mauro@deepspace6.net
				mauro@ferrara.linux.it
Deep Space 6 - IPv6 on Linux	http://www.deepspace6.net
Ferrara Linux Users Group	http://www.ferrara.linux.it

From mauro@deepspace6.net  Wed Dec 11 01:04:13 2002
Return-Path: <mauro@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from smtp2.libero.it (smtp2.libero.it [193.70.192.52])
	by liston.ferrara.linux.it (Postfix) with ESMTP
	id 179AE1F7049; Wed, 11 Dec 2002 01:04:13 +0100 (CET)
Received: from trantor.ferrara.linux.it (151.26.186.36) by smtp2.libero.it
	(6.7.015)        id 3DE3532300688A3D; Wed, 11 Dec 2002 01:04:12 +0100
Received: by trantor.ferrara.linux.it (Postfix, from userid 501)
	id 5703218F28; Wed, 11 Dec 2002 01:01:26 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
	by trantor.ferrara.linux.it (Postfix) with ESMTP
	id 4E5ED18F05; Wed, 11 Dec 2002 01:01:26 +0100 (CET)
Date: Wed, 11 Dec 2002 01:01:26 +0100 (CET)
From: Mauro Tortonesi <mauro@deepspace6.net>
To: ds6-backend@deepspace6.net, <ds6-devel@deepspace6.net>
Message-ID: <Pine.LNX.4.44.0212110100010.12443-100000@trantor.ferrara.linux.it>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Subject: [ds6-devel] bug report tracking tool
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Wed, 11 Dec 2002 00:04:13 -0000


should we set up a bug report tracking tool for our software projects?

-- 
Aequam memento rebus in arduis servare mentem...

Mauro Tortonesi			mauro@deepspace6.net
				mauro@ferrara.linux.it
Deep Space 6 - IPv6 on Linux	http://www.deepspace6.net
Ferrara Linux Users Group	http://www.ferrara.linux.it

From pb@bieringer.de  Wed Dec 11 08:48:24 2002
Return-Path: <pb@bieringer.de>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from smtp2.aerasec.de (gromit.aerasec.de [195.226.187.57])
	by liston.ferrara.linux.it (Postfix) with ESMTP
	id 4AD9E1F7049; Wed, 11 Dec 2002 08:48:24 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
	by smtp2.aerasec.de (Postfix) with SMTP
	id D341C13864; Wed, 11 Dec 2002 08:48:23 +0100 (CET)
X-AV-Checked: Wed Dec 11 08:48:23 2002 smtp2.aerasec.de
Received: from pD9E4ECF1.dip.t-dialin.net (pD9E4ECF1.dip.t-dialin.net
	[217.228.236.241])
	(using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits))
	(Client did not present a certificate)
	by smtp2.aerasec.de (Postfix) with ESMTP
	id 4818313863; Wed, 11 Dec 2002 08:48:23 +0100 (CET)
Date: Wed, 11 Dec 2002 08:42:23 +0100
From: Peter Bieringer <pb@bieringer.de>
To: ds6-backend@deepspace6.net, ds6-devel@deepspace6.net
Subject: Re: [ds6-devel] bug report tracking tool
Message-ID: <7300000.1039592543@gate.muc.bieringer.de>
In-Reply-To: <Pine.LNX.4.44.0212110100010.12443-100000@trantor.ferrara.linux.it>
References: <Pine.LNX.4.44.0212110100010.12443-100000@trantor.ferrara.
 linux.it>
X-Mailer: Mulberry/3.0.0b9 (Linux/x86)
X-URL: http://www.bieringer.de/pb/
X-OS: Linux
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Wed, 11 Dec 2002 07:48:24 -0000



--On Wednesday, December 11, 2002 01:01:26 AM +0100 Mauro Tortonesi
<mauro@deepspace6.net> wrote:

> should we set up a bug report tracking tool for our software
> projects?

I can only say something about my small projects:
        * perhaps an overkill, currently not needed

        Peter

---
Dr. Peter Bieringer
mailto: pb at bieringer dot de
http://www.bieringer.de/pb/
Key 0x958F422D : B501 24F4 9418 23E2 C0F3  F833 7B57 AA7B 958F 422D
From chris@leishman.org  Wed Dec 11 10:26:44 2002
Return-Path: <chris@leishman.org>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from oulu.fi (ousrvr.oulu.fi [130.231.240.1])
	by liston.ferrara.linux.it (Postfix) with ESMTP
	id E23081F7049; Wed, 11 Dec 2002 10:26:43 +0100 (CET)
Received: from leishman.org (angela-dsl.oulu.fi [130.231.168.252])
	by oulu.fi (8.8.5/8.8.5) with ESMTP id LAA21661;
	Wed, 11 Dec 2002 11:26:40 +0200 (EET)
Date: Wed, 11 Dec 2002 11:26:47 +0200
Subject: Re: [ds6-devel] bug report tracking tool
Content-Type: text/plain; charset=US-ASCII; format=flowed
Mime-Version: 1.0 (Apple Message framework v548)
To: Mauro Tortonesi <mauro@deepspace6.net>
From: Chris Leishman <chris@leishman.org>
In-Reply-To: <Pine.LNX.4.44.0212110100010.12443-100000@trantor.ferrara.linux.it>
Message-Id: <ABE9D492-0CEA-11D7-B170-003065F97418@leishman.org>
Content-Transfer-Encoding: 7bit
X-Mailer: Apple Mail (2.548)
cc: ds6-devel@deepspace6.net
cc: ds6-backend@deepspace6.net
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Wed, 11 Dec 2002 09:26:44 -0000


On Wednesday, December 11, 2002, at 02:01 AM, Mauro Tortonesi wrote:

>
> should we set up a bug report tracking tool for our software projects?

I agree.  IMHO anything with more than 1 developer should have a proper 
bug tracking system.  It doesn't have to be anything fancy though.

Regards,
Chris

From chris@deepspace6.net  Wed Dec 11 12:20:23 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id C3E8F1F7049
	for <ds6-devel@deepspace6.net>; Wed, 11 Dec 2002 12:20:23 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021211112023.C3E8F1F7049@liston.ferrara.linux.it>
Date: Wed, 11 Dec 2002 12:20:23 +0100 (CET)
Subject: [ds6-devel] nc6/src parser.c,1.6.2.1,1.6.2.2
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Wed, 11 Dec 2002 11:20:24 -0000

Update of /cvs/nc6/src

Modified Files:
      Tag: chris_refactor_101202
	parser.c 
Log Message:
Removed some left over debug code


Index: parser.c
===================================================================
RCS file: /cvs/nc6/src/parser.c,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -d -r1.6.2.1 -r1.6.2.2
--- parser.c	10 Dec 2002 00:34:10 -0000	1.6.2.1
+++ parser.c	11 Dec 2002 11:20:21 -0000	1.6.2.2
@@ -199,14 +199,12 @@
 static void parse_and_set_timeouts(const char *str,
 		connection_attributes *attrs)
 {
-	int time;
 	char *s;
 
 	assert(str != NULL);
 
 	if ((s = strchr(str, ':')) != NULL) {
 		*s++ = '\0';
-		time = (s[0] == '-')? -1 : safe_atoi(s);
 		ios_set_hold_timeout(&(attrs->remote_stream),
 		      (s[0] == '-')? -1 : safe_atoi(s));
 	}

From mauro@deepspace6.net  Wed Dec 11 16:04:19 2002
Return-Path: <mauro@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from smtp1.libero.it (smtp1.libero.it [193.70.192.51])
	by liston.ferrara.linux.it (Postfix) with ESMTP
	id E6CD21F7046; Wed, 11 Dec 2002 16:04:18 +0100 (CET)
Received: from trantor.ferrara.linux.it (151.26.186.115) by smtp1.libero.it
	(6.7.015)        id 3DE22B810072CD8C; Wed, 11 Dec 2002 16:03:55 +0100
Received: by trantor.ferrara.linux.it (Postfix, from userid 501)
	id 8506818F28; Wed, 11 Dec 2002 13:09:31 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
	by trantor.ferrara.linux.it (Postfix) with ESMTP
	id 8279518F24; Wed, 11 Dec 2002 13:09:31 +0100 (CET)
Date: Wed, 11 Dec 2002 13:09:31 +0100 (CET)
From: Mauro Tortonesi <mauro@deepspace6.net>
To: Chris Leishman <chris@leishman.org>
Subject: Re: [ds6-devel] bug report tracking tool
In-Reply-To: <ABE9D492-0CEA-11D7-B170-003065F97418@leishman.org>
Message-ID: <Pine.LNX.4.44.0212111308490.11270-100000@trantor.ferrara.linux.it>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
cc: ds6-devel@deepspace6.net
cc: ds6-backend@deepspace6.net
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Wed, 11 Dec 2002 15:04:19 -0000

On Wed, 11 Dec 2002, Chris Leishman wrote:

> On Wednesday, December 11, 2002, at 02:01 AM, Mauro Tortonesi wrote:
> 
> >
> > should we set up a bug report tracking tool for our software projects?
> 
> I agree.  IMHO anything with more than 1 developer should have a proper 
> bug tracking system.  It doesn't have to be anything fancy though.

what tool can we use? bugzilla?

-- 
Aequam memento rebus in arduis servare mentem...

Mauro Tortonesi			mauro@deepspace6.net
				mauro@ferrara.linux.it
Deep Space 6 - IPv6 on Linux	http://www.deepspace6.net
Ferrara Linux Users Group	http://www.ferrara.linux.it

From pioppo@ferrara.linux.it  Wed Dec 11 20:46:47 2002
Return-Path: <pioppo@ferrara.linux.it>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from flug.ferrara.linux.it (flug.4net.it [194.243.234.21])
	by liston.ferrara.linux.it (Postfix) with ESMTP
	id 32CA21F7046; Wed, 11 Dec 2002 20:46:47 +0100 (CET)
Received: from abulafia.casa (fe-d-28.4net.it [194.243.234.58])
	by flug.ferrara.linux.it (Postfix) with ESMTP
	id 6F6E73805B; Wed, 11 Dec 2002 20:46:46 +0100 (CET)
Date: Wed, 11 Dec 2002 20:46:33 +0100
From: Simone Piunno <pioppo@ferrara.linux.it>
To: Mauro Tortonesi <mauro@deepspace6.net>
Subject: Re: [ds6-backend] Re: [ds6-devel] bug report tracking tool
Message-ID: <20021211194632.GD2259@ferrara.linux.it>
References: <ABE9D492-0CEA-11D7-B170-003065F97418@leishman.org>
	<Pine.LNX.4.44.0212111308490.11270-100000@trantor.ferrara.linux.it>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <Pine.LNX.4.44.0212111308490.11270-100000@trantor.ferrara.linux.it>
User-Agent: Mutt/1.3.28i
Sender: <pioppo@ferrara.linux.it>
Errors-To: <pioppo@ferrara.linux.it>
Organization: Ferrara LUG
X-Operating-System: Linux 2.4.19+i2c_sensors
X-Message: GnuPG/PGP5 are welcome
X-Key-ID: 860314FC/C09E842C
X-Key-FP: 9C15F0D3E3093593AC952C92A0CD52B4860314FC
X-Key-URL: http://members.ferrara.linux.it/pioppo/mykey.asc
cc: ds6-devel@deepspace6.net
cc: ds6-backend@deepspace6.net
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Wed, 11 Dec 2002 19:46:47 -0000

On Wed, Dec 11, 2002 at 01:09:31PM +0100, Mauro Tortonesi wrote:

> > > should we set up a bug report tracking tool for our software projects?
> > 
> > I agree.  IMHO anything with more than 1 developer should have a proper 
> > bug tracking system.  It doesn't have to be anything fancy though.
> 
> what tool can we use? bugzilla?

bugzilla is nice: we use it at work, even for small teams (3-5 
developers) but it's too big (tailored for a project the size of 
mozilla) and difficult to install (many perl dependecies).
I'd consider smaller alternatives if you know one.

Please, don't say gnats :)

-- 
Adde parvum parvo magnus acervus erit.
Simone Piunno, FerraraLUG - http://members.ferrara.linux.it/pioppo
From chris@deepspace6.net  Tue Dec 10 01:34:15 2002
Return-Path: <chris@deepspace6.net>
Delivered-To: ds6-devel@liston.ferrara.linux.it
Received: from deepspace6.net (localhost.localdomain [127.0.0.1])
	by liston.ferrara.linux.it (Postfix) with SMTP id 0822F1F7049
	for <ds6-devel@deepspace6.net>; Tue, 10 Dec 2002 01:34:12 +0100 (CET)
From: chris@deepspace6.net
To: ds6-devel@deepspace6.net
User-Agent: cvsmail v0.9
Message-Id: <20021210003412.0822F1F7049@liston.ferrara.linux.it>
Date: Tue, 10 Dec 2002 01:34:12 +0100 (CET)
X-Mailman-Approved-At: Thu, 12 Dec 2002 00:11:18 +0100
Subject: [ds6-devel] nc6/src connection.c,NONE,1.1.2.1
	connection.h,NONE,1.1.2.1
	io_stream.c,NONE,1.1.2.1 io_stream.h,NONE,1.1.2.1
	Makefile.am,1.4,1.4.2.1 circ_buf.c,1.5,1.5.2.1
	circ_buf.h,1.6,1.6.2.1 filter.c,1.5,1.5.2.1 filter.h,1.4,1.4.2.1
	main.c,1.3,1.3.2.1 misc.c,1.4,1.4.2.1 misc.h,1.5,1.5.2.1
	network.c,1.5,1.5.2.1 network.h,1.3,1.3.2.1 parser.c,1.6,1.6.2.1
	parser.h,1.4,1.4.2.1 readwrite.c,1.9,1.9.2.1
	readwrite.h,1.5,1.5.2.1 timeout.c,1.1,NONE timeout.h,1.1,NONE
X-BeenThere: ds6-devel@deepspace6.net
X-Mailman-Version: 2.1b5+
Precedence: list
List-Id: DeepSpace6 mailing list for developers <ds6-devel.deepspace6.net>
List-Unsubscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=unsubscribe>
List-Archive: <http://lists.deepspace6.net/pipermail/ds6-devel>
List-Post: <mailto:ds6-devel@deepspace6.net>
List-Help: <mailto:ds6-devel-request@deepspace6.net?subject=help>
List-Subscribe: <http://lists.deepspace6.net/listinfo/ds6-devel>,
	<mailto:ds6-devel-request@deepspace6.net?subject=subscribe>
X-List-Received-Date: Tue, 10 Dec 2002 00:34:15 -0000

Update of /cvs/nc6/src

Modified Files:
      Tag: chris_refactor_101202
	Makefile.am circ_buf.c circ_buf.h filter.c filter.h main.c 
	misc.c misc.h network.c network.h parser.c parser.h 
	readwrite.c readwrite.h 
Added Files:
      Tag: chris_refactor_101202
	connection.c connection.h io_stream.c io_stream.h 
Removed Files:
      Tag: chris_refactor_101202
	timeout.c timeout.h 
Log Message:
- Reorganised execution flow so that each stage of processing (parsing args, opening connections, readwrite loop) are separate and called from main, rather than being called depth wise (parser->connect->readwrite).  This makes the code easier to follow and allows us some flexibility for doing things like INET modes, etc.

- Moved io_stream code into it's own header/source and added additional "methods" to act upon the stream.

- Moved connection_attributes into it's own header/source and added the remote&local addresses and streams to it.  This allows the parser stage to configure everything and then return it to main.

- Removed the timeout header/source and instead added a "hold_time" to the io_stream.
This makes the function of the timer very clear and allows for better control of timers.  It also significantly simplifies the exit conditions in the read/write loop.  The updated io_stream interface supplies a method to retrieve the time until the next timeout, allowing the readwrite loop to accurately trigger timeouts without the need to poll.  It also allows for the addition of other timeouts, such as an idle timeout, trivially.

The simplification of the read/write loop exit conditions also allows for socket "shutdowns" to be correctly handled (as per what I originally wanted from netcat way back when) simply by supplying "infinite" hold times.

- Renamed "port" in struct address_t to "service" to better reflect it's usage.

- Reorganised include order for consistency across project files.

- Various other cleanups.


--- NEW FILE: connection.c ---
/*
 *  connection.h - connection description structures and functions - header
 * 
 *  nc6 - an advanced netcat clone
 *  Copyright (C) 2001-2002 Mauro Tortonesi <mauro _at_ ferrara.linux.it>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */  
#include "config.h"
#include "misc.h"
#include "connection.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <assert.h>


void connection_attributes_init(connection_attributes *attrs)
{
	assert(attrs);

	memset((void*)attrs, 0, sizeof(connection_attributes));
	io_stream_init(&(attrs->remote_stream));
	io_stream_init(&(attrs->local_stream));

	/* the local stream has an infinite hold timeout by default */
	ios_set_hold_timeout(&(attrs->local_stream), -1);
}



void connection_attributes_destroy(connection_attributes *attrs)
{
	assert(attrs);

	io_stream_destroy(&(attrs->remote_stream));
	io_stream_destroy(&(attrs->local_stream));
}



void connection_attributes_to_addrinfo(struct addrinfo *ainfo,
		const connection_attributes *attrs)
{
	assert(ainfo);
	assert(attrs);

	switch (attrs->proto) {
		case PROTO_IPv6:
			ainfo->ai_family = AF_INET6;
			break;
		case PROTO_IPv4:
			ainfo->ai_family = AF_INET;
			break;
		case PROTO_UNSPECIFIED:
			ainfo->ai_family = AF_UNSPEC;
			break;
		default:
			fatal("internal error: unknown socket domain");
	}
	
	switch (attrs->type) {
		case UDP_SOCKET:
			ainfo->ai_socktype = SOCK_DGRAM;
			break;
		case TCP_SOCKET:
			ainfo->ai_socktype = SOCK_STREAM;
			break;
		default:
			fatal("internal error: unknown socket type");
	}
}
--- NEW FILE: connection.h ---
/*
 *  connection.h - connection description structures and functions - header
 * 
 *  nc6 - an advanced netcat clone
 *  Copyright (C) 2001-2002 Mauro Tortonesi <mauro _at_ ferrara.linux.it>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */  
#ifndef CONNECTION_H
#define CONNECTION_H

#include "io_stream.h"
#include <netdb.h>

typedef enum sock_type_t {
	UDP_SOCKET,
	TCP_SOCKET
} sock_type;

typedef enum sock_protocol_t {
	PROTO_IPv6,
	PROTO_IPv4,
	PROTO_UNSPECIFIED
} sock_proto;

typedef struct address_t
{
	char *address;
	char *service;
} address;

typedef struct connection_attributes_t
{
	sock_proto proto;
	sock_type  type;
	address remote_address;
	address local_address;
	io_stream remote_stream;
	io_stream local_stream;
} connection_attributes;


void connection_attributes_init(connection_attributes *attrs);
void connection_attributes_destroy(connection_attributes *attrs);

void connection_attributes_to_addrinfo(struct addrinfo *ainfo,
		const connection_attributes *attrs);

#endif /* CONNECTION_H */
--- NEW FILE: io_stream.c ---
/*
 *  io_stream.c - stream i/o wrapper - implementation 
 * 
 *  nc6 - an advanced netcat clone
 *  Copyright (C) 2001-2002 Mauro Tortonesi <mauro _at_ ferrara.linux.it>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */  
#include "config.h"
#include "io_stream.h"
#include "misc.h"
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <fcntl.h>


/* static void nonblock(int fd); */


void io_stream_init(io_stream *ios)
{
	assert(ios);

	ios->fd_in = -1;
	ios->fd_out = -1;
	ios->socktype = 0; /* unknown */
	ios->hold_time = 0; /* instant */
	timerclear(&(ios->read_closed));
}



void io_stream_destroy(io_stream *ios)
{
	assert(ios);
	ios_shutdown(ios, SHUT_RDWR);
}



void ios_assign_socket(io_stream *ios, int fd, int socktype)
{
	assert(ios);
	assert(fd >= 0);

	/* nonblock(fd); */
	ios->fd_in  = fd;
	ios->fd_out = fd;
	ios->socktype = socktype;
}



void ios_assign_stdio(io_stream *ios)
{
	assert(ios);

	if ((ios->fd_in  = dup(STDIN_FILENO)) < 0) 
		fatal("error in duplicating stdin file descriptor: %s", 
		      strerror(errno));
	
	if ((ios->fd_out = dup(STDOUT_FILENO)) < 0) 
		fatal("error in duplicating stdout file descriptor: %s", 
		      strerror(errno));

	/* nonblock(ios->fd_in); */
	/* nonblock(ios->fd_out); */

	ios->socktype = SOCK_STREAM;   /* pretend stdio is a stream socket */
}



void ios_shutdown(io_stream* ios, int how)
{
	assert(ios);

	if (how == SHUT_RDWR) {
		/* close both the input and the output */
		if (ios->fd_in != -1)
		{
			close(ios->fd_in);
			/* record the read shutdown time */
			gettimeofday(&(ios->read_closed), NULL);
		}
		/* if the same fd is input and output, don't close twice */
		if (ios->fd_out != -1 && ios->fd_out != ios->fd_in)
			close(ios->fd_out);
		ios->fd_in = ios->fd_out = -1;
	} else if (how == SHUT_RD) {
		/* close the input */
		if (ios->fd_in != -1) {
			/* if the fd is duplex, use shutdown */
			if (ios->fd_in == ios->fd_out)
				shutdown(ios->fd_in, SHUT_RD);
			else
				close(ios->fd_in);
			ios->fd_in = -1;
			/* record the read shutdown time */
			gettimeofday(&(ios->read_closed), NULL);
		}
	} else {
		assert(how == SHUT_WR);		
		/* close the output */
		if (ios->fd_out != -1) {
			/* if the fd is duplex, use shutdown */
			if (ios->fd_in == ios->fd_out)
				shutdown(ios->fd_out, SHUT_WR);
			else
				close(ios->fd_out);
			ios->fd_out = -1;
		}
	}
}



struct timeval* ios_next_timeout(io_stream *ios, struct timeval *tv)
{
	struct timeval now;

	assert(ios);
	assert(tv);

	/* no timeout if read is still open or hold time is infinite */
	if (is_read_open(ios) || ios->hold_time < 0)
		return NULL;

	if (ios->hold_time == 0) {
		/* instant timeout */
		timerclear(tv);
		return tv;
	}

	/* calculate the offset from now until the hold_time expiry */
	gettimeofday(&now, NULL);
	now.tv_sec -= ios->hold_time;
	timersub(&(ios->read_closed), &now, tv);

	if (tv->tv_sec < 0) {
		/* timeout has expired */
		timerclear(tv);
	}

	return tv;
}



/*
static void nonblock(int fd)
{
	int arg;
	if ((arg = fcntl(fd, F_GETFL, 0)) < 0)
		fatal("error reading file descriptor flags: %s", strerror(errno));

	arg |= O_NONBLOCK;

	if (fcntl(fd, F_SETFL, arg) < 0)
		fatal("error setting flag O_NONBLOCK on file descriptor",
			strerror(errno));
}
*/
--- NEW FILE: io_stream.h ---
/*
 *  io_stream.h - stream i/o wrapper - header
 * 
 *  nc6 - an advanced netcat clone
 *  Copyright (C) 2001-2002 Mauro Tortonesi <mauro _at_ ferrara.linux.it>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */  
#ifndef IO_STREAM_H
#define IO_STREAM_H

#include "misc.h"
#include "circ_buf.h"
#include <sys/time.h>

typedef struct io_stream_t
{
	int fd_in;       /* for reading */
	int fd_out;      /* for writing */
	int socktype;    /* the type of the socket */
	int hold_time;   /* time to hold the stream open after read closes,
	                    -1 means hold indefinately */
	struct timeval read_closed; /* the time that the read was closed */
} io_stream;

void io_stream_init(io_stream *ios);
void io_stream_destroy(io_stream *ios);

#define ios_readfd(IOS)   ((IOS)->fd_in)
#define ios_writefd(IOS)  ((IOS)->fd_out)

void ios_assign_socket(io_stream *ios, int fd, int socktype);
void ios_assign_stdio(io_stream *ios);
void ios_shutdown(io_stream *ios, int how);

#define is_read_open(IOS)   ((IOS)->fd_in >= 0)
#define is_write_open(IOS)  ((IOS)->fd_out >= 0)

/* sets the time (in sec) after read is shutdown that timeout occurs */
#define ios_set_hold_timeout(IOS, T)  ((IOS)->hold_time = (T))

/* Writes the interval to the next timeout into tv and returns a pointer
 * to tv.  If no timeout is active, NULL is returned and tv is unchanged. */
struct timeval* ios_next_timeout(io_stream *ios, struct timeval *tv);

#endif /* IO_STREAM_H */
Index: Makefile.am
===================================================================
RCS file: /cvs/nc6/src/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -d -r1.4 -r1.4.2.1
--- Makefile.am	28 Nov 2002 20:24:48 -0000	1.4
+++ Makefile.am	10 Dec 2002 00:34:09 -0000	1.4.2.1
@@ -1,3 +1,21 @@
 bin_PROGRAMS = nc6
-noinst_HEADERS = circ_buf.h filter.h misc.h network.h parser.h readwrite.h timeout.h 
-nc6_SOURCES = circ_buf.c filter.c main.c misc.c network.c parser.c readwrite.c timeout.c 
+noinst_HEADERS = \
+  circ_buf.h \
+  filter.h \
+  misc.h \
+  network.h \
+  parser.h \
+  readwrite.h \
+  io_stream.h \
+  connection.h
+
+nc6_SOURCES = \
+  circ_buf.c \
+  filter.c \
+  main.c \
+  misc.c \
+  network.c \
+  parser.c \
+  readwrite.c \
+  io_stream.c \
+  connection.c
Index: circ_buf.c
===================================================================
RCS file: /cvs/nc6/src/circ_buf.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -d -r1.5 -r1.5.2.1
--- circ_buf.c	9 Dec 2002 22:16:39 -0000	1.5
+++ circ_buf.c	10 Dec 2002 00:34:09 -0000	1.5.2.1
@@ -18,15 +18,15 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */  
+#include "config.h"
+#include "circ_buf.h"
+#include "misc.h"
 #include <assert.h>
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/socket.h>
 #include <sys/uio.h>
-#include "circ_buf.h"
-#include "misc.h"
 
 
 
Index: circ_buf.h
===================================================================
RCS file: /cvs/nc6/src/circ_buf.h,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -d -r1.6 -r1.6.2.1
--- circ_buf.h	9 Dec 2002 22:16:39 -0000	1.6
+++ circ_buf.h	10 Dec 2002 00:34:09 -0000	1.6.2.1
@@ -22,10 +22,12 @@
 #define CIRC_BUF_H
 
 #include "config.h"
+#include "misc.h"
+#include <sys/types.h>
+#include <sys/socket.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #endif
-#include "misc.h"
 
 typedef struct circ_buf_t {
 	uint8_t *buf;  /* pointer to the buffer */
Index: filter.c
===================================================================
RCS file: /cvs/nc6/src/filter.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -d -r1.5 -r1.5.2.1
--- filter.c	28 Nov 2002 20:24:48 -0000	1.5
+++ filter.c	10 Dec 2002 00:34:09 -0000	1.5.2.1
@@ -18,6 +18,11 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */  
+#include "config.h"
+#include "filter.h"
+#include "misc.h"
+#include "network.h"
+#include "parser.h"
 #include <assert.h>
 #include <netdb.h>
 #include <stdlib.h>
@@ -25,11 +30,6 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
-#include "config.h"
-#include "filter.h"
-#include "misc.h"
-#include "network.h"
-#include "parser.h"
 
 
 /* compare two sockaddr structs to see if they represent the same address */
@@ -143,14 +143,14 @@
 	assert(sa != NULL);
 	assert(addr != NULL);	
 	assert(addr->address == NULL || strlen(addr->address) > 0);
-	assert(addr->port    == NULL || strlen(addr->port) > 0);
+	assert(addr->service == NULL || strlen(addr->service) > 0);
 		
-	if (addr->address == NULL && addr->port == NULL) return TRUE;
+	if (addr->address == NULL && addr->service == NULL) return TRUE;
 		
-	/* if the address is unspecified and the port is allowed, 
+	/* if the address is unspecified and the service is allowed, 
 	 * then return TRUE */
 	if ((addr->address == NULL) && 
-	    ((safe_atoi(addr->port) == ntohs(get_port(sa))))) 
+	    ((safe_atoi(addr->service) == ntohs(get_port(sa))))) 
 		return TRUE;
 	
 	ret = FALSE;
@@ -182,7 +182,7 @@
 			fatal("internal error: unknown socket type");
 	}
 	
-	err = getaddrinfo(addr->address, addr->port, &hints, &res);
+	err = getaddrinfo(addr->address, addr->service, &hints, &res);
 	if (err != 0) fatal("getaddrinfo error: %s", gai_strerror(err));
 
 	for (ptr = res; ptr != NULL; ptr = ptr->ai_next) {
@@ -192,8 +192,8 @@
 			continue;
 		}
 		if ((are_address_equal(sa, ptr->ai_addr) == TRUE) &&
-		    (addr->port == NULL || 
-		     (safe_atoi(addr->port) == ntohs(get_port(sa))))) {
+		    (addr->service == NULL || 
+		     (safe_atoi(addr->service) == ntohs(get_port(sa))))) {
 			ret = TRUE;
 			break;
 		}
Index: filter.h
===================================================================
RCS file: /cvs/nc6/src/filter.h,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -d -r1.4 -r1.4.2.1
--- filter.h	28 Nov 2002 20:24:48 -0000	1.4
+++ filter.h	10 Dec 2002 00:34:09 -0000	1.4.2.1
@@ -21,11 +21,10 @@
 #ifndef FILTER_H
 #define FILTER_H
 
+#include "misc.h"
+#include "connection.h"
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <netdb.h>
-#include "misc.h"
-#include "network.h"
 
 bool is_allowed(const struct sockaddr *sa, const address *addr,
 		const connection_attributes* attrs);
Index: main.c
===================================================================
RCS file: /cvs/nc6/src/main.c,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -d -r1.3 -r1.3.2.1
--- main.c	28 Nov 2002 20:24:48 -0000	1.3
+++ main.c	10 Dec 2002 00:34:09 -0000	1.3.2.1
@@ -18,10 +18,13 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */  
-
+#include "config.h"
+#include "parser.h"
+#include "network.h"
+#include "readwrite.h"
 #include <signal.h>
 #include <string.h>
-#include "parser.h"
+#include <stdlib.h>
 
 /* program name */
 static char *program_name  = NULL;
@@ -29,7 +32,12 @@
 
 int main(int argc, char **argv)
 {
+	connection_attributes connection_attrs;
+	int mode;
 	char *ptr;
+	int retval;
+
+	connection_attributes_init(&connection_attrs);
 
 	/* save the program name in a static variable */
 	if ((ptr = strrchr(argv[0], '/')) != NULL) {
@@ -41,10 +49,30 @@
 	/* SIGPIPE and SIGURG must be ignored */
 	signal(SIGURG, SIG_IGN);
 	signal(SIGPIPE, SIG_IGN);
-	
-	parse_arguments(argc,argv);
 
-	return 0;
+	/* set flags and fill out the addresses and connection attributes */
+	mode = parse_arguments(argc, argv, &connection_attrs);
+
+	/* establish a connection */
+	switch (mode) {
+	case LISTEN_MODE:
+		do_listen(&connection_attrs);
+		break;
+	case CONNECT_MODE:
+		do_connect(&connection_attrs);
+		break;
+	default:
+		fatal("internal error: unknown connection mode");
+		break;
+	}
+
+	/* run the main read/write loop */
+	retval = readwrite(&(connection_attrs.remote_stream),
+	          &(connection_attrs.local_stream));
+
+	connection_attributes_destroy(&connection_attrs);
+
+	return (retval)? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 
@@ -53,6 +81,3 @@
 {
 	return program_name;
 }
-
-
-
Index: misc.c
===================================================================
RCS file: /cvs/nc6/src/misc.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -d -r1.4 -r1.4.2.1
--- misc.c	6 Oct 2002 16:21:23 -0000	1.4
+++ misc.c	10 Dec 2002 00:34:09 -0000	1.4.2.1
@@ -18,12 +18,13 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */  
+#include "config.h"
+#include "misc.h"
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
-#include "config.h"
-#include "misc.h"
+#include <string.h>
 #ifdef HAVE_STRTOL
 #include <errno.h>
 #include <limits.h>
@@ -76,6 +77,15 @@
 	if (value == NULL) fatal("virtual memory exhausted");
 
 	return value;
+}
+
+
+
+char *xstrdup(const char *str)
+{
+	register char *nstr = (char*)xmalloc(strlen(str));
+	strcpy(nstr, str);
+	return nstr;
 }
 
 
Index: misc.h
===================================================================
RCS file: /cvs/nc6/src/misc.h,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -d -r1.5 -r1.5.2.1
--- misc.h	28 Nov 2002 20:24:48 -0000	1.5
+++ misc.h	10 Dec 2002 00:34:09 -0000	1.5.2.1
@@ -39,6 +39,7 @@
 void fatal(const char *template, ...);
 void warn(const char *template, ...);
 uint8_t *xmalloc(size_t size);
+char *xstrdup(const char* str);
 
 #ifdef HAVE_STRTOL
 int safe_atoi(const char *str);
Index: network.c
===================================================================
RCS file: /cvs/nc6/src/network.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -d -r1.5 -r1.5.2.1
--- network.c	9 Dec 2002 22:03:06 -0000	1.5
+++ network.c	10 Dec 2002 00:34:10 -0000	1.5.2.1
@@ -18,6 +18,10 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */  
+#include "config.h"
+#include "network.h"
+#include "parser.h"
+#include "filter.h"
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <errno.h>
@@ -25,10 +29,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <assert.h>
-#include "network.h"
-#include "parser.h"
-#include "filter.h"
-#include "readwrite.h"
 
 /* buffer size for warning messages */
 static const size_t WARN_MESSAGE_SIZE = 512;
@@ -72,41 +72,9 @@
 
 
 
-void connection_attributes_to_addrinfo(struct addrinfo *ainfo,
-		const connection_attributes *attrs)
-{
-	switch (attrs->proto) {
-		case PROTO_IPv6:
-			ainfo->ai_family = AF_INET6;
-			break;
-		case PROTO_IPv4:
-			ainfo->ai_family = AF_INET;
-			break;
-		case PROTO_UNSPECIFIED:
-			ainfo->ai_family = AF_UNSPEC;
-			break;
-		default:
-			fatal("internal error: unknown socket domain");
-	}
-	
-	switch (attrs->type) {
-		case UDP_SOCKET:
-			ainfo->ai_socktype = SOCK_DGRAM;
-			break;
-		case TCP_SOCKET:
-			ainfo->ai_socktype = SOCK_STREAM;
-			break;
-		default:
-			fatal("internal error: unknown socket type");
-	}
-}
-
-
-
-void do_connect(const address *remote, const address *local,
-		const connection_attributes *attrs)
+void do_connect(connection_attributes *attrs)
 {
-	io_stream remote_stream, local_stream;
+	address *remote, *local;
 	int err, fd = -1;
 	struct addrinfo hints, *res = NULL, *ptr;
 	bool connect_attempted = FALSE;
@@ -115,14 +83,16 @@
 	char sbuf_rev[NI_MAXSERV + 1];
 	char sbuf_num[NI_MAXSERV + 1];
 
-	/* make sure that all the preconditions are respected */
-	assert(remote != NULL);
-	assert(remote->address != NULL);
-	assert(remote->port != NULL);
-	assert(local == NULL ||
-	    ((local->address == NULL || strlen(local->address) > 0) &&
-	     (local->port    == NULL || strlen(local->port)    > 0)));
 	assert(attrs != NULL);
+
+	remote = &(attrs->remote_address);
+	local = &(attrs->local_address);
+
+	/* make sure all the preconditions are respected */
+	assert(remote->address != NULL && strlen(remote->address) > 0);
+	assert(remote->service != NULL && strlen(remote->service) > 0);
+	assert(local->address == NULL || strlen(local->address) > 0);
+	assert(local->service == NULL || strlen(local->service) > 0);
 	
 	/* setup hints structure to be passed to getaddrinfo */
 	memset(&hints, 0, sizeof(hints));
@@ -136,7 +106,7 @@
 		hints.ai_flags |= AI_NUMERICHOST;
 
 	/* get the address of the remote end of the connection */
-	err = getaddrinfo(remote->address, remote->port, &hints, &res);
+	err = getaddrinfo(remote->address, remote->service, &hints, &res);
 	if (err != 0)
 		fatal("forward host lookup failed for remote enpoint %s: %s",
 		      remote->address, gai_strerror(err));
@@ -172,7 +142,7 @@
 					hbuf_rev, sizeof(hbuf_rev), sbuf