OSDN Git Service

(split) LDP: Update original to LDP v3.41.
[linuxjm/LDP_man-pages.git] / original / man7 / ipv6.7
1 .\" This man page is Copyright (C) 2000 Andi Kleen <ak@muc.de>.
2 .\" Permission is granted to distribute possibly modified copies
3 .\" of this page provided the header is included verbatim,
4 .\" and in case of nontrivial modification author and date
5 .\" of the modification is added to the header.
6 .\" $Id: ipv6.7,v 1.3 2000/12/20 18:10:31 ak Exp $
7 .TH IPV6 7 2012-05-10 "Linux" "Linux Programmer's Manual"
8 .SH NAME
9 ipv6 \- Linux IPv6 protocol implementation
10 .SH SYNOPSIS
11 .B #include <sys/socket.h>
12 .br
13 .B #include <netinet/in.h>
14 .sp
15 .IB tcp6_socket " = socket(AF_INET6, SOCK_STREAM, 0);"
16 .br
17 .IB raw6_socket " = socket(AF_INET6, SOCK_RAW, " protocol ");"
18 .br
19 .IB udp6_socket " = socket(AF_INET6, SOCK_DGRAM, " protocol ");"
20 .SH DESCRIPTION
21 Linux 2.2 optionally implements the Internet Protocol, version 6.
22 This man page contains a description of the IPv6 basic API as
23 implemented by the Linux kernel and glibc 2.1.
24 The interface
25 is based on the BSD sockets interface; see
26 .BR socket (7).
27 .PP
28 The IPv6 API aims to be mostly compatible with the
29 IPv4 API (see
30 .BR ip (7)).
31 Only differences are described in this man page.
32 .PP
33 To bind an
34 .B AF_INET6
35 socket to any process, the local address should be copied from the
36 .I in6addr_any
37 variable which has
38 .I in6_addr
39 type.
40 In static initializations,
41 .B IN6ADDR_ANY_INIT
42 may also be used, which expands to a constant expression.
43 Both of them are in network byte order.
44 .PP
45 The IPv6 loopback address (::1) is available in the global
46 .I in6addr_loopback
47 variable.
48 For initializations,
49 .B IN6ADDR_LOOPBACK_INIT
50 should be used.
51 .PP
52 IPv4 connections can be handled with the v6 API by using the
53 v4-mapped-on-v6 address type;
54 thus a program only needs to support this API type to
55 support both protocols.
56 This is handled transparently by the address
57 handling functions in the C library.
58 .PP
59 IPv4 and IPv6 share the local port space.
60 When you get an IPv4 connection
61 or packet to a IPv6 socket, its source address will be mapped
62 to v6 and it will be mapped to v6.
63 .SS "Address Format"
64 .in +4n
65 .nf
66 struct sockaddr_in6 {
67     sa_family_t     sin6_family;   /* AF_INET6 */
68     in_port_t       sin6_port;     /* port number */
69     uint32_t        sin6_flowinfo; /* IPv6 flow information */
70     struct in6_addr sin6_addr;     /* IPv6 address */
71     uint32_t        sin6_scope_id; /* Scope ID (new in 2.4) */
72 };
73
74 struct in6_addr {
75     unsigned char   s6_addr[16];   /* IPv6 address */
76 };
77 .fi
78 .in
79 .sp
80 .I sin6_family
81 is always set to
82 .BR AF_INET6 ;
83 .I sin6_port
84 is the protocol port (see
85 .I sin_port
86 in
87 .BR ip (7));
88 .I sin6_flowinfo
89 is the IPv6 flow identifier;
90 .I sin6_addr
91 is the 128-bit IPv6 address.
92 .I sin6_scope_id
93 is an ID depending on the scope of the address.
94 It is new in Linux 2.4.
95 Linux only supports it for link-local addresses, in that case
96 .I sin6_scope_id
97 contains the interface index (see
98 .BR netdevice (7))
99 .PP
100 IPv6 supports several address types: unicast to address a single
101 host, multicast to address a group of hosts,
102 anycast to address the nearest member of a group of hosts
103 (not implemented in Linux), IPv4-on-IPv6 to
104 address a IPv4 host, and other reserved address types.
105 .PP
106 The address notation for IPv6 is a group of 8 4-digit hexadecimal
107 numbers, separated with a \(aq:\(aq.
108 \&"::" stands for a string of 0 bits.
109 Special addresses are ::1 for loopback and ::FFFF:<IPv4 address>
110 for IPv4-mapped-on-IPv6.
111 .PP
112 The port space of IPv6 is shared with IPv4.
113 .SS "Socket Options"
114 IPv6 supports some protocol-specific socket options that can be set with
115 .BR setsockopt (2)
116 and read with
117 .BR getsockopt (2).
118 The socket option level for IPv6 is
119 .BR IPPROTO_IPV6 .
120 A boolean integer flag is zero when it is false, otherwise true.
121 .TP
122 .B IPV6_ADDRFORM
123 Turn an
124 .B AF_INET6
125 socket into a socket of a different address family.
126 Only
127 .B AF_INET
128 is currently supported for that.
129 It is only allowed for IPv6 sockets
130 that are connected and bound to a v4-mapped-on-v6 address.
131 The argument is a pointer to an integer containing
132 .BR AF_INET .
133 This is useful to pass v4-mapped sockets as file descriptors to
134 programs that don't know how to deal with the IPv6 API.
135 .TP
136 .B IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP
137 Control membership in multicast groups.
138 Argument is a pointer to a
139 .I struct ipv6_mreq
140 structure.
141 .\" FIXME IPV6_CHECKSUM is not documented, and probably should be
142 .\" FIXME IPV6_JOIN_ANYCAST is not documented, and probably should be
143 .\" FIXME IPV6_LEAVE_ANYCAST is not documented, and probably should be
144 .\" FIXME IPV6_RECVPKTINFO is not documented, and probably should be
145 .\" FIXME IPV6_2292PKTINFO is not documented, and probably should be
146 .\" FIXME there are probably many other IPV6_* socket options that
147 .\" should be documented
148 .TP
149 .B IPV6_MTU
150 Set the MTU to be used for the socket.
151 The MTU is limited by the device
152 MTU or the path MTU when path MTU discovery is enabled.
153 Argument is a pointer to integer.
154 .TP
155 .B IPV6_MTU_DISCOVER
156 Control path-MTU discovery on the socket.
157 See
158 .B IP_MTU_DISCOVER
159 in
160 .BR ip (7)
161 for details.
162 .TP
163 .B IPV6_MULTICAST_HOPS
164 Set the multicast hop limit for the socket.
165 Argument is a pointer to an
166 integer.
167 \-1 in the value means use the route default, otherwise it should be
168 between 0 and 255.
169 .TP
170 .B IPV6_MULTICAST_IF
171 Set the device for outgoing multicast packets on the socket.
172 This is only allowed
173 for
174 .B SOCK_DGRAM
175 and
176 .B SOCK_RAW
177 socket.
178 The argument is a pointer to an interface index (see
179 .BR netdevice (7))
180 in an integer.
181 .TP
182 .B IPV6_MULTICAST_LOOP
183 Control whether the socket sees multicast packets that it has send itself.
184 Argument is a pointer to boolean.
185 .TP
186 .B IPV6_PKTINFO
187 Set delivery of the
188 .B IPV6_PKTINFO
189 control message on incoming datagrams.
190 Only allowed for
191 .B SOCK_DGRAM
192 or
193 .B SOCK_RAW
194 sockets.
195 Argument is a pointer to a boolean value in an integer.
196 .TP
197 .nh
198 .B IPV6_RTHDR, IPV6_AUTHHDR, IPV6_DSTOPTS, IPV6_HOPOPTS, IPV6_FLOWINFO, IPV6_HOPLIMIT
199 .hy
200 Set delivery of control messages for incoming datagrams containing
201 extension headers from the received packet.
202 .B IPV6_RTHDR
203 delivers the routing header,
204 .B IPV6_AUTHHDR
205 delivers the authentication header,
206 .B IPV6_DSTOPTS
207 delivers the destination options,
208 .B IPV6_HOPOPTS
209 delivers the hop options,
210 .B IPV6_FLOWINFO
211 delivers an integer containing the flow ID,
212 .B IPV6_HOPLIMIT
213 delivers an integer containing the hop count of the packet.
214 The control messages have the same type as the socket option.
215 All these header options can also be set for outgoing packets
216 by putting the appropriate control message into the control buffer of
217 .BR sendmsg (2).
218 Only allowed for
219 .B SOCK_DGRAM
220 or
221 .B SOCK_RAW
222 sockets.
223 Argument is a pointer to a boolean value.
224 .TP
225 .B IPV6_RECVERR
226 Control receiving of asynchronous error options.
227 See
228 .B IP_RECVERR
229 in
230 .BR ip (7)
231 for details.
232 Argument is a pointer to boolean.
233 .TP
234 .B IPV6_ROUTER_ALERT
235 Pass forwarded packets containing a router alert hop-by-hop option to
236 this socket.
237 Only allowed for SOCK_RAW sockets.
238 The tapped packets are not forwarded by the kernel, it is the
239 user's responsibility to send them out again.
240 Argument is a pointer to an integer.
241 A positive integer indicates a router alert option value to intercept.
242 Packets carrying a router alert option with a value field containing
243 this integer will be delivered to the socket.
244 A negative integer disables delivery of packets with router alert options
245 to this socket.
246 .TP
247 .B IPV6_UNICAST_HOPS
248 Set the unicast hop limit for the socket.
249 Argument is a pointer to an integer.
250 \-1 in the value means use the route default,
251 otherwise it should be between 0 and 255.
252 .TP
253 .BR IPV6_V6ONLY " (since Linux 2.4.21 and 2.6)"
254 .\" See RFC 3493
255 If this flag is set to true (nonzero), then the socket is restricted
256 to sending and receiving IPv6 packets only.
257 In this case, an IPv4 and an IPv6 application can bind
258 to a single port at the same time.
259
260 If this flag is set to false (zero),
261 then the socket can be used to send and receive packets
262 to and from an IPv6 address or an IPv4-mapped IPv6 address.
263
264 The argument is a pointer to a boolean value in an integer.
265
266 The default value for this flag is defined by the contents of the file
267 .IR /proc/sys/net/ipv6/bindv6only .
268 The default value for that file is 0 (false).
269 .\" FLOWLABEL_MGR, FLOWINFO_SEND
270 .SH ERRORS
271 .\" FIXME document all errors.
272 .TP
273 .B ENODEV
274 The user tried to
275 .BR bind (2)
276 to a link-local IPv6 address, but the
277 .I sin6_scope_id
278 in the supplied
279 .I sockaddr_in6
280 structure is not a valid
281 interface index.
282 .SH VERSIONS
283 The older
284 .I libinet6
285 libc5 based IPv6 API implementation for Linux is not described here
286 and may vary in details.
287 .PP
288 Linux 2.4 will break binary compatibility for the
289 .I sockaddr_in6
290 for 64-bit
291 hosts by changing the alignment of
292 .I in6_addr
293 and adding an additional
294 .I sin6_scope_id
295 field.
296 The kernel interfaces stay compatible, but a program including
297 .I sockaddr_in6
298 or
299 .I in6_addr
300 into other structures may not be.
301 This is not
302 a problem for 32-bit hosts like i386.
303 .PP
304 The
305 .I sin6_flowinfo
306 field is new in Linux 2.4.
307 It is transparently passed/read by the kernel
308 when the passed address length contains it.
309 Some programs that pass a longer address buffer and then
310 check the outgoing address length may break.
311 .SH "NOTES"
312 The
313 .I sockaddr_in6
314 structure is bigger than the generic
315 .IR sockaddr .
316 Programs that assume that all address types can be stored safely in a
317 .I struct sockaddr
318 need to be changed to use
319 .I struct sockaddr_storage
320 for that instead.
321 .SH BUGS
322 The IPv6 extended API as in RFC\ 2292 is currently only partly
323 implemented;
324 although the 2.2 kernel has near complete support for receiving options,
325 the macros for generating IPv6 options are missing in glibc 2.1.
326 .PP
327 IPSec support for EH and AH headers is missing.
328 .PP
329 Flow label management is not complete and not documented here.
330 .PP
331 This man page is not complete.
332 .SH "SEE ALSO"
333 .BR cmsg (3),
334 .BR ip (7)
335 .PP
336 RFC\ 2553: IPv6 BASIC API.
337 Linux tries to be compliant to this.
338 .PP
339 RFC\ 2460: IPv6 specification.