HP-UX Reference (11i v2 04/09) - 3 Library Functions A-M (vol 6)

i
inet6(3N) inet6(3N)
IPv6 addresses in string form, the following two constants are defined in
<netinet/in.h>
:
#define INET_ADDRSTRLEN 16
#define INET6_ADDRSTRLEN 46
The inet_ntop() function returns a pointer to the buffer containing the text string if the conversion
succeeds, and NULL otherwise. Upon failure, errno is set to [EAFNOSUPPORT] if the af argument is
invalid, or [ENOSPC] if the size of the result buffer is inadequate.
IPv6 Address Notation
The IPv6 address is
128
bytes long. Example of an IPv6 address is as shown below:
FEDC:BA98:7654:3210:FEDC:BA98:7654:3210
The 128 bits are written as eight 16-bit integers separated by colons. Each integer is represented by four
hexadecimal digits.
In the initial stages all the 128 bits will not be used, hence, it is very likely that there will be many zeros.
Hence the IP address in such a scenario will look like this:
1080:0:0:0:0:800:200C:417A
The above address can be represented in a compact fashion, by replacing a set of consecutive null 16-bit
numbers by two colons. The above address can now be re-written as follows:
1080::800:200C:417A
Expanding the abbreviation is very simple. Align whatever is at the left of the double colon to the left of
the address: these are the leading 16-bit words. Then align whatever is at the right of the colons to the
right of the address and fill up with zeros.
The double-colon convention can be used only once inside an address.
To support the transition from IPv4, two special IPv6 addresses are supported. They are
IPv4-
compatible addresses and IPv4-mapped addresses.
IPv4-Compatible Addresses Description and Example
IPv4-compatible addresses can be converted to and from the older IPv4 network address format. They are
used when IPv6 systems need to communicate with each other, but are separated by an IPv4 network.
IPv4-compatible addresses are formed by prepending 96 bits of zero, to a valid, 32-bit IPv4 address. For
example, the IPv4 address of
1.2.3.4
can be converted to the IPv6 address by first converting each decimal number separated by dots (".") to a
2-digit hexadecimal value, and concatenate into 4-digit hex values between colons (":") as listed below.
::0102:0304
In addition, leading zeros may be omitted for each hex number between the colons. Therefore, this may be
written as the following IPv6 address:
::102:304
We can retain the dot-decimal format and re-write the above address as
::1.2.3.4
The above address is also a valid IPv4-compatible IPv6 address.
IPv4-Mapped Addresses Description and Example
IPv4-mapped addresses indicate systems that do not support IPv6. They are limited to IPv4. An IPv6 host
can communicate with an IPv4-only host using the IPv4-mapped IPv6 address.
IPv4-mapped addresses are formed by prepending 80 bits of zero, and 16 bits of one’s, to a valid 32 bit
IPv4 address. An IPv4 address of
1.2.3.5
when mapped to IPv6, it becomes:
::FFFF:1.2.3.5
Section 3540 Hewlett-Packard Company 2 HP-UX 11i Version 2: September 2004