netinet/in.h - Internet Protocol family - IP version 6 additions
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.
<netinet/in.h>header defines the in6_addr structure that contains member s6_addr, a 16-element array of uint8_t. This array is used to contain a 128-bit IPv6 address, stored in network byte order.
<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.
<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.
<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.
<netinet/in.h>header defines integer symbolic constant IPPROTO_IPV6 to identify the IPV6 protocol level in getsockopt()and setsockopt()calls.
<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
<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
<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:
- join a multicast group
- quit a multicast group
- Multicast hop limit.
- Interface to use for outgoing multicast packets
- Multicast packets are delivered back to the local application
- Unicast hop limit
<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.
getsockopt(), setsockopt(). <sys/socket.h>.
First released in Issue 5.1.