version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
IPV6 |
|
|
2 |
!!!IPV6 |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
ADDRESS FORMAT |
|
|
7 |
SOCKET OPTIONS |
|
|
8 |
VERSIONS |
|
|
9 |
PORTING NOTES |
|
|
10 |
BUGS |
|
|
11 |
SEE ALSO |
|
|
12 |
---- |
|
|
13 |
!!NAME |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
ipv6, PF_INET6 - Linux IPv6 protocol implementation |
|
|
17 |
!!SYNOPSIS |
|
|
18 |
|
|
|
19 |
|
|
|
20 |
__#include __ |
|
|
21 |
#include __ |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
''tcp6_socket'' __= socket(PF_INET6, SOCK_STREAM, |
|
|
25 |
0);__'' |
|
|
26 |
raw6_socket'' __= socket(PF_INET6, SOCK_RAW,__ |
|
|
27 |
''protocol''__);__'' |
|
|
28 |
udp6_socket'' __= socket(PF_INET6, SOCK_DGRAM,__ |
|
|
29 |
''protocol''__);__ |
|
|
30 |
!!DESCRIPTION |
|
|
31 |
|
|
|
32 |
|
|
|
33 |
Linux 2.2 optionally implements the Internet Protocol, |
|
|
34 |
version 6. This man page contains a description of the IPv6 |
|
|
35 |
basic API as implemented by the Linux kernel and glibc 2.1. |
|
|
36 |
The interface is based on the BSD sockets interface; see |
|
|
37 |
socket(7). |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
The IPv6 API aims to be mostly compatible with the |
|
|
41 |
ip(7) v4 API. Only differences are described in this |
|
|
42 |
man page. |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
To bind an ''AF_INET6'' socket to any process the local |
|
|
46 |
address should be copied from the __in6addr_any__ |
|
|
47 |
variable which has ''in6_addr'' type. In static |
|
|
48 |
initializations __IN6ADDR_ANY_INIT__ may also be used, |
|
|
49 |
which expands to a constant expression. Both of them are in |
|
|
50 |
network order. |
|
|
51 |
|
|
|
52 |
|
|
|
53 |
The IPv6 loopback address (::1) is available in the global |
|
|
54 |
__in6addr_loopback__ variable. For initializations |
|
|
55 |
__IN6ADDR_LOOPBACK_INIT__ should be used. |
|
|
56 |
|
|
|
57 |
|
|
|
58 |
IPv4 connections can be handled with the v6 API by using the |
|
|
59 |
v4-mapped-on-v6 address type; thus a program only needs only |
|
|
60 |
to support this API type to support both protocols. This is |
|
|
61 |
handled transparently by the address handling functions in |
|
|
62 |
libc. |
|
|
63 |
|
|
|
64 |
|
|
|
65 |
IPv4 and IPv6 share the local port space. When you get an |
|
|
66 |
IPv4 connection or packet to a IPv6 socket its source |
|
|
67 |
address will be mapped to v6 and it'll be mapped to |
|
|
68 |
v6. |
|
|
69 |
!!ADDRESS FORMAT |
|
|
70 |
|
|
|
71 |
|
|
|
72 |
struct sockaddr_in6 { |
|
|
73 |
u_int16_t sin6_family;/* AF_INET6 */ |
|
|
74 |
u_int16_t sin6_port;/* port number */ |
|
|
75 |
u_int32_t sin6_flowinfo;/* IPv6 flow information */ |
|
|
76 |
struct in6_addr sin6_addr;/* IPv6 address */ |
|
|
77 |
u_int32_t sin6_scope_id; /* Scope id (new in 2.4) */ |
|
|
78 |
}; |
|
|
79 |
struct in6_addr { |
|
|
80 |
unsigned char s6_addr[[16];/* IPv6 address */ |
|
|
81 |
}; |
|
|
82 |
|
|
|
83 |
|
|
|
84 |
__sin6_family__ is always set to __AF_INET6; |
|
|
85 |
sin6_port__ is the protocol port (see __sin_port__ in |
|
|
86 |
ip(7)); __sin6_flowinfo__ is the IPv6 flow |
|
|
87 |
identifier; __sin6_addr__ is the 128bit IPv6 address. |
|
|
88 |
__sin6_scope_id__ is an id of depending of on the scope |
|
|
89 |
of the address. It is new in Linux 2.4. Linux only supports |
|
|
90 |
it for link scope addresses, in that case |
|
|
91 |
''sin6_scope_id'' contains the interface index (see |
|
|
92 |
netdevice(7)) |
|
|
93 |
|
|
|
94 |
|
|
|
95 |
IPv6 supports several address types: unicast to address a |
|
|
96 |
single host, multicast to address a group of hosts, anycast |
|
|
97 |
to address the nearest member of a group of hosts (not |
|
|
98 |
implemented in Linux), IPv4-on-IPv6 to address a IPv4 host, |
|
|
99 |
and other reserved address types. |
|
|
100 |
|
|
|
101 |
|
|
|
102 |
The address notation for IPv6 is a group of 16 2 digit |
|
|
103 |
hexadecimal numbers, separated with a ':'. '::' stands for a |
|
|
104 |
string of 0 bits. Special addresses are ::1 for loopback and |
|
|
105 |
FFFF:: |
|
|
106 |
|
|
|
107 |
|
|
|
108 |
The port space of IPv6 is shared with IPv4. |
|
|
109 |
!!SOCKET OPTIONS |
|
|
110 |
|
|
|
111 |
|
|
|
112 |
IPv6 supports some protocol specific socket options that can |
|
|
113 |
be set with setsockopt(2) and read with |
|
|
114 |
getsockopt(2). The socket option level for IPv6 is |
|
|
115 |
__IPPROTO_IPV6__. A boolean integer flag is zero when it |
|
|
116 |
is false, otherwise true. |
|
|
117 |
|
|
|
118 |
|
|
|
119 |
__IPV6_UNICAST_HOPS__ |
|
|
120 |
|
|
|
121 |
|
|
|
122 |
Set the unicast hop limit for the socket. Argument is an |
|
|
123 |
pointer to an integer. -1 in the value means use the route |
|
|
124 |
default, otherwise it should be between 0 and |
|
|
125 |
255. |
|
|
126 |
|
|
|
127 |
|
|
|
128 |
__IPV6_MULTICAST_HOPS__ |
|
|
129 |
|
|
|
130 |
|
|
|
131 |
Set the multicast hop limit for the socket. Argument is a |
|
|
132 |
pointer to an integer. -1 in the value means use the route |
|
|
133 |
default, otherwise it should be between 0 and |
|
|
134 |
255. |
|
|
135 |
|
|
|
136 |
|
|
|
137 |
__IPV6_MULTICAST_IF__ |
|
|
138 |
|
|
|
139 |
|
|
|
140 |
Set the device for outgoing multicast packets on the socket. |
|
|
141 |
This is only allowed for ''SOCK_DGRAM'' and |
|
|
142 |
''SOCK_RAW'' socket. The argument is an pointer to an |
|
|
143 |
interface index (see netdevice(7)) in an |
|
|
144 |
integer. |
|
|
145 |
|
|
|
146 |
|
|
|
147 |
__IPV6_ADDRFORM__ |
|
|
148 |
|
|
|
149 |
|
|
|
150 |
Turn an ''AF_INET6'' socket into a socket of a different |
|
|
151 |
address family. Only ''AF_INET'' is currently supported |
|
|
152 |
for that. It is only allowed for IPv6 sockets that are |
|
|
153 |
connected and bound to a v4-mapped-on-v6 address. The |
|
|
154 |
argument is a pointer to a integer containing |
|
|
155 |
__AF_INET.__ This is useful to pass v4-mapped sockets as |
|
|
156 |
filedescriptors to programs that don't know how to deal with |
|
|
157 |
the IPv6 API. |
|
|
158 |
|
|
|
159 |
|
|
|
160 |
__IPV6_PKTINFO__ |
|
|
161 |
|
|
|
162 |
|
|
|
163 |
Set delivery of the __IPV6_PKTINFO__ control message on |
|
|
164 |
incoming datagrams. Only allowed for __SOCK_DGRAM__ or |
|
|
165 |
__SOCK_RAW__ sockets. Argument is a pointer to a boolean |
|
|
166 |
value in an integer. |
|
|
167 |
|
|
|
168 |
|
|
|
169 |
__IPV6_RTHDR, IPV6_AUTHHDR, IPV6_DSTOPS, IPV6_HOPOPTS, |
|
|
170 |
IPV6_FLOWINFO, IPV6_HOPLIMIT__ |
|
|
171 |
|
|
|
172 |
|
|
|
173 |
Set delivery of control messages for incoming data- grams |
|
|
174 |
containing extension headers from the re- ceived packet. |
|
|
175 |
''IPV6_RTHDR'' delivers the routing header, |
|
|
176 |
''IPV6_AUTHHDR'' delivers the authentication header, |
|
|
177 |
''IPV6_DSTOPTS'' delivers the destination op- tions, |
|
|
178 |
''IPV6_HOPOPTS'' delivers the hop options, |
|
|
179 |
''IPV6_FLOWINFO'' delivers an integer containing the flow |
|
|
180 |
id, ''IPV6_HOPLIMIT'' delivers an integer contain- ing |
|
|
181 |
the hop count of the packet. The control mes- sages have the |
|
|
182 |
same type as the socket option. All these header options can |
|
|
183 |
also be set for outgoing packets by putting the appropriate |
|
|
184 |
control message into the control buffer of |
|
|
185 |
sendmsg(2). Only al- lowed for __SOCK_DGRAM__ or |
|
|
186 |
__SOCK_RAW__ sockets. Argument is a pointer to a boolean |
|
|
187 |
value. |
|
|
188 |
|
|
|
189 |
|
|
|
190 |
__IPV6_MULTICAST_LOOP__ |
|
|
191 |
|
|
|
192 |
|
|
|
193 |
Control whether the socket sees multicast packets that is |
|
|
194 |
has send itself. Argument is a pointer to |
|
|
195 |
boolean. |
|
|
196 |
|
|
|
197 |
|
|
|
198 |
__IPV6_ADD_MEMBERSHIP, |
|
|
199 |
IPV6_DROP_MEMBERSHIP__ |
|
|
200 |
|
|
|
201 |
|
|
|
202 |
Control membership in multicast groups. Argument is a |
|
|
203 |
pointer to a __struct ipv6_mreq__ structure. |
|
|
204 |
|
|
|
205 |
|
|
|
206 |
__IPV6_MTU__ |
|
|
207 |
|
|
|
208 |
|
|
|
209 |
Set the MTU to be used for the socket. The MTU is limited by |
|
|
210 |
the device MTU or the path mtu when path mtu discovery is |
|
|
211 |
enabled. Argument is a pointer to integer. |
|
|
212 |
|
|
|
213 |
|
|
|
214 |
__IPV6_MTU_DISCOVER__ |
|
|
215 |
|
|
|
216 |
|
|
|
217 |
Control path mtu discovery on the socket. See |
|
|
218 |
''IP_MTU_DISCOVER'' in ip(7) for |
|
|
219 |
details. |
|
|
220 |
|
|
|
221 |
|
|
|
222 |
__IPV6_RECVERR__ |
|
|
223 |
|
|
|
224 |
|
|
|
225 |
Control receiving of asynchronous error options. See |
|
|
226 |
''IP_RECVERR'' in ip(7) for details. Argument is a |
|
|
227 |
pointer to boolean. |
|
|
228 |
|
|
|
229 |
|
|
|
230 |
__IPV6_ROUTER_ALERT__ |
|
|
231 |
|
|
|
232 |
|
|
|
233 |
Pass all forwarded packets containing an router alert option |
|
|
234 |
to this socket. Only allowed for datagram sockets and for |
|
|
235 |
root. Argument is a point- er to boolean. |
|
|
236 |
!!VERSIONS |
|
|
237 |
|
|
|
238 |
|
|
|
239 |
The older ''libinet6'' libc5 based IPv6 API |
|
|
240 |
implementation for Linux is not described here and may vary |
|
|
241 |
in details. |
|
|
242 |
|
|
|
243 |
|
|
|
244 |
Linux 2.4 will break binary compatibility for the sockad- |
|
|
245 |
dr_in6 for 64bit hosts by changing the alignment of |
|
|
246 |
''in6_addr'' and adding an additional |
|
|
247 |
''sin6_scope_id'' field. The kernel interfaces stay |
|
|
248 |
compatible, but a program including sockaddr_in6 or in6_addr |
|
|
249 |
into other structures may not be. This is not a problem for |
|
|
250 |
32bit hosts like i386. |
|
|
251 |
|
|
|
252 |
|
|
|
253 |
The __sin6_flowinfo__ field is new in Linux 2.4. It is |
|
|
254 |
trans- parently passed/read by the kernel when the passed |
|
|
255 |
address length contains it. Some programs that pass a longer |
|
|
256 |
ad- dress buffer and then check the outgoing address length |
|
|
257 |
may break. |
|
|
258 |
!!PORTING NOTES |
|
|
259 |
|
|
|
260 |
|
|
|
261 |
The __sockaddr_in6__ structure is bigger than the generic |
|
|
262 |
__sockaddr.__ Programs that assume that all address types |
|
|
263 |
can be stored safely in a __struct sockaddr__ need to be |
|
|
264 |
changed to use __struct sockaddr_storage__ for that |
|
|
265 |
instead. |
|
|
266 |
!!BUGS |
|
|
267 |
|
|
|
268 |
|
|
|
269 |
The IPv6 extended API as in RFC2292 is currently only partly |
|
|
270 |
implemented; although the 2.2 kernel has near com- plete |
|
|
271 |
support for receiving options, the macros for gener- ating |
|
|
272 |
IPv6 options are missing in glibc 2.1. |
|
|
273 |
|
|
|
274 |
|
|
|
275 |
IPSec support for EH and AH headers is missing. |
|
|
276 |
|
|
|
277 |
|
|
|
278 |
Flow label management is not complete and not documented |
|
|
279 |
here. |
|
|
280 |
|
|
|
281 |
|
|
|
282 |
This man page is not complete. |
|
|
283 |
!!SEE ALSO |
|
|
284 |
|
|
|
285 |
|
|
|
286 |
ip(7), cmsg(3) |
|
|
287 |
|
|
|
288 |
|
|
|
289 |
RFC2553: IPv6 BASIC API. Linux tries to be compliant to |
|
|
290 |
this. |
|
|
291 |
|
|
|
292 |
|
|
|
293 |
RFC2460: IPv6 specification. |
|
|
294 |
---- |