OSDN Git Service

(split) LDP: Update original to LDP v3.50.
[linuxjm/LDP_man-pages.git] / original / man7 / ipv6.7
1 .\" This man page is Copyright (C) 2000 Andi Kleen <ak@muc.de>.
2 .\"
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.
8 .\" %%%LICENSE_END
9 .\"
10 .\" $Id: ipv6.7,v 1.3 2000/12/20 18:10:31 ak Exp $
11 .\"
12 .\" The following socket options are undocumented
13 .\"     All of the folloing 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
29 .\"
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 .\"
86 .TH IPV6 7 2012-12-16 "Linux" "Linux Programmer's Manual"
87 .SH NAME
88 ipv6 \- Linux IPv6 protocol implementation
89 .SH SYNOPSIS
90 .B #include <sys/socket.h>
91 .br
92 .B #include <netinet/in.h>
93 .sp
94 .IB tcp6_socket " = socket(AF_INET6, SOCK_STREAM, 0);"
95 .br
96 .IB raw6_socket " = socket(AF_INET6, SOCK_RAW, " protocol ");"
97 .br
98 .IB udp6_socket " = socket(AF_INET6, SOCK_DGRAM, " protocol ");"
99 .SH DESCRIPTION
100 Linux 2.2 optionally implements the Internet Protocol, version 6.
101 This man page contains a description of the IPv6 basic API as
102 implemented by the Linux kernel and glibc 2.1.
103 The interface
104 is based on the BSD sockets interface; see
105 .BR socket (7).
106 .PP
107 The IPv6 API aims to be mostly compatible with the
108 IPv4 API (see
109 .BR ip (7)).
110 Only differences are described in this man page.
111 .PP
112 To bind an
113 .B AF_INET6
114 socket to any process, the local address should be copied from the
115 .I in6addr_any
116 variable which has
117 .I in6_addr
118 type.
119 In static initializations,
120 .B IN6ADDR_ANY_INIT
121 may also be used, which expands to a constant expression.
122 Both of them are in network byte order.
123 .PP
124 The IPv6 loopback address (::1) is available in the global
125 .I in6addr_loopback
126 variable.
127 For initializations,
128 .B IN6ADDR_LOOPBACK_INIT
129 should be used.
130 .PP
131 IPv4 connections can be handled with the v6 API by using the
132 v4-mapped-on-v6 address type;
133 thus a program only needs to support this API type to
134 support both protocols.
135 This is handled transparently by the address
136 handling functions in the C library.
137 .PP
138 IPv4 and IPv6 share the local port space.
139 When you get an IPv4 connection
140 or packet to a IPv6 socket, its source address will be mapped
141 to v6 and it will be mapped to v6.
142 .SS Address format
143 .in +4n
144 .nf
145 struct sockaddr_in6 {
146     sa_family_t     sin6_family;   /* AF_INET6 */
147     in_port_t       sin6_port;     /* port number */
148     uint32_t        sin6_flowinfo; /* IPv6 flow information */
149     struct in6_addr sin6_addr;     /* IPv6 address */
150     uint32_t        sin6_scope_id; /* Scope ID (new in 2.4) */
151 };
152
153 struct in6_addr {
154     unsigned char   s6_addr[16];   /* IPv6 address */
155 };
156 .fi
157 .in
158 .sp
159 .I sin6_family
160 is always set to
161 .BR AF_INET6 ;
162 .I sin6_port
163 is the protocol port (see
164 .I sin_port
165 in
166 .BR ip (7));
167 .I sin6_flowinfo
168 is the IPv6 flow identifier;
169 .I sin6_addr
170 is the 128-bit IPv6 address.
171 .I sin6_scope_id
172 is an ID depending on the scope of the address.
173 It is new in Linux 2.4.
174 Linux only supports it for link-local addresses, in that case
175 .I sin6_scope_id
176 contains the interface index (see
177 .BR netdevice (7))
178 .PP
179 IPv6 supports several address types: unicast to address a single
180 host, multicast to address a group of hosts,
181 anycast to address the nearest member of a group of hosts
182 (not implemented in Linux), IPv4-on-IPv6 to
183 address a IPv4 host, and other reserved address types.
184 .PP
185 The address notation for IPv6 is a group of 8 4-digit hexadecimal
186 numbers, separated with a \(aq:\(aq.
187 \&"::" stands for a string of 0 bits.
188 Special addresses are ::1 for loopback and ::FFFF:<IPv4 address>
189 for IPv4-mapped-on-IPv6.
190 .PP
191 The port space of IPv6 is shared with IPv4.
192 .SS Socket options
193 IPv6 supports some protocol-specific socket options that can be set with
194 .BR setsockopt (2)
195 and read with
196 .BR getsockopt (2).
197 The socket option level for IPv6 is
198 .BR IPPROTO_IPV6 .
199 A boolean integer flag is zero when it is false, otherwise true.
200 .TP
201 .B IPV6_ADDRFORM
202 Turn an
203 .B AF_INET6
204 socket into a socket of a different address family.
205 Only
206 .B AF_INET
207 is currently supported for that.
208 It is only allowed for IPv6 sockets
209 that are connected and bound to a v4-mapped-on-v6 address.
210 The argument is a pointer to an integer containing
211 .BR AF_INET .
212 This is useful to pass v4-mapped sockets as file descriptors to
213 programs that don't know how to deal with the IPv6 API.
214 .TP
215 .B IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP
216 Control membership in multicast groups.
217 Argument is a pointer to a
218 .IR "struct ipv6_mreq" .
219 .TP
220 .B IPV6_MTU
221 .BR getsockopt ():
222 Retrieve the current known path MTU of the current socket.
223 Only valid when the socket has been connected.
224 Returns an integer.
225
226 .BR setsockopt ():
227 Set the MTU to be used for the socket.
228 The MTU is limited by the device
229 MTU or the path MTU when path MTU discovery is enabled.
230 Argument is a pointer to integer.
231 .TP
232 .B IPV6_MTU_DISCOVER
233 Control path-MTU discovery on the socket.
234 See
235 .B IP_MTU_DISCOVER
236 in
237 .BR ip (7)
238 for details.
239 .TP
240 .B IPV6_MULTICAST_HOPS
241 Set the multicast hop limit for the socket.
242 Argument is a pointer to an
243 integer.
244 \-1 in the value means use the route default, otherwise it should be
245 between 0 and 255.
246 .TP
247 .B IPV6_MULTICAST_IF
248 Set the device for outgoing multicast packets on the socket.
249 This is only allowed
250 for
251 .B SOCK_DGRAM
252 and
253 .B SOCK_RAW
254 socket.
255 The argument is a pointer to an interface index (see
256 .BR netdevice (7))
257 in an integer.
258 .TP
259 .B IPV6_MULTICAST_LOOP
260 Control whether the socket sees multicast packets that it has send itself.
261 Argument is a pointer to boolean.
262 .TP
263 .BR IPV6_RECVPKTINFO " (since Linux 2.6.14)"
264 Set delivery of the
265 .B IPV6_PKTINFO
266 control message on incoming datagrams.
267 Such control messages contain a
268 .IR "struct in6_pktinfo" ,
269 as per RFC 3542.
270 Only allowed for
271 .B SOCK_DGRAM
272 or
273 .B SOCK_RAW
274 sockets.
275 Argument is a pointer to a boolean value in an integer.
276 .TP
277 .nh
278 .B IPV6_RTHDR, IPV6_AUTHHDR, IPV6_DSTOPTS, IPV6_HOPOPTS, IPV6_FLOWINFO, IPV6_HOPLIMIT
279 .hy
280 Set delivery of control messages for incoming datagrams containing
281 extension headers from the received packet.
282 .B IPV6_RTHDR
283 delivers the routing header,
284 .B IPV6_AUTHHDR
285 delivers the authentication header,
286 .B IPV6_DSTOPTS
287 delivers the destination options,
288 .B IPV6_HOPOPTS
289 delivers the hop options,
290 .B IPV6_FLOWINFO
291 delivers an integer containing the flow ID,
292 .B IPV6_HOPLIMIT
293 delivers an integer containing the hop count of the packet.
294 The control messages have the same type as the socket option.
295 All these header options can also be set for outgoing packets
296 by putting the appropriate control message into the control buffer of
297 .BR sendmsg (2).
298 Only allowed for
299 .B SOCK_DGRAM
300 or
301 .B SOCK_RAW
302 sockets.
303 Argument is a pointer to a boolean value.
304 .TP
305 .B IPV6_RECVERR
306 Control receiving of asynchronous error options.
307 See
308 .B IP_RECVERR
309 in
310 .BR ip (7)
311 for details.
312 Argument is a pointer to boolean.
313 .TP
314 .B IPV6_ROUTER_ALERT
315 Pass forwarded packets containing a router alert hop-by-hop option to
316 this socket.
317 Only allowed for SOCK_RAW sockets.
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
325 to this socket.
326 .TP
327 .B IPV6_UNICAST_HOPS
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.
332 .TP
333 .BR IPV6_V6ONLY " (since Linux 2.4.21 and 2.6)"
334 .\" See RFC 3493
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.
339
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.
343
344 The argument is a pointer to a boolean value in an integer.
345
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
350 .SH ERRORS
351 .\" FIXME document all errors.
352 .TP
353 .B ENODEV
354 The user tried to
355 .BR bind (2)
356 to a link-local IPv6 address, but the
357 .I sin6_scope_id
358 in the supplied
359 .I sockaddr_in6
360 structure is not a valid
361 interface index.
362 .SH VERSIONS
363 The older
364 .I libinet6
365 libc5 based IPv6 API implementation for Linux is not described here
366 and may vary in details.
367 .PP
368 Linux 2.4 will break binary compatibility for the
369 .I sockaddr_in6
370 for 64-bit
371 hosts by changing the alignment of
372 .I in6_addr
373 and adding an additional
374 .I sin6_scope_id
375 field.
376 The kernel interfaces stay compatible, but a program including
377 .I sockaddr_in6
378 or
379 .I in6_addr
380 into other structures may not be.
381 This is not
382 a problem for 32-bit hosts like i386.
383 .PP
384 The
385 .I sin6_flowinfo
386 field is new in Linux 2.4.
387 It is transparently passed/read by the kernel
388 when the passed address length contains it.
389 Some programs that pass a longer address buffer and then
390 check the outgoing address length may break.
391 .SH NOTES
392 The
393 .I sockaddr_in6
394 structure is bigger than the generic
395 .IR sockaddr .
396 Programs that assume that all address types can be stored safely in a
397 .I struct sockaddr
398 need to be changed to use
399 .I struct sockaddr_storage
400 for that instead.
401 .SH BUGS
402 The IPv6 extended API as in RFC\ 2292 is currently only partly
403 implemented;
404 although the 2.2 kernel has near complete support for receiving options,
405 the macros for generating IPv6 options are missing in glibc 2.1.
406 .PP
407 IPSec support for EH and AH headers is missing.
408 .PP
409 Flow label management is not complete and not documented here.
410 .PP
411 This man page is not complete.
412 .SH SEE ALSO
413 .BR cmsg (3),
414 .BR ip (7)
415 .PP
416 RFC\ 2553: IPv6 BASIC API;
417 Linux tries to be compliant to this.
418 RFC\ 2460: IPv6 specification.