.\" This man page is Copyright (C) 2000 Andi Kleen <ak@muc.de>.
+.\"
+.\" %%%LICENSE_START(VERBATIM_ONE_PARA)
.\" Permission is granted to distribute possibly modified copies
.\" of this page provided the header is included verbatim,
.\" and in case of nontrivial modification author and date
.\" of the modification is added to the header.
+.\" %%%LICENSE_END
+.\"
.\" $Id: ipv6.7,v 1.3 2000/12/20 18:10:31 ak Exp $
-.TH IPV6 7 2012-11-07 "Linux" "Linux Programmer's Manual"
+.\"
+.\" The following socket options are undocumented
+.\" All of the following are from:
+.\" commit 333fad5364d6b457c8d837f7d05802d2aaf8a961
+.\" Author: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
+.\" Support several new sockopt / ancillary data in Advanced API (RFC3542).
+.\" IPV6_2292PKTINFO (2.6.14)
+.\" Formerly IPV6_PKTINFO
+.\" IPV6_2292HOPOPTS (2.6.14)
+.\" Formerly IPV6_HOPOPTS, which is documented
+.\" IPV6_2292DSTOPTS (2.6.14)
+.\" Formerly IPV6_DSTOPTS, which is documented
+.\" IPV6_2292RTHDR (2.6.14)
+.\" Formerly IPV6_RTHDR, which is documented
+.\" IPV6_2292PKTOPTIONS (2.6.14)
+.\" Formerly IPV6_PKTOPTIONS
+.\" IPV6_2292HOPLIMIT (2.6.14)
+.\" Formerly IPV6_HOPLIMIT, which is documented
+.\"
+.\" IPV6_RECVHOPLIMIT (2.6.14)
+.\" IPV6_RECVHOPOPTS (2.6.14)
+.\" IPV6_RTHDRDSTOPTS (2.6.14)
+.\" IPV6_RECVRTHDR (2.6.14)
+.\" IPV6_RECVDSTOPTS (2.6.14)
+.\"
+.\" IPV6_RECVPATHMTU (2.6.35, flag value added in 2.6.14)
+.\" commit 793b14731686595a741d9f47726ad8b9a235385a
+.\" Author: Brian Haley <brian.haley@hp.com>
+.\" IPV6_PATHMTU (2.6.35, flag value added in 2.6.14)
+.\" commit 793b14731686595a741d9f47726ad8b9a235385a
+.\" Author: Brian Haley <brian.haley@hp.com>
+.\" IPV6_DONTFRAG (2.6.35, flag value added in 2.6.14)
+.\" commit 793b14731686595a741d9f47726ad8b9a235385a
+.\" Author: Brian Haley <brian.haley@hp.com>
+.\" commit 4b340ae20d0e2366792abe70f46629e576adaf5e
+.\" Author: Brian Haley <brian.haley@hp.com>
+.\"
+.\" IPV6_RECVTCLASS (2.6.14)
+.\" commit 41a1f8ea4fbfcdc4232f023732584aae2220de31
+.\" Author: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
+.\" Based on patch from David L Stevens <dlstevens@us.ibm.com>
+.\"
+.\" IPV6_CHECKSUM (2.2)
+.\" IPV6_NEXTHOP (2.2)
+.\" IPV6_JOIN_ANYCAST (2.4.21 / 2.6)
+.\" IPV6_LEAVE_ANYCAST (2.4.21 / 2.6)
+.\" IPV6_FLOWLABEL_MGR (2.2.7 / 2.4)
+.\" IPV6_FLOWINFO_SEND (2.2.7 / 2.4)
+.\" IPV6_IPSEC_POLICY (2.6)
+.\" IPV6_XFRM_POLICY (2.6)
+.\" IPV6_TCLASS (2.6)
+.\"
+.\" IPV6_ADDR_PREFERENCES (2.6.26)
+.\" commit 7cbca67c073263c179f605bdbbdc565ab29d801d
+.\" Author: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
+.\" IPV6_MINHOPCOUNT (2.6.35)
+.\" commit e802af9cabb011f09b9c19a82faef3dd315f27eb
+.\" Author: Stephen Hemminger <shemminger@vyatta.com>
+.\" IPV6_ORIGDSTADDR (2.6.37)
+.\" Actually a CMSG rather than a sockopt?
+.\" In header file, we have IPV6_RECVORIGDSTADDR == IPV6_ORIGDSTADDR
+.\" commit 6c46862280c5f55eda7750391bc65cd7e08c7535
+.\" Author: Balazs Scheidler <bazsi@balabit.hu>
+.\" IPV6_RECVORIGDSTADDR (2.6.37)
+.\" commit 6c46862280c5f55eda7750391bc65cd7e08c7535
+.\" Author: Balazs Scheidler <bazsi@balabit.hu>
+.\" Support for IPV6_RECVORIGDSTADDR sockopt for UDP sockets
+.\" were contributed by Harry Mason.
+.\" IPV6_TRANSPARENT (2.6.37)
+.\" commit 6c46862280c5f55eda7750391bc65cd7e08c7535
+.\" Author: Balazs Scheidler <bazsi@balabit.hu>
+.\" IPV6_UNICAST_IF (3.4)
+.\" commit c4062dfc425e94290ac427a98d6b4721dd2bc91f
+.\" Author: Erich E. Hoover <ehoover@mines.edu>
+.\"
+.TH IPV6 7 2017-09-15 "Linux" "Linux Programmer's Manual"
.SH NAME
ipv6 \- Linux IPv6 protocol implementation
.SH SYNOPSIS
.B #include <sys/socket.h>
.br
.B #include <netinet/in.h>
-.sp
+.PP
.IB tcp6_socket " = socket(AF_INET6, SOCK_STREAM, 0);"
.br
.IB raw6_socket " = socket(AF_INET6, SOCK_RAW, " protocol ");"
.PP
IPv4 connections can be handled with the v6 API by using the
v4-mapped-on-v6 address type;
-thus a program only needs to support this API type to
+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.
.PP
IPv4 and IPv6 share the local port space.
When you get an IPv4 connection
-or packet to a IPv6 socket, its source address will be mapped
+or packet to an IPv6 socket, its source address will be mapped
to v6 and it will be mapped to v6.
-.SS "Address Format"
+.SS Address format
.in +4n
-.nf
+.EX
struct sockaddr_in6 {
sa_family_t sin6_family; /* AF_INET6 */
in_port_t sin6_port; /* port number */
struct in6_addr {
unsigned char s6_addr[16]; /* IPv6 address */
};
-.fi
+.EE
.in
-.sp
+.PP
.I sin6_family
is always set to
.BR AF_INET6 ;
.I sin6_scope_id
is an ID depending on the scope of the address.
It is new in Linux 2.4.
-Linux only supports it for link-local addresses, in that case
+Linux supports it only for link-local addresses, in that case
.I sin6_scope_id
contains the interface index (see
.BR netdevice (7))
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.
+address an IPv4 host, and other reserved address types.
.PP
The address notation for IPv6 is a group of 8 4-digit hexadecimal
numbers, separated with a \(aq:\(aq.
for IPv4-mapped-on-IPv6.
.PP
The port space of IPv6 is shared with IPv4.
-.SS "Socket Options"
+.SS Socket options
IPv6 supports some protocol-specific socket options that can be set with
.BR setsockopt (2)
and read with
Only
.B AF_INET
is currently supported for that.
-It is only allowed for IPv6 sockets
+It is allowed only for IPv6 sockets
that are connected and bound to a v4-mapped-on-v6 address.
The argument is a pointer to an integer containing
.BR AF_INET .
.B IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP
Control membership in multicast groups.
Argument is a pointer to a
-.I struct ipv6_mreq
-structure.
-.\" FIXME IPV6_CHECKSUM is not documented, and probably should be
-.\" FIXME IPV6_JOIN_ANYCAST is not documented, and probably should be
-.\" FIXME IPV6_LEAVE_ANYCAST is not documented, and probably should be
-.\" FIXME IPV6_PKTINFO is not documented, and probably should be
-.\" FIXME IPV6_2292PKTINFO is not documented, and probably should be
-.\" FIXME there are probably many other IPV6_* socket options that
-.\" should be documented
+.IR "struct ipv6_mreq" .
.TP
.B IPV6_MTU
+.BR getsockopt ():
+Retrieve the current known path MTU of the current socket.
+Valid only when the socket has been connected.
+Returns an integer.
+.IP
+.BR setsockopt ():
Set the MTU to be used for the socket.
The MTU is limited by the device
MTU or the path MTU when path MTU discovery is enabled.
.TP
.B IPV6_MULTICAST_IF
Set the device for outgoing multicast packets on the socket.
-This is only allowed
-for
+This is allowed only for
.B SOCK_DGRAM
and
.B SOCK_RAW
Such control messages contain a
.IR "struct in6_pktinfo" ,
as per RFC 3542.
-Only allowed for
+Allowed only for
.B SOCK_DGRAM
or
.B SOCK_RAW
All these header options can also be set for outgoing packets
by putting the appropriate control message into the control buffer of
.BR sendmsg (2).
-Only allowed for
+Allowed only for
.B SOCK_DGRAM
or
.B SOCK_RAW
.B IPV6_ROUTER_ALERT
Pass forwarded packets containing a router alert hop-by-hop option to
this socket.
-Only allowed for SOCK_RAW sockets.
+Allowed only for
+.B SOCK_RAW
+sockets.
The tapped packets are not forwarded by the kernel, it is the
user's responsibility to send them out again.
Argument is a pointer to an integer.
to sending and receiving IPv6 packets only.
In this case, an IPv4 and an IPv6 application can bind
to a single port at the same time.
-
+.IP
If this flag is set to false (zero),
then the socket can be used to send and receive packets
to and from an IPv6 address or an IPv4-mapped IPv6 address.
-
+.IP
The argument is a pointer to a boolean value in an integer.
-
+.IP
The default value for this flag is defined by the contents of the file
.IR /proc/sys/net/ipv6/bindv6only .
The default value for that file is 0 (false).
.\" FLOWLABEL_MGR, FLOWINFO_SEND
.SH ERRORS
-.\" FIXME document all errors.
.TP
.B ENODEV
The user tried to
structure is not a valid
interface index.
.SH VERSIONS
-The older
-.I libinet6
-libc5 based IPv6 API implementation for Linux is not described here
-and may vary in details.
-.PP
Linux 2.4 will break binary compatibility for the
.I sockaddr_in6
for 64-bit
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"
+.SH NOTES
The
.I sockaddr_in6
structure is bigger than the generic
need to be changed to use
.I struct sockaddr_storage
for that instead.
+.PP
+.BR SOL_IP ,
+.BR SOL_IPV6 ,
+.B SOL_ICMPV6
+and other
+.BR 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;
Flow label management is not complete and not documented here.
.PP
This man page is not complete.
-.SH "SEE ALSO"
+.SH SEE ALSO
.BR cmsg (3),
.BR ip (7)
.PP