-
Notifications
You must be signed in to change notification settings - Fork 106
Description
cork_ipv6_to_raw_string() is incomplete in its handling of IPv6 addresses that contain IPv4 addresses as their low order 32 bits. The RFCs that I have found address a total of 5 cases, the first 2 of which are covered by the existing code:
-
Prefix of
::/96IPv4-compatible (RFC 1933) -
Prefix of
::ffff:0:0/96IPv4-mapped (RFC 2765) -
Prefix of
::ffff:0:0:0/96IPv4-translated (RFC 2765) -
Prefix of
64:ff9b::\96IPv4-embeded (RFC 6052)
5: Automatic tunneling per RFC 5214. This starts with an arbitrary 64 bit routing prefix followed by:X:00:5efe:and the IPv4 address, where X has the hex representation ofa.
0indicating a local, individual IPv4 address
b.100indicating a local, group IPv4 address
c.200indicating a global, individual IPv4 address
d.300indicating a global, group IPv4 address
The code should be extended to cover the additional forms. It may be useful to make the presentation of the IPv4 address in dotted form optional given the advice of RFC 5952 which covers the representation of IPv6 addresses as text.
Addresses such as IPv4-Mapped IPv6 addresses, ISATAP [RFC5214], and
IPv4-translatable addresses [ADDR-FORMAT] have IPv4 addresses
embedded in the low-order 32 bits of the address. These addresses
have a special representation that may mix hexadecimal and dot
decimal notations. The decimal notation may be used only for the
last 32 bits of the address. For these addresses, mixed notation is
RECOMMENDED if the following condition is met: the address can be
distinguished as having IPv4 addresses embedded in the lower 32 bits
solely from the address field through the use of a well-known prefix.
Such prefixes are defined in [RFC4291] and [RFC2765] at the time of
this writing. If it is known by some external method that a given
prefix is used to embed IPv4, it MAY be represented as mixed
notation. Tools that provide options to specify prefixes that are
(or are not) to be represented as mixed notation may be useful.There is a trade-off here where a recommendation to achieve an exact
match in a search (no dot decimals whatsoever) and a recommendation
to help the readability of an address (dot decimal whenever possible)
does not result in the same solution. The above recommendation is
aimed at fixing the representation as much as possible while leaving
the opportunity for future well-known prefixes to be represented in a
human-friendly manner as tools adjust to newly assigned prefixes.