[157640] in North American Network Operators' Group
Re: IPv6 Netowrk Device Numbering BP
daemon@ATHENA.MIT.EDU (Owen DeLong)
Thu Nov 1 10:13:11 2012
From: Owen DeLong <owen@delong.com>
In-Reply-To: <509273D5.3070503@foobar.org>
Date: Thu, 1 Nov 2012 07:07:35 -0700
To: Nick Hilliard <nick@foobar.org>
Cc: nanog@nanog.org
Errors-To: nanog-bounces+nanog.discuss=bloom-picayune.mit.edu@nanog.org
On Nov 1, 2012, at 06:06 , Nick Hilliard <nick@foobar.org> wrote:
> On 01/11/2012 12:20, Masataka Ohta wrote:
>> We should better introduce partially decimal format for
>> IPv6 addresses or, better, avoid IPv6 entirely.
>=20
> No we shouldn't. Text representations of IPv6 addresses are already a
> complete pain to parse. We don't need to add to this pain by adding a =
new
> format which gains us nothing in particular over existing schemas such =
as
> that suggested by Eugeniu.
>=20
> Nick
>=20
I agree with you that we shouldn't introduce partially decimal format, =
but I
don't see why you say IPv6 addresses are difficult to parse.
1. Tokenize (on : boundaries).
2. If n(tokens) < 8, expand null token to 9-n tokens.
(result 8 total tokens).
3. Parse tokens left to right as 16 bit hex numbers, such that =
accumulator a accumulates each token t
as follows:
a<<=3D16
a |=3D t
The only exceptions to this parsing would be if someone handed you a =
textual representation of
an IPv4 mapped address (::ffff:192.0.2.50), which essentially represents =
the partial decimal format
Masataka is requesting.
You really shouldn't need to parse these and it's perfectly valid to =
reject them as invalid input.
This really is an output only format to describe an IPv4 connection =
being mapped to an IPv6
socket with IPV6_V6ONLY=3Dfalse in the socket options. These addresses =
should never appear
on the wire. Internally, the software sees them as any other 128 bit =
integer and only the
UI presentation of these numbers for display should ever use that =
format.
That format is used as a convenience for user display because it allows =
the user to readily
identify the IPv4 address of the connection rather than having to =
convert the hex to decimal
to know what host is involved.
Finally, at this point, if you're feeling like you have to write your =
own IP address parser,
you're probably doing something wrong. PLEASE PLEASE PLEASE use the =
standard
libraries whenever possible. inet_pton, getaddrinfo, etc. if you are =
using C. In PERL,
you have these, plus Net::IP as well which provides extensive IP address =
parsing and
manipulation capabilities.
There are similar library functions for virtually every other language =
at this point as well.
Owen