.\" Copyright, the authors of the Linux man-pages project .\" .\" SPDX-License-Identifier: Linux-man-pages-1-para .\" .TH ipv6 7 (date) "Linux man-pages (unreleased)" .SH NAME ipv6 \- Linux IPv6 protocol implementation .SH SYNOPSIS .nf .B #include .B #include .P .IB tcp6_socket " = socket(AF_INET6, SOCK_STREAM, 0);" .IB raw6_socket " = socket(AF_INET6, SOCK_RAW, " protocol ");" .IB udp6_socket " = socket(AF_INET6, SOCK_DGRAM, " protocol ");" .fi .SH 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 .BR socket (7). .P The IPv6 API aims to be mostly compatible with the IPv4 API (see .BR ip (7)). Only differences are described in this man page. .P To bind an .B AF_INET6 socket to any process, the local address should be copied from the .I in6addr_any variable which has .I in6_addr type. In static initializations, .B IN6ADDR_ANY_INIT may also be used, which expands to a constant expression. Both of them are in network byte order. .P The IPv6 loopback address (::1) is available in the global .I in6addr_loopback variable. For initializations, .B IN6ADDR_LOOPBACK_INIT should be used. .P 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. .P 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. .SS Address format .in +4n .EX struct sockaddr_in6 { sa_family_t sin6_family; /* AF_INET6 */ in_port_t sin6_port; /* port number */ uint32_t sin6_flowinfo; /* IPv6 flow information */ struct in6_addr sin6_addr; /* IPv6 address */ uint32_t sin6_scope_id; /* Scope ID (new in Linux 2.4) */ }; \& struct in6_addr { unsigned char s6_addr[16]; /* IPv6 address */ }; .EE .in .P .I sin6_family is always set to .BR AF_INET6 ; .I sin6_port is the protocol port (see .I sin_port in .BR ip (7)); .I sin6_flowinfo is the IPv6 flow identifier; .I sin6_addr is the 128-bit IPv6 address. .I 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 .I sin6_scope_id contains the interface index (see .BR netdevice (7)) .P 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. .P The address notation for IPv6 is a group of 8 4-digit hexadecimal numbers, separated with a \[aq]:\[aq]. \&"::" stands for a string of 0 bits. Special addresses are ::1 for loopback and ::FFFF: for IPv4-mapped-on-IPv6. .P The port space of IPv6 is shared with IPv4. .SS Socket options See .BR IPPROTO_IPV6 (2const). .SH ERRORS .TP .B ENODEV The user tried to .BR bind (2) to a link-local IPv6 address, but the .I sin6_scope_id in the supplied .I sockaddr_in6 structure is not a valid interface index. .SH VERSIONS Linux 2.4 will break binary compatibility for the .I sockaddr_in6 for 64-bit hosts by changing the alignment of .I in6_addr and adding an additional .I sin6_scope_id field. The kernel interfaces stay compatible, but a program including .I sockaddr_in6 or .I in6_addr into other structures may not be. This is not a problem for 32-bit hosts like i386. .P The .I 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. .SH NOTES The .I sockaddr_in6 structure is bigger than the generic .IR sockaddr . Programs that assume that all address types can be stored safely in a .I struct sockaddr need to be changed to use .I struct sockaddr_storage for that instead. .P .BR SOL_IP , .BR SOL_IPV6 , .BR SOL_ICMPV6 , and other .B SOL_* socket options are nonportable variants of .BR IPPROTO_* . See also .BR ip (7). .SH 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. .P IPSec support for EH and AH headers is missing. .P Flow label management is not complete and not documented here. .P This man page is not complete. .SH SEE ALSO .BR IPPROTO_IPV6 (2const), .BR ip (7) .P RFC\ 2553: IPv6 BASIC API; Linux tries to be compliant to this. RFC\ 2460: IPv6 specification.