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