]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/ipv6.7
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man7 / ipv6.7
CommitLineData
77117f4f 1.\" This man page is Copyright (C) 2000 Andi Kleen <ak@muc.de>.
2297bf0e 2.\"
00acdba1 3.\" %%%LICENSE_START(VERBATIM_ONE_PARA)
77117f4f
MK
4.\" Permission is granted to distribute possibly modified copies
5.\" of this page provided the header is included verbatim,
6.\" and in case of nontrivial modification author and date
7.\" of the modification is added to the header.
8ff7380d 8.\" %%%LICENSE_END
6a717e5e 9.\"
77117f4f 10.\" $Id: ipv6.7,v 1.3 2000/12/20 18:10:31 ak Exp $
c6a7484a
MK
11.\"
12.\" The following socket options are undocumented
78a87bf9 13.\" All of the following are from:
c6a7484a
MK
14.\" commit 333fad5364d6b457c8d837f7d05802d2aaf8a961
15.\" Author: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
16.\" Support several new sockopt / ancillary data in Advanced API (RFC3542).
17.\" IPV6_2292PKTINFO (2.6.14)
18.\" Formerly IPV6_PKTINFO
19.\" IPV6_2292HOPOPTS (2.6.14)
20.\" Formerly IPV6_HOPOPTS, which is documented
21.\" IPV6_2292DSTOPTS (2.6.14)
22.\" Formerly IPV6_DSTOPTS, which is documented
23.\" IPV6_2292RTHDR (2.6.14)
24.\" Formerly IPV6_RTHDR, which is documented
25.\" IPV6_2292PKTOPTIONS (2.6.14)
26.\" Formerly IPV6_PKTOPTIONS
27.\" IPV6_2292HOPLIMIT (2.6.14)
28.\" Formerly IPV6_HOPLIMIT, which is documented
e6d86b41 29.\"
c6a7484a
MK
30.\" IPV6_RECVHOPLIMIT (2.6.14)
31.\" IPV6_RECVHOPOPTS (2.6.14)
32.\" IPV6_RTHDRDSTOPTS (2.6.14)
33.\" IPV6_RECVRTHDR (2.6.14)
34.\" IPV6_RECVDSTOPTS (2.6.14)
35.\"
36.\" IPV6_RECVPATHMTU (2.6.35, flag value added in 2.6.14)
37.\" commit 793b14731686595a741d9f47726ad8b9a235385a
38.\" Author: Brian Haley <brian.haley@hp.com>
39.\" IPV6_PATHMTU (2.6.35, flag value added in 2.6.14)
40.\" commit 793b14731686595a741d9f47726ad8b9a235385a
41.\" Author: Brian Haley <brian.haley@hp.com>
42.\" IPV6_DONTFRAG (2.6.35, flag value added in 2.6.14)
43.\" commit 793b14731686595a741d9f47726ad8b9a235385a
44.\" Author: Brian Haley <brian.haley@hp.com>
45.\" commit 4b340ae20d0e2366792abe70f46629e576adaf5e
46.\" Author: Brian Haley <brian.haley@hp.com>
47.\"
48.\" IPV6_RECVTCLASS (2.6.14)
49.\" commit 41a1f8ea4fbfcdc4232f023732584aae2220de31
50.\" Author: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
51.\" Based on patch from David L Stevens <dlstevens@us.ibm.com>
52.\"
53.\" IPV6_CHECKSUM (2.2)
54.\" IPV6_NEXTHOP (2.2)
55.\" IPV6_JOIN_ANYCAST (2.4.21 / 2.6)
56.\" IPV6_LEAVE_ANYCAST (2.4.21 / 2.6)
57.\" IPV6_FLOWLABEL_MGR (2.2.7 / 2.4)
58.\" IPV6_FLOWINFO_SEND (2.2.7 / 2.4)
59.\" IPV6_IPSEC_POLICY (2.6)
60.\" IPV6_XFRM_POLICY (2.6)
61.\" IPV6_TCLASS (2.6)
62.\"
63.\" IPV6_ADDR_PREFERENCES (2.6.26)
64.\" commit 7cbca67c073263c179f605bdbbdc565ab29d801d
65.\" Author: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
66.\" IPV6_MINHOPCOUNT (2.6.35)
67.\" commit e802af9cabb011f09b9c19a82faef3dd315f27eb
68.\" Author: Stephen Hemminger <shemminger@vyatta.com>
69.\" IPV6_ORIGDSTADDR (2.6.37)
70.\" Actually a CMSG rather than a sockopt?
71.\" In header file, we have IPV6_RECVORIGDSTADDR == IPV6_ORIGDSTADDR
72.\" commit 6c46862280c5f55eda7750391bc65cd7e08c7535
73.\" Author: Balazs Scheidler <bazsi@balabit.hu>
74.\" IPV6_RECVORIGDSTADDR (2.6.37)
75.\" commit 6c46862280c5f55eda7750391bc65cd7e08c7535
76.\" Author: Balazs Scheidler <bazsi@balabit.hu>
77.\" Support for IPV6_RECVORIGDSTADDR sockopt for UDP sockets
78.\" were contributed by Harry Mason.
79.\" IPV6_TRANSPARENT (2.6.37)
80.\" commit 6c46862280c5f55eda7750391bc65cd7e08c7535
81.\" Author: Balazs Scheidler <bazsi@balabit.hu>
82.\" IPV6_UNICAST_IF (3.4)
83.\" commit c4062dfc425e94290ac427a98d6b4721dd2bc91f
84.\" Author: Erich E. Hoover <ehoover@mines.edu>
85.\"
45186a5d 86.TH IPV6 7 2021-03-22 "Linux man-pages (unreleased)"
77117f4f 87.SH NAME
61310e03 88ipv6 \- Linux IPv6 protocol implementation
77117f4f 89.SH SYNOPSIS
c7db92b9 90.nf
77117f4f 91.B #include <sys/socket.h>
77117f4f 92.B #include <netinet/in.h>
68e4db0a 93.PP
d4c8c97c 94.IB tcp6_socket " = socket(AF_INET6, SOCK_STREAM, 0);"
d4c8c97c 95.IB raw6_socket " = socket(AF_INET6, SOCK_RAW, " protocol ");"
d4c8c97c 96.IB udp6_socket " = socket(AF_INET6, SOCK_DGRAM, " protocol ");"
c7db92b9 97.fi
77117f4f
MK
98.SH DESCRIPTION
99Linux 2.2 optionally implements the Internet Protocol, version 6.
100This man page contains a description of the IPv6 basic API as
101implemented by the Linux kernel and glibc 2.1.
102The interface
103is based on the BSD sockets interface; see
104.BR socket (7).
105.PP
106The IPv6 API aims to be mostly compatible with the
acae0322
MK
107IPv4 API (see
108.BR ip (7)).
77117f4f
MK
109Only differences are described in this man page.
110.PP
111To bind an
112.B AF_INET6
acae0322 113socket to any process, the local address should be copied from the
77117f4f
MK
114.I in6addr_any
115variable which has
116.I in6_addr
117type.
acae0322 118In static initializations,
77117f4f
MK
119.B IN6ADDR_ANY_INIT
120may also be used, which expands to a constant expression.
acae0322 121Both of them are in network byte order.
77117f4f
MK
122.PP
123The IPv6 loopback address (::1) is available in the global
124.I in6addr_loopback
125variable.
acae0322 126For initializations,
77117f4f
MK
127.B IN6ADDR_LOOPBACK_INIT
128should be used.
129.PP
130IPv4 connections can be handled with the v6 API by using the
131v4-mapped-on-v6 address type;
043649cd 132thus a program needs to support only this API type to
77117f4f
MK
133support both protocols.
134This is handled transparently by the address
acae0322 135handling functions in the C library.
77117f4f
MK
136.PP
137IPv4 and IPv6 share the local port space.
138When you get an IPv4 connection
b3f48015 139or packet to an IPv6 socket, its source address will be mapped
77117f4f 140to v6 and it will be mapped to v6.
73d8cece 141.SS Address format
77117f4f 142.in +4n
6545cc56 143.EX
77117f4f 144struct sockaddr_in6 {
191702ea
TH
145 sa_family_t sin6_family; /* AF_INET6 */
146 in_port_t sin6_port; /* port number */
77117f4f
MK
147 uint32_t sin6_flowinfo; /* IPv6 flow information */
148 struct in6_addr sin6_addr; /* IPv6 address */
149 uint32_t sin6_scope_id; /* Scope ID (new in 2.4) */
150};
151
152struct in6_addr {
153 unsigned char s6_addr[16]; /* IPv6 address */
154};
6545cc56 155.EE
77117f4f 156.in
51f5698d 157.PP
77117f4f
MK
158.I sin6_family
159is always set to
160.BR AF_INET6 ;
161.I sin6_port
162is the protocol port (see
163.I sin_port
164in
165.BR ip (7));
166.I sin6_flowinfo
167is the IPv6 flow identifier;
168.I sin6_addr
169is the 128-bit IPv6 address.
170.I sin6_scope_id
acae0322 171is an ID depending on the scope of the address.
77117f4f 172It is new in Linux 2.4.
33a0ccb2 173Linux supports it only for link-local addresses, in that case
77117f4f
MK
174.I sin6_scope_id
175contains the interface index (see
176.BR netdevice (7))
177.PP
178IPv6 supports several address types: unicast to address a single
179host, multicast to address a group of hosts,
180anycast to address the nearest member of a group of hosts
181(not implemented in Linux), IPv4-on-IPv6 to
b3f48015 182address an IPv4 host, and other reserved address types.
77117f4f 183.PP
c080d579 184The address notation for IPv6 is a group of 8 4-digit hexadecimal
77117f4f
MK
185numbers, separated with a \(aq:\(aq.
186\&"::" stands for a string of 0 bits.
187Special addresses are ::1 for loopback and ::FFFF:<IPv4 address>
188for IPv4-mapped-on-IPv6.
189.PP
190The port space of IPv6 is shared with IPv4.
73d8cece 191.SS Socket options
77117f4f
MK
192IPv6 supports some protocol-specific socket options that can be set with
193.BR setsockopt (2)
194and read with
195.BR getsockopt (2).
196The socket option level for IPv6 is
197.BR IPPROTO_IPV6 .
198A boolean integer flag is zero when it is false, otherwise true.
199.TP
200.B IPV6_ADDRFORM
201Turn an
202.B AF_INET6
203socket into a socket of a different address family.
204Only
205.B AF_INET
206is currently supported for that.
33a0ccb2 207It is allowed only for IPv6 sockets
77117f4f
MK
208that are connected and bound to a v4-mapped-on-v6 address.
209The argument is a pointer to an integer containing
210.BR AF_INET .
211This is useful to pass v4-mapped sockets as file descriptors to
212programs that don't know how to deal with the IPv6 API.
213.TP
214.B IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP
215Control membership in multicast groups.
216Argument is a pointer to a
437b953c 217.IR "struct ipv6_mreq" .
77117f4f
MK
218.TP
219.B IPV6_MTU
2970eb3b 220.BR getsockopt ():
032e1ba5 221Retrieve the current known path MTU of the current socket.
d4c45a8e 222Valid only when the socket has been connected.
032e1ba5 223Returns an integer.
5711c04f 224.IP
2970eb3b 225.BR setsockopt ():
77117f4f
MK
226Set the MTU to be used for the socket.
227The MTU is limited by the device
4023450d 228MTU or the path MTU when path MTU discovery is enabled.
77117f4f
MK
229Argument is a pointer to integer.
230.TP
231.B IPV6_MTU_DISCOVER
4023450d 232Control path-MTU discovery on the socket.
77117f4f
MK
233See
234.B IP_MTU_DISCOVER
235in
236.BR ip (7)
237for details.
238.TP
239.B IPV6_MULTICAST_HOPS
240Set the multicast hop limit for the socket.
241Argument is a pointer to an
242integer.
243\-1 in the value means use the route default, otherwise it should be
244between 0 and 255.
245.TP
246.B IPV6_MULTICAST_IF
247Set the device for outgoing multicast packets on the socket.
33a0ccb2 248This is allowed only for
77117f4f
MK
249.B SOCK_DGRAM
250and
251.B SOCK_RAW
252socket.
253The argument is a pointer to an interface index (see
254.BR netdevice (7))
255in an integer.
256.TP
257.B IPV6_MULTICAST_LOOP
258Control whether the socket sees multicast packets that it has send itself.
259Argument is a pointer to boolean.
260.TP
d796c68d 261.BR IPV6_RECVPKTINFO " (since Linux 2.6.14)"
77117f4f
MK
262Set delivery of the
263.B IPV6_PKTINFO
264control message on incoming datagrams.
b33062e5
DP
265Such control messages contain a
266.IR "struct in6_pktinfo" ,
267as per RFC 3542.
d4c45a8e 268Allowed only for
77117f4f
MK
269.B SOCK_DGRAM
270or
271.B SOCK_RAW
272sockets.
273Argument is a pointer to a boolean value in an integer.
274.TP
275.nh
52e27aeb 276.B IPV6_RTHDR, IPV6_AUTHHDR, IPV6_DSTOPTS, IPV6_HOPOPTS, IPV6_FLOWINFO, IPV6_HOPLIMIT
77117f4f
MK
277.hy
278Set delivery of control messages for incoming datagrams containing
279extension headers from the received packet.
280.B IPV6_RTHDR
281delivers the routing header,
282.B IPV6_AUTHHDR
283delivers the authentication header,
284.B IPV6_DSTOPTS
285delivers the destination options,
286.B IPV6_HOPOPTS
287delivers the hop options,
288.B IPV6_FLOWINFO
289delivers an integer containing the flow ID,
290.B IPV6_HOPLIMIT
291delivers an integer containing the hop count of the packet.
292The control messages have the same type as the socket option.
293All these header options can also be set for outgoing packets
294by putting the appropriate control message into the control buffer of
295.BR sendmsg (2).
d4c45a8e 296Allowed only for
77117f4f
MK
297.B SOCK_DGRAM
298or
299.B SOCK_RAW
300sockets.
301Argument is a pointer to a boolean value.
302.TP
303.B IPV6_RECVERR
304Control receiving of asynchronous error options.
305See
306.B IP_RECVERR
307in
308.BR ip (7)
309for details.
310Argument is a pointer to boolean.
311.TP
312.B IPV6_ROUTER_ALERT
313Pass forwarded packets containing a router alert hop-by-hop option to
314this socket.
d4c45a8e 315Allowed only for
b834c23e
YK
316.B SOCK_RAW
317sockets.
77117f4f
MK
318The tapped packets are not forwarded by the kernel, it is the
319user's responsibility to send them out again.
320Argument is a pointer to an integer.
321A positive integer indicates a router alert option value to intercept.
322Packets carrying a router alert option with a value field containing
323this integer will be delivered to the socket.
324A negative integer disables delivery of packets with router alert options
325to this socket.
326.TP
327.B IPV6_UNICAST_HOPS
328Set the unicast hop limit for the socket.
329Argument is a pointer to an integer.
330\-1 in the value means use the route default,
331otherwise it should be between 0 and 255.
332.TP
333.BR IPV6_V6ONLY " (since Linux 2.4.21 and 2.6)"
334.\" See RFC 3493
c7094399 335If this flag is set to true (nonzero), then the socket is restricted
77117f4f
MK
336to sending and receiving IPv6 packets only.
337In this case, an IPv4 and an IPv6 application can bind
338to a single port at the same time.
5711c04f 339.IP
77117f4f
MK
340If this flag is set to false (zero),
341then the socket can be used to send and receive packets
342to and from an IPv6 address or an IPv4-mapped IPv6 address.
5711c04f 343.IP
77117f4f 344The argument is a pointer to a boolean value in an integer.
5711c04f 345.IP
77117f4f 346The default value for this flag is defined by the contents of the file
f08b799c 347.IR /proc/sys/net/ipv6/bindv6only .
77117f4f
MK
348The default value for that file is 0 (false).
349.\" FLOWLABEL_MGR, FLOWINFO_SEND
85ab5d7a 350.SH ERRORS
85ab5d7a
SP
351.TP
352.B ENODEV
353The user tried to
354.BR bind (2)
355to a link-local IPv6 address, but the
356.I sin6_scope_id
357in the supplied
358.I sockaddr_in6
359structure is not a valid
360interface index.
77117f4f 361.SH VERSIONS
77117f4f
MK
362Linux 2.4 will break binary compatibility for the
363.I sockaddr_in6
364for 64-bit
365hosts by changing the alignment of
366.I in6_addr
367and adding an additional
368.I sin6_scope_id
369field.
370The kernel interfaces stay compatible, but a program including
371.I sockaddr_in6
372or
373.I in6_addr
374into other structures may not be.
375This is not
376a problem for 32-bit hosts like i386.
377.PP
378The
379.I sin6_flowinfo
380field is new in Linux 2.4.
381It is transparently passed/read by the kernel
382when the passed address length contains it.
383Some programs that pass a longer address buffer and then
384check the outgoing address length may break.
47297adb 385.SH NOTES
77117f4f
MK
386The
387.I sockaddr_in6
388structure is bigger than the generic
389.IR sockaddr .
390Programs that assume that all address types can be stored safely in a
391.I struct sockaddr
392need to be changed to use
393.I struct sockaddr_storage
394for that instead.
8013e4ef
SA
395.PP
396.BR SOL_IP ,
397.BR SOL_IPV6 ,
d556548b 398.BR SOL_ICMPV6 ,
8013e4ef 399and other
14d43d30 400.B SOL_*
636355f9 401socket options are nonportable variants of
14d43d30 402.BR IPPROTO_* .
636355f9
MK
403See also
404.BR ip (7).
77117f4f
MK
405.SH BUGS
406The IPv6 extended API as in RFC\ 2292 is currently only partly
407implemented;
408although the 2.2 kernel has near complete support for receiving options,
409the macros for generating IPv6 options are missing in glibc 2.1.
410.PP
411IPSec support for EH and AH headers is missing.
412.PP
413Flow label management is not complete and not documented here.
414.PP
415This man page is not complete.
47297adb 416.SH SEE ALSO
77117f4f
MK
417.BR cmsg (3),
418.BR ip (7)
419.PP
173fe7e7 420RFC\ 2553: IPv6 BASIC API;
77117f4f 421Linux tries to be compliant to this.
77117f4f 422RFC\ 2460: IPv6 specification.