What is ucspi-tcp and why does it need IPv6?

Please see http://cr.yp.to/ucspi-tcp.html for an explanation what ucspi-tcp is. Basically, many people use it to replace inetd. It consists of tcpserver and tcpclient. tcpserver can listen on sockets and start programs in an inetd like fashion except that information like the IP address and remote port are communicated via environment variables, so writing a server is very easy and the servers are also more portable since they don't have to use the socket API directly.

What does your diff do?

The current version adds simple IPv6 support for tcpserver and tcpclient.

Note that IPv6 has inherent IPv4 compatibility, so IPv4 connections are still possible without having to start a second tcpserver or something like that. But since some systems may have IPv6 support in their libc but not in the kernel, my tcpserver will always try to create an IPv6 listening socket but will fall back to transparent IPv4 support. Note that this is done by the socket wrappers, not explicitly by tcpserver, so to tcpserver the connections look like a normal IPv4 mapped IPv6 connection.

If a client connects via IPv4 (and you don't use the new -6 option), tcpserver will make the environment variables look just like the unpatched version. tcpclient also has a -6 option now with the same effect.

IPv6 connections use $PROTO=TCP6, so clients can use this to see how they should try to parse the IP numbers given in the environment, should they feel the need to do so.

There is a new -4 option to tcpclient. I updated the resolver so that you can request an IPv6 address for a machine that has only an A record. If the lookup for an AAAA record fails, dns_ip6 will do an A lookup and convert the address(es) to IP4-mapped IPv6 addresses. If you want tcpclient to connect to the IPv4 address even if there is an AAAA record, you can use the -4 option to tcpclient.

What does not work yet?

There are quite a few servers using tcpserver out there. If they try to parse the IP addresses, they are not IPv6 ready and need to be touched.

Where can I get the patch?

Simply download ucspi-tcp-0.88-ipv6.diff20.bz2 (GPG sig). Beware: unified diff format (you probably need GNU patch to apply it).

See Also

If you like this, you should probably also go to:

  1. x86-linux ucspi-tcp [gpg sig]. This is statically linked against dietlibc and has a resident size of 44k on my machine (compared to 476k for the shared glibc version).
  2. ucspi-ipc
  3. my libdjb project
  4. my daemontools patches
  5. my djbdns patches
  6. http://drt.ailis.de/, which has some cool clients for daemontools and ucspi-tcp.
  7. bzip2, the compressor I used to compress the diff.