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"
9 ipv6 \- Linux IPv6 protocol implementation
11 .B #include <sys/socket.h>
13 .B #include <netinet/in.h>
15 .IB tcp6_socket " = socket(AF_INET6, SOCK_STREAM, 0);"
17 .IB raw6_socket " = socket(AF_INET6, SOCK_RAW, " protocol ");"
19 .IB udp6_socket " = socket(AF_INET6, SOCK_DGRAM, " protocol ");"
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.
25 is based on the BSD sockets interface; see
28 The IPv6 API aims to be mostly compatible with the
31 Only differences are described in this man page.
35 socket to any process, the local address should be copied from the
40 In static initializations,
42 may also be used, which expands to a constant expression.
43 Both of them are in network byte order.
45 The IPv6 loopback address (::1) is available in the global
49 .B IN6ADDR_LOOPBACK_INIT
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.
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.
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) */
75 unsigned char s6_addr[16]; /* IPv6 address */
84 is the protocol port (see
89 is the IPv6 flow identifier;
91 is the 128-bit IPv6 address.
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
97 contains the interface index (see
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.
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.
112 The port space of IPv6 is shared with IPv4.
114 IPv6 supports some protocol-specific socket options that can be set with
118 The socket option level for IPv6 is
120 A boolean integer flag is zero when it is false, otherwise true.
125 socket into a socket of a different address family.
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
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.
136 .B IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP
137 Control membership in multicast groups.
138 Argument is a pointer to a
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
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.
156 Control path-MTU discovery on the socket.
163 .B IPV6_MULTICAST_HOPS
164 Set the multicast hop limit for the socket.
165 Argument is a pointer to an
167 \-1 in the value means use the route default, otherwise it should be
171 Set the device for outgoing multicast packets on the socket.
178 The argument is a pointer to an interface index (see
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.
189 control message on incoming datagrams.
195 Argument is a pointer to a boolean value in an integer.
198 .B IPV6_RTHDR, IPV6_AUTHHDR, IPV6_DSTOPTS, IPV6_HOPOPTS, IPV6_FLOWINFO, IPV6_HOPLIMIT
200 Set delivery of control messages for incoming datagrams containing
201 extension headers from the received packet.
203 delivers the routing header,
205 delivers the authentication header,
207 delivers the destination options,
209 delivers the hop options,
211 delivers an integer containing the flow ID,
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
223 Argument is a pointer to a boolean value.
226 Control receiving of asynchronous error options.
232 Argument is a pointer to boolean.
235 Pass forwarded packets containing a router alert hop-by-hop option to
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
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.
253 .BR IPV6_V6ONLY " (since Linux 2.4.21 and 2.6)"
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.
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.
264 The argument is a pointer to a boolean value in an integer.
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
271 .\" FIXME document all errors.
276 to a link-local IPv6 address, but the
280 structure is not a valid
285 libc5 based IPv6 API implementation for Linux is not described here
286 and may vary in details.
288 Linux 2.4 will break binary compatibility for the
291 hosts by changing the alignment of
293 and adding an additional
296 The kernel interfaces stay compatible, but a program including
300 into other structures may not be.
302 a problem for 32-bit hosts like i386.
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.
314 structure is bigger than the generic
316 Programs that assume that all address types can be stored safely in a
318 need to be changed to use
319 .I struct sockaddr_storage
322 The IPv6 extended API as in RFC\ 2292 is currently only partly
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.
327 IPSec support for EH and AH headers is missing.
329 Flow label management is not complete and not documented here.
331 This man page is not complete.
336 RFC\ 2553: IPv6 BASIC API.
337 Linux tries to be compliant to this.
339 RFC\ 2460: IPv6 specification.