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"
9 ipv6, PF_INET6 \- Linux IPv6 protocol implementation
11 .B #include <sys/socket.h>
13 .B #include <netinet/in.h>
15 .IB tcp6_socket " = socket(PF_INET6, SOCK_STREAM, 0);"
17 .IB raw6_socket " = socket(PF_INET6, SOCK_RAW, " protocol ");"
19 .IB udp6_socket " = socket(PF_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 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 only to support this API type to
55 support both protocols.
56 This is handled transparently by the address
57 handling functions in libc.
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.
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) */
76 unsigned char s6_addr[16]; /* IPv6 address */
85 is the protocol port (see
90 is the IPv6 flow identifier;
92 is the 128-bit IPv6 address.
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
98 contains the interface index (see
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.
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.
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 a 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_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
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.
157 Control path mtu discovery on the socket.
164 .B IPV6_MULTICAST_HOPS
165 Set the multicast hop limit for the socket.
166 Argument is a pointer to an
168 \-1 in the value means use the route default, otherwise it should be
172 Set the device for outgoing multicast packets on the socket.
179 The argument is a pointer to an interface index (see
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.
190 control message on incoming datagrams.
196 Argument is a pointer to a boolean value in an integer.
199 .B IPV6_RTHDR, IPV6_AUTHHDR, IPV6_DSTOPS, IPV6_HOPOPTS, IPV6_FLOWINFO, IPV6_HOPLIMIT
201 Set delivery of control messages for incoming datagrams containing
202 extension headers from the received packet.
204 delivers the routing header,
206 delivers the authentication header,
208 delivers the destination options,
210 delivers the hop options,
212 delivers an integer containing the flow ID,
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
224 Argument is a pointer to a boolean value.
227 Control receiving of asynchronous error options.
233 Argument is a pointer to boolean.
236 Pass forwarded packets containing a router alert hop-by-hop option to
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
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
257 libc5 based IPv6 API implementation for Linux is not described here
258 and may vary in details.
260 Linux 2.4 will break binary compatibility for the
263 hosts by changing the alignment of
265 and adding an additional
268 The kernel interfaces stay compatible, but a program including
272 into other structures may not be.
274 a problem for 32-bit hosts like i386.
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.
286 structure is bigger than the generic
288 Programs that assume that all address types can be stored safely in a
290 need to be changed to use
291 .I struct sockaddr_storage
294 The IPv6 extended API as in RFC\ 2292 is currently only partly
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.
299 IPSec support for EH and AH headers is missing.
301 Flow label management is not complete and not documented here.
303 This man page is not complete.
308 RFC\ 2553: IPv6 BASIC API.
309 Linux tries to be compliant to this.
311 RFC\ 2460: IPv6 specification.