HPlogo HP-UX IPv6 Porting Guide: HP-UX 11i v2 September 2004 > Chapter 2 IPv6 Addressing

IPv6 Address Types

» 

Technical documentation

Complete book in PDF

 » Table of Contents

Unicast Address

Figure 2-3 Unicast Address

Unicast Address

Unicast addresses usually comprise a 64-bit prefix and a 64-bit interface ID.

Figure 2-4 Unicast Prefix

Unicast Prefix

The 64-bit interface ID must be unique on the link. An interface ID often includes the interface Link-Layer Address.

IPv6 Loopback Address

The loopback interface uses the IPv6 loopback address for self-testing, by sending IP datagrams to itself. The IPv6 loopback address is: 0:0:0:0:0:0:0:1 (or more simply, ::1).

Link-local Unicast Address

The LAN segment is the scope of a Link-local Address, and is used for address autoconfiguration and neighbor discovery.

Figure 2-5 Link-Local Unicast Address

Link-Local Unicast Address

Site-local Addresses

Use site-local addresses on networks not connecting to the Internet.

Figure 2-6 Site-local Unicast Address

Site-local Unicast Address

IPv6 Multicast Addresses

IPv6 multicast addresses resemble IPv4 multicast addresses, but have an explicit field for address-scope.

Figure 2-7 Multicast Address Format

Multicast Address Format

Some Well-know Multicast Addresses

FF02::1   All nodes (link-local)

FF02::2   All routers (link-local)

FF02::9   All Routing Information Protocol next generation (RIPng) routers (link-local)

IPv6 Wildcard Addresses

In IPv4, an application can let the system choose which source IP address to bind to a socket by specifying a wildcard address: the symbolic constant INADDR_ANY in the bind() function call. In IPv6, because the IPv6 address type is a structure (struct in6_addr), a symbolic constant can initialize an IPv6 address structure variable, but cannot assign an IPv6 structure variable. Therefore, an IPv6 wildcard address requires two forms:

  • For initialization, use the symbolic constant IN6ADDR_ANY_INIT of the type struct in6_addr. For example,
    struct in6_addr anyaddr = IN6ADDR_ANY_INIT;

NOTE: Only use the constant during initialization.
  • For assignment, use the global variable named in6addr_any, of the type in6_addr structure. For example:

Header file

<netinet/in.h>
extern const struct in6_addr in6addr_any;

struct sockaddr_in6 sin6;
...
sin6.sin6_addr = in6addr_any; /* structure assignment */
...
if (bind(s, (struct sockaddr *) &sin6, sizeof(sin6)) == -1)

IPv6 Loopback Addresses

The IPv4 loopback address is an integer type INADDR_LOOPBACK. The IPv6 loopback address is an in6_addr structure defined in <netinet/in.h>. For example:

Header file

<netinet/in.h>
sin6.sin6_addr = in6addr_loopback; /* structure assignment */

The symbolic constant named IN6ADDR_LOOPBACK_INIT is defined in <netinet/in.h>. Use it only when declaring a sockaddr_in6 struct. For example:

struct in6_addr loopbackaddr = IN6ADDR_LOOPBACK_INIT

NOTE: IPv4 defines INADDR_* constants in IPv4 host byte order. However, IPv6 defines IN6ADDR_* and in6addr* constants in network byte order.
© 2004 Hewlett-Packard Development Company, L.P.