Previous section.

Technical Standard: Networking Services (XNS), Issue 5.2 Draft 2.0
Copyright © 1999 The Open Group

NAME

netinet/in.h - Internet Protocol family - IP version 6 additions

NOTE

Use of Sockets over Internet Protocols based on IPv4 (Use of Sockets over Internet Protocols based on IPv4) contains the basic definition of this interface. The following additional information pertains to IPv6.

DESCRIPTION

The <netinet/in.h> header defines the in6_addr structure that contains member s6_addr[16], a 16-element array of uint8_t. This array is used to contain a 128-bit IPv6 address, stored in network byte order.

The <netinet/in.h> header defines the sockaddr_in6 structure that includes at least the following members:

member type value
sin6_family sa_family_t AF_INET6
sin6_port in_port_t port number
sin6_flowinfo uint32_t IPv6 traffic class and flow information
sin6_addr struct in6_addr IPv6 address
uint32_t sin6_scope_id set of interfaces for a scope

The sockaddr_in6 structure should be set to zero by an application prior to using it, since implementations are free to have additional, implementation specific, fields in sockaddr_in6.

The sin6_scope_id field is a 32-bit integer that identifies a set of interfaces as appropriate for the scope of the address carried in the sin6_addr field. For a link scope sin6_addr, sin6_scope_id would be an interface index. For a site scope sin6_addr, sin6_scope_id would be a site identifier. The mapping of sin6_scope_id to an interface or set of interfaces is left to implementation and future specifications on the subject of site identifiers.

The <netinet/in.h> header declares the external variable in6addr_any of type struct in6_addr. This variable is initialised by the system to contain the wildcard IPv6 address. It also defines symbolic constant IN6ADDR_ANY_INIT which the application can use to initialize a variable of type struct in6_addr to the IPv6 wildcard address.

The <netinet/in.h> header declares the external variable in6addr_loopback of type struct in6_addr. This variable is initialised by the system to contain the loopback IPv6 address. It also defines symbolic constant IN6ADDR_LOOPBACK_INIT which the application can use to initialize a variable of type struct in6_addr to the IPv6 loopback address.

The <netinet/in.h> header defines integer symbolic constant IPPROTO_IPV6 to identify the IPV6 protocol level in getsockopt() and setsockopt() calls.

The <netinet/in.h> header defines the ipv6_mreq structure that includes at least the following members:

member type value
ipv6mr_multiaddr struct in6_addr IPv6 multicast address
ipv6mr_interface unsigned int interface index

The <netinet/in.h> header defines the following macro to help applications declare buffers of the proper size to store IPv6 addresses in string form:


INET6_ADDRSTRLEN 46

The <netinet/in.h> header defines the following macros, with distinct integral values, for use in the option_name argument in getsockopt() or setsockopt() calls at protocol level IPPROTO_IPV6:

IPV6_JOIN_GROUP
join a multicast group

IPV6_LEAVE_GROUP
quit a multicast group

IPV6_MULTICAST_HOPS
Multicast hop limit.

IPV6_MULTICAST_IF
Interface to use for outgoing multicast packets

IPV6_MULTICAST_LOOP
Multicast packets are delivered back to the local application

IPV6_UNICAST_HOPS
Unicast hop limit

The <netinet/in.h> header defines the following macros that test for special IPv6 addresses. Each macro is of type int and takes a single argument of type const struct in6_addr*.

Macro Description
IN6_IS_ADDR_UNSPECIFIED unspecified address
IN6_IS_ADDR_LOOPBACK loopback address
IN6_IS_ADDR_MULTICAST multicast address
IN6_IS_ADDR_LINKLOCAL unicast link-local address
IN6_IS_ADDR_SITELOCAL unicast site-local address
IN6_IS_ADDR_V4MAPPED IPv4 mapped address
IN6_IS_ADDR_V4COMPAT IPv4 compatible address
IN6_IS_ADDR_MC_NODELOCAL multicast node-local address
IN6_IS_ADDR_MC_LINKLOCAL multicast link-local address
IN6_IS_ADDR_MC_SITELOCAL multicast site-local address
IN6_IS_ADDR_MC_ORGLOCAL multicast organization-local address
IN6_IS_ADDR_MC_GLOBAL multicast global address

Note that IN6_IS_ADDR_LINKLOCAL and IN6_IS_ADDR_SITELOCAL return true only for the two local-use IPv6 unicast addresses. They do not return true for multicast addresses of either link-local or site-local scope.

SEE ALSO

getsockopt(), setsockopt(). <sys/socket.h>.

CHANGE HISTORY

First released in Issue 5.1.

Contents Next section Index