1 .\" This man page is Copyright (C) 2000 Andi Kleen <ak@muc.de>.
3 .\" %%%LICENSE_START(VERBATIM_ONE_PARA)
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.
10 .\" $Id: ipv6.7,v 1.3 2000/12/20 18:10:31 ak Exp $
12 .\" The following socket options are undocumented
13 .\" All of the following are from:
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
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)
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>
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>
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)
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>
86 .TH IPV6 7 2021-03-22 "Linux" "Linux Programmer's Manual"
88 ipv6 \- Linux IPv6 protocol implementation
91 .B #include <sys/socket.h>
92 .B #include <netinet/in.h>
94 .IB tcp6_socket " = socket(AF_INET6, SOCK_STREAM, 0);"
95 .IB raw6_socket " = socket(AF_INET6, SOCK_RAW, " protocol ");"
96 .IB udp6_socket " = socket(AF_INET6, SOCK_DGRAM, " protocol ");"
99 Linux 2.2 optionally implements the Internet Protocol, version 6.
100 This man page contains a description of the IPv6 basic API as
101 implemented by the Linux kernel and glibc 2.1.
103 is based on the BSD sockets interface; see
106 The IPv6 API aims to be mostly compatible with the
109 Only differences are described in this man page.
113 socket to any process, the local address should be copied from the
118 In static initializations,
120 may also be used, which expands to a constant expression.
121 Both of them are in network byte order.
123 The IPv6 loopback address (::1) is available in the global
127 .B IN6ADDR_LOOPBACK_INIT
130 IPv4 connections can be handled with the v6 API by using the
131 v4-mapped-on-v6 address type;
132 thus a program needs to support only this API type to
133 support both protocols.
134 This is handled transparently by the address
135 handling functions in the C library.
137 IPv4 and IPv6 share the local port space.
138 When you get an IPv4 connection
139 or packet to an IPv6 socket, its source address will be mapped
140 to v6 and it will be mapped to v6.
144 struct sockaddr_in6 {
145 sa_family_t sin6_family; /* AF_INET6 */
146 in_port_t sin6_port; /* port number */
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) */
153 unsigned char s6_addr[16]; /* IPv6 address */
162 is the protocol port (see
167 is the IPv6 flow identifier;
169 is the 128-bit IPv6 address.
171 is an ID depending on the scope of the address.
172 It is new in Linux 2.4.
173 Linux supports it only for link-local addresses, in that case
175 contains the interface index (see
178 IPv6 supports several address types: unicast to address a single
179 host, multicast to address a group of hosts,
180 anycast to address the nearest member of a group of hosts
181 (not implemented in Linux), IPv4-on-IPv6 to
182 address an IPv4 host, and other reserved address types.
184 The address notation for IPv6 is a group of 8 4-digit hexadecimal
185 numbers, separated with a \(aq:\(aq.
186 \&"::" stands for a string of 0 bits.
187 Special addresses are ::1 for loopback and ::FFFF:<IPv4 address>
188 for IPv4-mapped-on-IPv6.
190 The port space of IPv6 is shared with IPv4.
192 IPv6 supports some protocol-specific socket options that can be set with
196 The socket option level for IPv6 is
198 A boolean integer flag is zero when it is false, otherwise true.
203 socket into a socket of a different address family.
206 is currently supported for that.
207 It is allowed only for IPv6 sockets
208 that are connected and bound to a v4-mapped-on-v6 address.
209 The argument is a pointer to an integer containing
211 This is useful to pass v4-mapped sockets as file descriptors to
212 programs that don't know how to deal with the IPv6 API.
214 .B IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP
215 Control membership in multicast groups.
216 Argument is a pointer to a
217 .IR "struct ipv6_mreq" .
221 Retrieve the current known path MTU of the current socket.
222 Valid only when the socket has been connected.
226 Set the MTU to be used for the socket.
227 The MTU is limited by the device
228 MTU or the path MTU when path MTU discovery is enabled.
229 Argument is a pointer to integer.
232 Control path-MTU discovery on the socket.
239 .B IPV6_MULTICAST_HOPS
240 Set the multicast hop limit for the socket.
241 Argument is a pointer to an
243 \-1 in the value means use the route default, otherwise it should be
247 Set the device for outgoing multicast packets on the socket.
248 This is allowed only for
253 The argument is a pointer to an interface index (see
257 .B IPV6_MULTICAST_LOOP
258 Control whether the socket sees multicast packets that it has send itself.
259 Argument is a pointer to boolean.
261 .BR IPV6_RECVPKTINFO " (since Linux 2.6.14)"
264 control message on incoming datagrams.
265 Such control messages contain a
266 .IR "struct in6_pktinfo" ,
273 Argument is a pointer to a boolean value in an integer.
276 .B IPV6_RTHDR, IPV6_AUTHHDR, IPV6_DSTOPTS, IPV6_HOPOPTS, IPV6_FLOWINFO, IPV6_HOPLIMIT
278 Set delivery of control messages for incoming datagrams containing
279 extension headers from the received packet.
281 delivers the routing header,
283 delivers the authentication header,
285 delivers the destination options,
287 delivers the hop options,
289 delivers an integer containing the flow ID,
291 delivers an integer containing the hop count of the packet.
292 The control messages have the same type as the socket option.
293 All these header options can also be set for outgoing packets
294 by putting the appropriate control message into the control buffer of
301 Argument is a pointer to a boolean value.
304 Control receiving of asynchronous error options.
310 Argument is a pointer to boolean.
313 Pass forwarded packets containing a router alert hop-by-hop option to
318 The tapped packets are not forwarded by the kernel, it is the
319 user's responsibility to send them out again.
320 Argument is a pointer to an integer.
321 A positive integer indicates a router alert option value to intercept.
322 Packets carrying a router alert option with a value field containing
323 this integer will be delivered to the socket.
324 A negative integer disables delivery of packets with router alert options
328 Set the unicast hop limit for the socket.
329 Argument is a pointer to an integer.
330 \-1 in the value means use the route default,
331 otherwise it should be between 0 and 255.
333 .BR IPV6_V6ONLY " (since Linux 2.4.21 and 2.6)"
335 If this flag is set to true (nonzero), then the socket is restricted
336 to sending and receiving IPv6 packets only.
337 In this case, an IPv4 and an IPv6 application can bind
338 to a single port at the same time.
340 If this flag is set to false (zero),
341 then the socket can be used to send and receive packets
342 to and from an IPv6 address or an IPv4-mapped IPv6 address.
344 The argument is a pointer to a boolean value in an integer.
346 The default value for this flag is defined by the contents of the file
347 .IR /proc/sys/net/ipv6/bindv6only .
348 The default value for that file is 0 (false).
349 .\" FLOWLABEL_MGR, FLOWINFO_SEND
355 to a link-local IPv6 address, but the
359 structure is not a valid
362 Linux 2.4 will break binary compatibility for the
365 hosts by changing the alignment of
367 and adding an additional
370 The kernel interfaces stay compatible, but a program including
374 into other structures may not be.
376 a problem for 32-bit hosts like i386.
380 field is new in Linux 2.4.
381 It is transparently passed/read by the kernel
382 when the passed address length contains it.
383 Some programs that pass a longer address buffer and then
384 check the outgoing address length may break.
388 structure is bigger than the generic
390 Programs that assume that all address types can be stored safely in a
392 need to be changed to use
393 .I struct sockaddr_storage
401 socket options are nonportable variants of
406 The IPv6 extended API as in RFC\ 2292 is currently only partly
408 although the 2.2 kernel has near complete support for receiving options,
409 the macros for generating IPv6 options are missing in glibc 2.1.
411 IPSec support for EH and AH headers is missing.
413 Flow label management is not complete and not documented here.
415 This man page is not complete.
420 RFC\ 2553: IPv6 BASIC API;
421 Linux tries to be compliant to this.
422 RFC\ 2460: IPv6 specification.