]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man7/ipv6.7
s/u_long/unsigned long/
[thirdparty/man-pages.git] / 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 2007-10-14 "Linux" "Linux Programmer's Manual"
8 .SH NAME
9 ipv6, PF_INET6 \- 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(PF_INET6, SOCK_STREAM, 0);"
16 .br
17 .IB raw6_socket " = socket(PF_INET6, SOCK_RAW, " protocol ");"
18 .br
19 .IB udp6_socket " = socket(PF_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 .BR ip (7)
30 v4 API.
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 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 only to support this API type to
55 support both protocols.
56 This is handled transparently by the address
57 handling functions in libc.
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 .sp
65 .in +4n
66 .nf
67 struct sockaddr_in6 {
68 uint16_t sin6_family; /* AF_INET6 */
69 uint16_t sin6_port; /* port number */
70 uint32_t sin6_flowinfo; /* IPv6 flow information */
71 struct in6_addr sin6_addr; /* IPv6 address */
72 uint32_t sin6_scope_id; /* Scope ID (new in 2.4) */
73 };
74
75 struct in6_addr {
76 unsigned char s6_addr[16]; /* IPv6 address */
77 };
78 .fi
79 .in
80 .sp
81 .I sin6_family
82 is always set to
83 .BR AF_INET6 ;
84 .I sin6_port
85 is the protocol port (see
86 .I sin_port
87 in
88 .BR ip (7));
89 .I sin6_flowinfo
90 is the IPv6 flow identifier;
91 .I sin6_addr
92 is the 128-bit IPv6 address.
93 .I sin6_scope_id
94 is an ID of depending of on the scope of the address.
95 It is new in Linux 2.4.
96 Linux only supports it for link scope addresses, in that case
97 .I sin6_scope_id
98 contains the interface index (see
99 .BR netdevice (7))
100 .PP
101 IPv6 supports several address types: unicast to address a single
102 host, multicast to address a group of hosts,
103 anycast to address the nearest member of a group of hosts
104 (not implemented in Linux), IPv4-on-IPv6 to
105 address a IPv4 host, and other reserved address types.
106 .PP
107 The address notation for IPv6 is a group of 16 2 digit hexadecimal
108 numbers, separated with a ':'. '::' 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 a 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_V6ONLY is not documented, and probably should be
145 .\" FIXME IPV6_RECVPKTINFO is not documented, and probably should be
146 .\" FIXME IPV6_2292PKTINFO is not documented, and probably should be
147 .\" FIXME there are probably many other IPV6_* socket options that
148 .\" should be documented
149 .TP
150 .B IPV6_MTU
151 Set the MTU to be used for the socket.
152 The MTU is limited by the device
153 MTU or the path mtu when path mtu discovery is enabled.
154 Argument is a pointer to integer.
155 .TP
156 .B IPV6_MTU_DISCOVER
157 Control path mtu discovery on the socket.
158 See
159 .B IP_MTU_DISCOVER
160 in
161 .BR ip (7)
162 for details.
163 .TP
164 .B IPV6_MULTICAST_HOPS
165 Set the multicast hop limit for the socket.
166 Argument is a pointer to an
167 integer.
168 \-1 in the value means use the route default, otherwise it should be
169 between 0 and 255.
170 .TP
171 .B IPV6_MULTICAST_IF
172 Set the device for outgoing multicast packets on the socket.
173 This is only allowed
174 for
175 .B SOCK_DGRAM
176 and
177 .B SOCK_RAW
178 socket.
179 The argument is a pointer to an interface index (see
180 .BR netdevice (7))
181 in an integer.
182 .TP
183 .B IPV6_MULTICAST_LOOP
184 Control whether the socket sees multicast packets that it has send itself.
185 Argument is a pointer to boolean.
186 .TP
187 .B IPV6_PKTINFO
188 Set delivery of the
189 .B IPV6_PKTINFO
190 control message on incoming datagrams.
191 Only allowed for
192 .B SOCK_DGRAM
193 or
194 .B SOCK_RAW
195 sockets.
196 Argument is a pointer to a boolean value in an integer.
197 .TP
198 .nh
199 .B IPV6_RTHDR, IPV6_AUTHHDR, IPV6_DSTOPS, IPV6_HOPOPTS, IPV6_FLOWINFO, IPV6_HOPLIMIT
200 .hy
201 Set delivery of control messages for incoming datagrams containing
202 extension headers from the received packet.
203 .B IPV6_RTHDR
204 delivers the routing header,
205 .B IPV6_AUTHHDR
206 delivers the authentication header,
207 .B IPV6_DSTOPTS
208 delivers the destination options,
209 .B IPV6_HOPOPTS
210 delivers the hop options,
211 .B IPV6_FLOWINFO
212 delivers an integer containing the flow ID,
213 .B IPV6_HOPLIMIT
214 delivers an integer containing the hop count of the packet.
215 The control messages have the same type as the socket option.
216 All these header options can also be set for outgoing packets
217 by putting the appropriate control message into the control buffer of
218 .BR sendmsg (2).
219 Only allowed for
220 .B SOCK_DGRAM
221 or
222 .B SOCK_RAW
223 sockets.
224 Argument is a pointer to a boolean value.
225 .TP
226 .B IPV6_RECVERR
227 Control receiving of asynchronous error options.
228 See
229 .B IP_RECVERR
230 in
231 .BR ip (7)
232 for details.
233 Argument is a pointer to boolean.
234 .TP
235 .B IPV6_ROUTER_ALERT
236 Pass forwarded packets containing a router alert hop-by-hop option to
237 this socket.
238 Only allowed for SOCK_RAW sockets.
239 The tapped packets are not forwarded by the kernel, it is the
240 user's responsibility to send them out again.
241 Argument is a pointer to an integer.
242 A positive integer indicates a router alert option value to intercept.
243 Packets carrying a router alert option with a value field containing
244 this integer will be delivered to the socket.
245 A negative integer disables delivery of packets with router alert options
246 to this socket.
247 .TP
248 .B IPV6_UNICAST_HOPS
249 Set the unicast hop limit for the socket.
250 Argument is an pointer to an integer.
251 \-1 in the value means use the route default,
252 otherwise it should be between 0 and 255.
253 .\" FLOWLABEL_MGR, FLOWINFO_SEND
254 .SH VERSIONS
255 The older
256 .I libinet6
257 libc5 based IPv6 API implementation for Linux is not described here
258 and may vary in details.
259 .PP
260 Linux 2.4 will break binary compatibility for the
261 .I sockaddr_in6
262 for 64-bit
263 hosts by changing the alignment of
264 .I in6_addr
265 and adding an additional
266 .I sin6_scope_id
267 field.
268 The kernel interfaces stay compatible, but a program including
269 .I sockaddr_in6
270 or
271 .I in6_addr
272 into other structures may not be.
273 This is not
274 a problem for 32-bit hosts like i386.
275 .PP
276 The
277 .I sin6_flowinfo
278 field is new in Linux 2.4.
279 It is transparently passed/read by the kernel
280 when the passed address length contains it.
281 Some programs that pass a longer address buffer and then
282 check the outgoing address length may break.
283 .SH "NOTES"
284 The
285 .I sockaddr_in6
286 structure is bigger than the generic
287 .IR sockaddr .
288 Programs that assume that all address types can be stored safely in a
289 .I struct sockaddr
290 need to be changed to use
291 .I struct sockaddr_storage
292 for that instead.
293 .SH BUGS
294 The IPv6 extended API as in RFC\ 2292 is currently only partly
295 implemented;
296 although the 2.2 kernel has near complete support for receiving options,
297 the macros for generating IPv6 options are missing in glibc 2.1.
298 .PP
299 IPSec support for EH and AH headers is missing.
300 .PP
301 Flow label management is not complete and not documented here.
302 .PP
303 This man page is not complete.
304 .SH "SEE ALSO"
305 .BR cmsg (3),
306 .BR ip (7)
307 .PP
308 RFC\ 2553: IPv6 BASIC API.
309 Linux tries to be compliant to this.
310 .PP
311 RFC\ 2460: IPv6 specification.