Debian Codegraph @

upstream/debian-unstable/man7/ipv6.7

raw
1 .\" Copyright 2000, Andi Kleen <[email protected]>
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-1-para
5 .\"
6 .TH ipv6 7 2026-02-08 "Linux man-pages 6.18"
7 .SH NAME
8 ipv6 \- Linux IPv6 protocol implementation
9 .SH SYNOPSIS
10 .nf
11 .B #include <sys/socket.h>
12 .B #include <netinet/in.h>
13 .P
14 .IB tcp6_socket " = socket(AF_INET6, SOCK_STREAM, 0);"
15 .IB raw6_socket " = socket(AF_INET6, SOCK_RAW, " protocol ");"
16 .IB udp6_socket " = socket(AF_INET6, SOCK_DGRAM, " protocol ");"
17 .fi
18 .SH DESCRIPTION
19 Linux 2.2 optionally implements the Internet Protocol, version 6.
20 This man page contains a description of the IPv6 basic API
21 as implemented by the Linux kernel and glibc 2.1.
22 The interface is based on the BSD sockets interface;
23 see
24 .BR socket (7).
25 .P
26 The IPv6 API aims to be mostly compatible with the
27 IPv4 API (see
28 .BR ip (7)).
29 Only differences are described in this man page.
30 .P
31 To bind an
32 .B AF_INET6
33 socket to any process,
34 the local address should be copied from the
35 .I in6addr_any
36 variable which has
37 .I in6_addr
38 type.
39 In static initializations,
40 .B IN6ADDR_ANY_INIT
41 may also be used,
42 which expands to a constant expression.
43 Both of them are in network byte order.
44 .P
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 .P
52 IPv4 connections can be handled with the v6 API
53 by using the v4-mapped-on-v6 address type;
54 thus a program needs to support only this API type
55 to support both protocols.
56 This is handled transparently
57 by the address handling functions in the C library.
58 .P
59 IPv4 and IPv6 share the local port space.
60 When you get an IPv4 connection
61 or packet to an IPv6 socket,
62 its source address will be mapped to v6.
63 .SS Address format
64 .in +4n
65 .EX
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 Linux 2.4) */
72 };
73 \&
74 struct in6_addr {
75 unsigned char s6_addr[16]; /* IPv6 address */
76 };
77 .EE
78 .in
79 .P
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 supports it only for link-local addresses, in that case
96 .I sin6_scope_id
97 contains the interface index (see
98 .BR netdevice (7))
99 .P
100 IPv6 supports several address types: unicast to address a single host,
101 multicast to address a group of hosts,
102 anycast to address the nearest member of a group of hosts
103 (not implemented in Linux),
104 IPv4-on-IPv6 to address an IPv4 host,
105 and other reserved address types.
106 .P
107 The address notation for IPv6 is a group of 8 4-digit hexadecimal numbers,
108 separated with a \[aq]:\[aq].
109 \&"::" stands for a string of 0 bits.
110 Special addresses are ::1 for loopback and ::FFFF:<IPv4 address>
111 for IPv4-mapped-on-IPv6.
112 .P
113 The port space of IPv6 is shared with IPv4.
114 .SS Socket options
115 See
116 .BR IPPROTO_IPV6 (2const).
117 .SH ERRORS
118 .TP
119 .B ENODEV
120 The user tried to
121 .BR bind (2)
122 to a link-local IPv6 address, but the
123 .I sin6_scope_id
124 in the supplied
125 .I sockaddr_in6
126 structure is not a valid
127 interface index.
128 .SH VERSIONS
129 Linux 2.4 will break binary compatibility for the
130 .I sockaddr_in6
131 for 64-bit
132 hosts by changing the alignment of
133 .I in6_addr
134 and adding an additional
135 .I sin6_scope_id
136 field.
137 The kernel interfaces stay compatible, but a program including
138 .I sockaddr_in6
139 or
140 .I in6_addr
141 into other structures may not be.
142 This is not
143 a problem for 32-bit hosts like i386.
144 .P
145 The
146 .I sin6_flowinfo
147 field is new in Linux 2.4.
148 It is transparently passed/read by the kernel
149 when the passed address length contains it.
150 Some programs that pass a longer address buffer and then
151 check the outgoing address length may break.
152 .SH NOTES
153 The
154 .I sockaddr_in6
155 structure is bigger than the generic
156 .IR sockaddr .
157 Programs that assume that all address types can be stored safely in a
158 .I struct sockaddr
159 need to be changed to use
160 .I struct sockaddr_storage
161 for that instead.
162 .P
163 .BR SOL_IP ,
164 .BR SOL_IPV6 ,
165 .BR SOL_ICMPV6 ,
166 and other
167 .B SOL_*
168 socket options are nonportable variants of
169 .BR IPPROTO_* .
170 See also
171 .BR ip (7).
172 .SH BUGS
173 The IPv6 extended API as in RFC\ 2292 is currently only partly
174 implemented;
175 although the 2.2 kernel has near complete support for receiving options,
176 the macros for generating IPv6 options are missing in glibc 2.1.
177 .P
178 IPSec support for EH and AH headers is missing.
179 .P
180 Flow label management is not complete and not documented here.
181 .P
182 This man page is not complete.
183 .SH SEE ALSO
184 .BR IPPROTO_IPV6 (2const),
185 .BR ip (7)
186 .P
187 RFC\ 2553: IPv6 BASIC API;
188 Linux tries to be compliant to this.
189 RFC\ 2460: IPv6 specification.