ipv6 (7) - Linux Manuals
ipv6: Linux IPv6 protocol implementation
NAME
ipv6 - Linux IPv6 protocol implementation
SYNOPSIS
#include <sys/socket.h>#include <netinet/in.h>
tcp6_socket = socket(AF_INET6, SOCK_STREAM, 0);
raw6_socket = socket(AF_INET6, SOCK_RAW, protocol);
udp6_socket = socket(AF_INET6, SOCK_DGRAM, protocol);
DESCRIPTION
Linux 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 IPv4 API (see ip(7)). 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 byte 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 needs to support only this API type to support both protocols. This is handled transparently by the address handling functions in the C library.
IPv4 and IPv6 share the local port space. When you get an IPv4 connection or packet to an IPv6 socket, its source address will be mapped to v6 and it will be mapped to v6.
Address format
struct sockaddr_in6 {
struct in6_addr {
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 128-bit IPv6 address.
sin6_scope_id
is an ID depending on the scope of the address.
It is new in Linux 2.4.
Linux supports it only for link-local 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 an IPv4 host, and other reserved address types.
The address notation for IPv6 is a group of 8 4-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.
The port space of IPv6 is shared with IPv4.
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.
SOL_IP,
SOL_IPV6,
SOL_ICMPV6,
and other
SOL_*
socket options are nonportable variants of
IPPROTO_*.
See also
ip(7).
IPSec support for EH and AH headers is missing.
Flow label management is not complete and not documented here.
This man page is not complete.
RFC 2553: IPv6 BASIC API;
Linux tries to be compliant to this.
RFC 2460: IPv6 specification.
Socket options
IPv6 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.
ERRORS
VERSIONS
Linux 2.4 will break binary compatibility for the
sockaddr_in6
for 64-bit
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 32-bit hosts like i386.
NOTES
The
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.
BUGS
The IPv6 extended API as in RFC 2292 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.
COLOPHON
This page is part of release 5.10 of the Linux
man-pages
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
https://www.kernel.org/doc/man-pages/.
SEE ALSO
cmsg(3),
ip(7)