IPV6Section: Linux Programmer's Manual (7)
Return to Main Contents
NAMEipv6, PF_INET6 - Linux IPv6 protocol implementation
DESCRIPTIONLinux 2.2 optionally implements the Internet Protocol, version 6. This man page contains a description of the IPv6 basic API as implemented by the Linux kernel and glibc 2.1. The interface is based on the BSD sockets interface; see socket(7).
The IPv6 API aims to be mostly compatible with the ip(7) v4 API. Only differences are described in this man page.
To bind an AF_INET6 socket to any process the local address should be copied from the in6addr_any variable which has in6_addr type. In static initializations IN6ADDR_ANY_INIT may also be used, which expands to a constant expression. Both of them are in network order.
The IPv6 loopback address (::1) is available in the global in6addr_loopback variable. For initializations IN6ADDR_LOOPBACK_INIT should be used.
IPv4 connections can be handled with the v6 API by using the v4-mapped-on-v6 address type; thus a program only needs only to support this API type to support both protocols. This is handled transparently by the address handling functions in libc.
sin6_family is always set to AF_INET6; sin6_port is the protocol port (see sin_port in ip(7)); sin6_flowinfo is the IPv6 flow identifier; sin6_addr is the 128bit IPv6 address. sin6_scope_id is an id of depending of on the scope of the address. It is new in Linux 2.4. Linux only supports it for link scope addresses, in that case sin6_scope_id contains the interface index (see netdevice(7))
IPv6 supports several address types: unicast to address a single host, multicast to address a group of hosts, anycast to address the nearest member of a group of hosts (not implemented in Linux), IPv4-on-IPv6 to address a IPv4 host, and other reserved address types.
The address notation for IPv6 is a group of 16 2 digit hexadecimal numbers, separated with a ':'. '::' stands for a string of 0 bits. Special addresses are ::1 for loopback and FFFF::<IPv4 address> for IPv4-mapped-on-IPv6.
SOCKET OPTIONSIPv6 supports some protocol specific socket options that can be set with setsockopt(2) and read with getsockopt(2). The socket option level for IPv6 is IPPROTO_IPV6. A boolean integer flag is zero when it is false, otherwise true.
VERSIONSThe older libinet6 libc5 based IPv6 API implementation for Linux is not described here and may vary in details.
Linux 2.4 will break binary compatibility for the sockaddr_in6 for 64bit hosts by changing the alignment of in6_addr and adding an additional sin6_scope_id field. The kernel interfaces stay compatible, but a program including sockaddr_in6 or in6_addr into other structures may not be. This is not a problem for 32bit hosts like i386.
The sin6_flowinfo field is new in Linux 2.4. It is transparently passed/read by the kernel when the passed address length contains it. Some programs that pass a longer address buffer and then check the outgoing address length may break.
PORTING NOTESThe sockaddr_in6 structure is bigger than the generic sockaddr. Programs that assume that all address types can be stored safely in a struct sockaddr need to be changed to use struct sockaddr_storage for that instead.
BUGSThe IPv6 extended API as in RFC2292 is currently only partly implemented; although the 2.2 kernel has near complete support for receiving options, the macros for generating IPv6 options are missing in glibc 2.1.
IPSec support for EH and AH headers is missing.
Flow label management is not complete and not documented here.
SEE ALSOip(7), cmsg(3)
RFC2553: IPv6 BASIC API. Linux tries to be compliant to this.
RFC2460: IPv6 specification.
This document was created by man2html, using the manual pages.
Time: 22:25:46 GMT, May 22, 2013