develooper Front page | perl.perl5.porters | Postings from August 2001

Adding IPv6 to Perl

Thread Next
Jeff Okamoto
August 17, 2001 12:48
Adding IPv6 to Perl
Message ID:
This is a summary of what I think needs to be done with Perl to make it
IPv6 compatible.

1.  No changes to core of Perl.  The existing core networking functions
will not be changed, and thus will not be IPv6-compatible.

Reason:  Perl 6 will have to support IPv6 and it is moving lots of stuff
out of the core into modules.  The current networking functions will not
be in the core of Perl 6, so there is no reason to port them.

2.  Old IPv4 scripts will work without needing any changes.  Until, that
is, either the system they are running on or the version of Perl they
are using no longer supports IPv4.

Reason: Backward-compatibility.

3. Perl will remain IPv4 compatible as long as the underlying operating
system supports it.

Reason: Backward-compatibility.

4. The new Socket6 module will only include IPv6 routines.  The old Socket
module will be left alone.

Reason: Too many other modules inherit from IO::Socket.  The Principle of
Least Astonishment and the desire for backward-compatibility have precedence.

5. IO::Socket::INET will split into INET4 and INET6.  INET will create
delegations to either INET4 or INET6, on a "smart" basis with overrides
via the environment and/or a package local.  This will occur at DNS
lookup time in the case of a client program.  It could occur as early
as socket creation time, if the proper flags are passed or environment 
variables set.

Reason: Because most implementations of IPv6 will still allow IPv4
addresses to be used, we need to keep IPV4 support around.  This means
that IO::Socket::INET cannot contain both IPv4 and IPv6 functionality
due to function name collisions (such as socket).

Therefore IPv4 and IPv6 functions must live in separate package namespaces.
Now we must consider the point of view of a Perl user.  They have a script
that worked fine on IPv4, using IPv4 addresses.  If that script runs on a
system which also supports IPv6, which routines should be called: IPv4,
or IPv6 (in IPv4 compatibility mode)?  What if the script is running on an
IPv6-only node (which means it can still handle IPv4 addresses, but must
translate the address into IPv6)?

We should try to make this as "invisible" as possible.  In the above case,
if the node can handle IPv4, it should use them (unless overriden).  If the
node can't, then the IPv6 routines should be used (with possible warnings).

The return value of a DNS lookup is another factor.  Nameservers could
have both an IPv4 record (A) and an IPv6 record (A6 or AAAA).  In the
case of a nameserver holding both types, Perl should ask the nameserver
to return both records, then decide which record it should prefer.

Open, ongoing discussion issues:

String representation of an IPv6 address, and of an IPv4-encapsulated
address.  TMTOWTDI.

XSUB's (or whatever Perl 6 uses)

How Configure will tell if a system is IPv6-compatible

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About