On 03/01/2012 16:52, Rick Macklem wrote:
> The basics are in RFC4291, but I think that inet_pton(3) knows how to
> deal with it. (I think "::" can be used once to specify the longest #
> of 16bit fields that are all zeros.)

RFC 4291 has a basic description of the textual representation of IPv6
addresses, but it is ambiguous: there are several different ways to
present the same address according to the RFC 4291 rules.

inet_pton(3) follows RFC 5952 which is a superset of the 4291 rules,
only allowing a single, unambiguous representation for each IPv6 number.

> After inet_pton() has translated it to a binary address, then the macros
> in sys/netinet6/in6.h can be used to determine if the address is a loopback, 
> etc.

While 5952 describes how to correctly present an IPv6 address, there's
still lots of important other stuff in 4291.  For instance bit 70 in an
IPv6 address flags that the address is derived from a number hardwired
into the interface -- typically the ethernet MAC address, as is commonly
done for SLAAC (StateLess Address Autoconfiguration: RFC 4862,
rtsold(8), rtadvd(8)). So an arbitrarily invented address should have
that bit set to zero.  Bit 71 is also special, indicating manycast vs
unicast, and should also be zero for the vast majority of uses.
See
http://www.infracaninophile.co.uk/articles/hotchpotch.html#rand-aaaa.pl
for some perl code that operates in this area.

Also of interest: RFC 5156 which lists IPv6 address ranges dedicated to
special purpose usages, and RFC 4193 which roughly is the IPv6
equivalent to RFC 1918, but somewhat more complicated.  You might find
https://www.sixxs.net/tools/grh/ula/ relevant too, although actually
using that as a registry is pretty pointless.

        Cheers,

        Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
JID: matt...@infracaninophile.co.uk               Kent, CT11 9PW

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to