Re: IPv6 and the "average user"

Pedro Roque (roque@di.fc.ul.pt)
Thu, 21 Nov 1996 14:14:07 GMT


>>>>> "Janos" == Janos Farkas <chexum@bankinf.banki.hu> writes:

Janos> On 20 Nov 1996, H. Peter Anvin wrote:
>> Quite true, but the IPv6 address space is expected to be
>> exhausted in 30 years. The switch from IPv4 to IPv6 is going
>> to be painful, but that is nothing compared to what switching
>> standard protocol stacks in the late 2020's would be like...!

Janos> Which brings up a question; could we make a framework,
Janos> which could allow changing protocols under applications,
Janos> without recompiling? I.e. currently to change an
Janos> application to support IPv6 we need to hack around, and
Janos> change socket(AF_INET,..) into a conditional
Janos> socket(AF_INET6,..) and changing the resolver calls to
Janos> something more modern, (and possibly this may care about
Janos> getting the address family for us too in the socket()
Janos> call). And to care about the "port" abstraction being the
Janos> same, or being accessible by getservby..(). And to hope
Janos> all the stream/dgram semantics are sufficiently close. Or
Janos> maybe the NRL getaddrinfo() is about to solve this? :)

Yes. getaddrinfo allows you to do just that.
Get the inet6-apps kit from ftp.inner.net (mirrored in some places including
ftp.ul.pt) and take a look at the aplications it includes.

This is a snip from telnetd

{
struct addrinfo req, *ai, *ai2;
char *service = (argc > 0) ? *(argv++) : "telnet";
char *host = (argc > 1) ? *argv : NULL;

int err;

[...]
memset(&req, 0, sizeof(struct addrinfo));
req.ai_flags |= AI_PASSIVE;
req.ai_socktype = SOCK_STREAM;

if (err = getaddrinfo(host, service, &req, &ai)) {
fprintf(stderr, "telnetd: %s.%s: %s\n", host, service,
nrl_gai_strerror(err));
}

for (ai2 = ai; ai2; ai2 = ai2->next) {
sk = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
err = bind(sk, ai->ai_addr, ai->ai_addrlen);
[...]
}
}

Note that there are no hard coded address or protocol families in the
application. To do a client connet to host X all you need to do
is modify the above example to not use AI_PASSIVE and pass the
apropriate hostname to getaddrinfo.

A similar getnameinfo exists to transform sockaddrs in printable hostname and
service names.

This way you can run an IPv6 capable aplication on your machine even without
AF_INET6 in kernel. If you then chose to add INET6 sockets all you need is to
restart the app (which usually comes free when you reboot for af_inet6
support). The same aproach can work for spx/ipx or whatever.

Now, all we need is to integrate getaddrinfo and friends in glibc and
of course to modify all our current apps... sigh.

regards,
./Pedro.