1ip6(7P) Protocols ip6(7P)
2
3
4
6 ip6 - Internet Protocol Version 6
7
9 #include <sys/socket.h>
10 #include <netinet/in.h>
11 #include <netinet/ip6.h>
12
13
14 s = socket(AF_INET6, SOCK_RAW, proto);
15
16
17 t = t_open ("/dev/rawip6", O_RDWR);
18
19
21 The IPv6 protocol is the next generation of the internetwork datagram
22 delivery protocol of the Internet protocol family. Programs may use
23 IPv6 through higher-level protocols such as the Transmission Control
24 Protocol (TCP) or the User Datagram Protocol (UDP), or may interface
25 directly to IPv6. See tcp(7P) and udp(7P). Direct access may be by
26 means of the socket interface, using a "raw socket," or by means of the
27 Transport Level Interface (TLI). The protocol options and IPv6 exten‐
28 sion headers defined in the IPv6 specification may be set in outgoing
29 datagrams.
30
32 The STREAMS driver /dev/rawip6 is the TLI transport provider that pro‐
33 vides raw access to IPv6.
34
35
36 Raw IPv6 sockets are connectionless and are normally used with the
37 sendto() and recvfrom() calls (see send(3SOCKET) and recv(3SOCKET)),
38 although the connect(3SOCKET) call may also be used to fix the destina‐
39 tion for future datagrams. In this case, the read(2) or recv(3SOCKET)
40 and write(2) or send(3SOCKET) calls may be used. Ancillary data may
41 also be sent or received over raw IPv6 sockets using the
42 sendmsg(3SOCKET) and recvmsg(3SOCKET) system calls.
43
44
45 Unlike raw IP, IPv6 applications do not include a complete IPv6 header
46 when sending; there is no IPv6 analog to the IP IP_HDRINCL socket
47 option. IPv6 header values may be specified or received as ancillary
48 data to a sendmsg(3SOCKET) or recvmsg(3SOCKET) system call, or may be
49 specified as "sticky" options on a per-socket basis by using the set‐
50 sockopt(3SOCKET) system call. Such sticky options are applied to all
51 outbound packets unless overridden by ancillary data. If any ancillary
52 data is specified in a sendmsg(3SOCKET) call, all sticky options not
53 explicitly overridden revert to default values for that datagram only;
54 the sticky options persist as set for subsequent datagrams.
55
56
57 Since sendmsg(3SOCKET) is not supported for SOCK_STREAM upper level
58 protocols such as TCP, ancillary data is unsupported for TCP. Sticky
59 options, however, are supported.
60
61
62 Since sendmsg(3SOCKET) is supported for SOCK_DGRAM upper level proto‐
63 cols, both ancillary data and sticky options are supported for UDP,
64 ICMP6, and raw IPv6 sockets.
65
66
67 The socket options supported at the IPv6 level are:
68
69 IPV6_BOUND_IF Limit reception and transmission of packets to
70 this interface. Takes an integer as an argu‐
71 ment; the integer is the selected interace
72 index.
73
74
75 IPV6_UNSPEC_SRC Boolean. Allow/disallow sending with a zero
76 source address.
77
78
79 IPV6_UNICAST_HOPS Default hop limit for unicast datagrams. This
80 option takes an integer as an argument. Its
81 value becomes the new default value for
82 ip6_hops that IPv6 will use on outgoing unicast
83 datagrams sent from that socket. The initial
84 default is 60.
85
86
87 IPV6_CHECKSUM Specify the integer offset in bytes into the
88 user data of the checksum location. Does not
89 apply to the ICMP6 protocol. Note: checksums
90 are required for all IPv6 datagrams; this is
91 different from IP, in which datagram checksums
92 were optional. IPv6 will compute the ULP check‐
93 sum if the value in the checksum field is zero.
94
95
96 IPV6_SEC_OPT Enable or obtain IPsec security settings for
97 this socket. For more details on the protection
98 services of IPsec, see ipsec(7P).
99
100
101 IPV6_DONTFRAG Boolean. Control fragmentation.
102
103
104 IPV6_USE_MIN_MTU Controls whether path MTU discovery is used. If
105 set to 1, path MTU discovery is never used and
106 IPv6 packets are sent with the IPv6 minimum
107 MTU. If set to -1, path MTU discovery is not
108 used for multicast and multicast packets are
109 sent with the IPv6 minimum MTU. If set to 0,
110 path MTU is always performed.
111
112
113 IPV6_V6ONLY Boolean. If set, only V6 packets can be sent or
114 received
115
116
117 IPV6_SRC_PREFERENCES Enable or obtain Source Address Selection rule
118 settings for this socket. For more details on
119 the Source Address Selection rules, see
120 inet6(7P).
121
122
123
124 The following options are boolean switches controlling the reception of
125 ancillary data:
126
127 IPV6_RECVPKTINFO Enable/disable receipt of the index of the
128 interface the packet arrived on, and of the
129 inbound packet's destination address.
130
131
132 IPV6_RECVHOPLIMIT Enable/disable receipt of the inbound packet's
133 current hoplimit.
134
135
136 IPV6_RECVHOPOPTS Enable/disable receipt of the inbound packet's
137 IPv6 hop-by-hop extension header.
138
139
140 IPV6_RECVDSTOPTS Enable/disable receipt of the inbound packet's
141 IPv6 destination options extension header.
142
143
144 IPV6_RECVRTHDR Enable/disable receipt of the inbound packet's
145 IPv6 routing header.
146
147
148 IPV6_RECVRTHDRDSTOPTS Enable/disable receipt of the inbound packet's
149 intermediate-hops options extension header.
150 This option is obsolete. IPV6_RECVDSTOPTS
151 turns on receipt of both destination option
152 headers.
153
154
155 IPV6_RECVTCLASS Enable/disable receipt of the traffic class of
156 the inbound packet.
157
158
159 IPV6_RECVPATHMTU Enable/disable receipt of the path mtu of the
160 inbound packet.
161
162
163
164 The following options may be set as sticky options with setsock‐
165 opt(3SOCKET) or as ancillary data to a sendmsg(3SOCKET) system call:
166
167 IPV6_PKTINFO Set the source address and/or interface out which
168 the packet(s) will be sent. Takes a struct
169 in6_pktinfo as the parameter.
170
171
172 IPV6_HOPLIMIT Set the initial hoplimit for outbound datagrams.
173 Takes an integer as the parameter. Note: This
174 option sets the hoplimit only for ancillary data
175 or sticky options and does not change the default
176 hoplimit for the socket; see IPV6_UNICAST_HOPS and
177 IPV6_MULTICAST_HOPS to change the socket's default
178 hoplimit.
179
180
181 IPV6_NEXTHOP Specify the IPv6 address of the first hop, which
182 must be a neighbor of the sending host. Takes a
183 struct sockaddr_in6 as the parameter. When this
184 option specifies the same address as the destina‐
185 tion IPv6 address of the datagram, this is equiva‐
186 lent to the existing SO_DONTROUTE option.
187
188
189 IPV6_HOPOPTS Specify one or more hop-by-hop options. Variable
190 length. Takes a complete IPv6 hop-by-hop options
191 extension header as the parameter.
192
193
194 IPV6_DSTOPTS Specify one or more destination options. Variable
195 length. Takes a complete IPv6 destination options
196 extension header as the parameter.
197
198
199 IPV6_RTHDR Specify the IPv6 routing header. Variable length.
200 Takes a complete IPv6 routing header as the param‐
201 eter. Currently, only type 0 routing headers are
202 supported.
203
204
205 IPV6_RTHDRDSTOPTS Specify one or more destination options for all
206 intermediate hops. May be configured, but will not
207 be applied unless an IPv6 routing header is also
208 configured. Variable length. Takes a complete IPv6
209 destination options extension header as the param‐
210 eter.
211
212
213 IPV6_PATHMTU Get the path MTU associated with a connected
214 socket. Takes a ip6_mtuinfo as the parameter.
215
216
217 IPV6_TCLASS Set the traffic class associated with outgoing
218 packets. The parameter is an integer. If the
219 parameter is less then -1 or greater then 256,
220 EINVAL is returned. If the parameter is equal to
221 -1, use the default. If the parameter is between 0
222 and 255 inclusive, use that value.
223
224
225
226 The following options affect the socket's multicast behavior:
227
228 IPV6_JOIN_GROUP Join a multicast group. Takes a struct
229 ipv6_mreq as the parameter; the structure
230 contains a multicast address and an inter‐
231 face index.
232
233
234 IPV6_LEAVE_GROUP Leave a multicast group. Takes a struct
235 ipv6_mreq as the parameter; the structure
236 contains a multicast address and an inter‐
237 face index.
238
239
240 MCAST_JOIN_GROUP Functionally equivalent to IPV6_JOIN_GROUP.
241 Takes a struct group_req as the parameter.
242 The structure contains a multicast address
243 and an interface index.
244
245
246 MCAST_BLOCK_SOURCE Block multicast packets on a particular
247 multicast group whose source address
248 matches the given source address. The spec‐
249 ified group must be joined previously using
250 IPV6_JOIN_GROUP or MCAST_JOIN_GROUP. Takes
251 a struct group_source_req as the parameter.
252 The structure contains an interface index,
253 a multicast address, and a source address.
254
255
256 MCAST_UNBLOCK_SOURCE Unblock multicast packets which were previ‐
257 ously blocked using MCAST_BLOCK_SOURCE.
258 Takes a struct group_source_req as the
259 parameter. The structure contains an inter‐
260 face index, a multicast address, and a
261 source address.
262
263
264 MCAST_LEAVE_GROUP Functionally equivalent to
265 IPV6_LEAVE_GROUP. Takes a struct group_req
266 as the parameter. The structure contains a
267 multicast address and an interface index.
268
269
270 MCAST_JOIN_SOURCE_GROUP Begin receiving packets for the given mul‐
271 ticast group whose source address matches
272 the specified address. Takes a struct
273 group_source_req as the parameter. The
274 structure contains an interface index, a
275 multicast address, and a source address.
276
277
278 MCAST_LEAVE_SOURCE_GROUP Stop receiving packets for the given multi‐
279 cast group whose source address matches the
280 specified address. Takes a struct
281 group_source_req as the parameter. The
282 structure contains an interface index, a
283 multicast address, and a source address.
284
285
286 IPV6_MULTICAST_IF The outgoing interface for multicast pack‐
287 ets. This option takes an integer as an
288 argument; the integer is the interface
289 index of the selected interface.
290
291
292 IPV6_MULTICAST_HOPS Default hop limit for multicast datagrams.
293 This option takes an integer as an argu‐
294 ment. Its value becomes the new default
295 value for ip6_hops that IPv6 will use on
296 outgoing multicast datagrams sent from that
297 socket. The initial default is 1.
298
299
300 IPV6_MULTICAST_LOOP Loopback for multicast datagrams. Normally
301 multicast datagrams are delivered to mem‐
302 bers on the sending host. Setting the
303 unsigned character argument to 0 will cause
304 the opposite behavior.
305
306
307
308 The multicast socket options can be used with any datagram socket type
309 in the IPv6 family.
310
311
312 At the socket level, the socket option SO_DONTROUTE may be applied.
313 This option forces datagrams being sent to bypass routing and forward‐
314 ing by forcing the IPv6 hoplimit field to 1, meaning that the packet
315 will not be forwarded by routers.
316
317
318 Raw IPv6 datagrams can also be sent and received using the TLI connec‐
319 tionless primitives.
320
321
322 Datagrams flow through the IPv6 layer in two directions: from the net‐
323 work up to user processes and from user processes down to the network.
324 Using this orientation, IPv6 is layered above the network interface
325 drivers and below the transport protocols such as UDP and TCP. The
326 Internet Control Message Protocol (ICMPv6) for the Internet Protocol
327 Version 6 (IPv6) is logically a part of IPv6. See icmp6(7P).
328
329
330 Unlike IP, IPv6 provides no checksum of the IPv6 header. Also unlike
331 IP, upper level protocol checksums are required. IPv6 will compute the
332 ULP/data portion checksum if the checksum field contains a zero (see
333 IPV6_CHECKSUM option above).
334
335
336 IPv6 extension headers in received datagrams are processed in the IPv6
337 layer according to the protocol specification. Currently recognized
338 IPv6 extension headers include hop-by-hop options header, destination
339 options header, routing header (currently, only type 0 routing headers
340 are supported), and fragment header.
341
342
343 By default, the IPv6 layer will not forward IPv6 packets that are not
344 addressed to it. This behavior can be overridden by using routeadm(1M)
345 to enable the ipv6-forwarding option. IPv6 forwarding is configured at
346 boot time based on the setting of routeadm(1M)'s ipv6-forwarding
347 option.
348
349
350 For backwards compatibility, IPv6 forwarding can be enabled or disabled
351 using ndd(1M)'s ip_forwarding variable. It is set to 1 if IPv6 for‐
352 warding is enabled, or 0 if it is disabled.
353
354
355 Additionally, finer-grained forwarding can be configured in IPv6. Each
356 interface can be configured to forward IPv6 packets by setting the
357 IFF_ROUTER interface flag. This flag can be set and cleared using
358 ifconfig(1M)'s router and -router options. If an interface's IFF_ROUTER
359 flag is set, packets can be forwarded to or from the interface. If it
360 is clear, packets will neither be forwarded from this interface to oth‐
361 ers, nor forwarded to this interface. Setting the ip6_forwarding vari‐
362 able sets all of the IPv6 interfaces' IFF_ROUTER flags.
363
364
365 For backwards compatibility, each interface creates an <ifname>ip6_for‐
366 warding /dev/ip6 variable that can be modified using ndd(1M). An inter‐
367 face's :ip6_forwarding ndd variable is a boolean variable that mirrors
368 the status of its IFF_ROUTER interface flag. It is set to 1 if the flag
369 is set, or 0 if it is clear. This interface specific <ifname>:ip6_for‐
370 warding ndd variable is obsolete and may be removed in a future release
371 of Solaris. The ifconfig(1M) router and -router interfaces are pre‐
372 ferred.
373
374
375 The IPv6 layer will send an ICMP6 message back to the source host in
376 many cases when it receives a datagram that can not be handled. A "time
377 exceeded" ICMP6 message will be sent if the ip6_hops field in the IPv6
378 header drops to zero in the process of forwarding a datagram. A "desti‐
379 nation unreachable" message will be sent by a router or by the origi‐
380 nating host if a datagram can not be sent on because there is no route
381 to the final destination; it will be sent by a router when it encoun‐
382 ters a firewall prohibition; it will be sent by a destination node when
383 the transport protocol (that is, TCP) has no listener. A "packet too
384 big" message will be sent by a router if the packet is larger than the
385 MTU of the outgoing link (this is used for Path MTU Discovery). A
386 "parameter problem" message will be sent if there is a problem with a
387 field in the IPv6 header or any of the IPv6 extension headers such that
388 the packet cannot be fully processed.
389
390
391 The IPv6 layer supports fragmentation and reassembly. Datagrams are
392 fragmented on output if the datagram is larger than the maximum trans‐
393 mission unit (MTU) of the network interface. Fragments of received
394 datagrams are dropped from the reassembly queues if the complete data‐
395 gram is not reconstructed within a short time period.
396
397
398 Errors in sending discovered at the network interface driver layer are
399 passed by IPv6 back up to the user process.
400
402 svcs(1), ndd(1M), routeadm(1M), svcadm(1M), read(2), write(2),
403 bind(3SOCKET), connect(3SOCKET), getsockopt(3SOCKET), recv(3SOCKET),
404 recvmsg(3SOCKET), send(3SOCKET), sendmsg(3SOCKET), setsockopt(3SOCKET),
405 defaultrouter(4), smf(5), icmp6(7P), if_tcp(7P), ipsec(7P), inet6(7P),
406 routing(7P), tcp(7P), udp(7P)
407
408
409 Deering, S. and Hinden, B. RFC 2460, Internet Protocol, Version 6
410 (IPv6) Specification. The Internet Society. December, 1998.
411
412
413 Stevens, W., and Thomas, M. RFC 2292, Advanced Sockets API for IPv6.
414 Network Working Group. February 1998.
415
417 A socket operation may fail with one of the following errors returned:
418
419 EPROTONOSUPPORT Unsupported protocol (for example, IPPROTO_RAW.)
420
421
422 EACCES A bind() operation was attempted with a "reserved"
423 port number and the effective user ID of the process
424 was not the privileged user.
425
426
427 EADDRINUSE A bind() operation was attempted on a socket with a
428 network address/port pair that has already been
429 bound to another socket.
430
431
432 EADDRNOTAVAIL A bind() operation was attempted for an address that
433 is not configured on this machine.
434
435
436 EINVAL A sendmsg() operation with a non-NULL msg_accrights
437 was attempted.
438
439
440 EINVAL A getsockopt() or setsockopt() operation with an
441 unknown socket option name was given.
442
443
444 EINVAL A getsockopt() or setsockopt() operation was
445 attempted with the IPv6 option field improperly
446 formed; an option field was shorter than the minimum
447 value or longer than the option buffer provided; the
448 value in the option field was invalid.
449
450
451 EISCONN A connect() operation was attempted on a socket on
452 which a connect() operation had already been per‐
453 formed, and the socket could not be successfully
454 disconnected before making the new connection.
455
456
457 EISCONN A sendto() or sendmsg() operation specifying an
458 address to which the message should be sent was
459 attempted on a socket on which a connect() operation
460 had already been performed.
461
462
463 EMSGSIZE A send(), sendto(), or sendmsg() operation was
464 attempted to send a datagram that was too large for
465 an interface, but was not allowed to be fragmented
466 (such as broadcasts).
467
468
469 ENETUNREACH An attempt was made to establish a connection via
470 connect(), or to send a datagram by means of
471 sendto() or sendmsg(), where there was no matching
472 entry in the routing table; or if an ICMP "destina‐
473 tion unreachable" message was received.
474
475
476 ENOTCONN A send() or write() operation, or a sendto() or
477 sendmsg() operation not specifying an address to
478 which the message should be sent, was attempted on a
479 socket on which a connect() operation had not
480 already been performed.
481
482
483 ENOBUFS The system ran out of memory for fragmentation buf‐
484 fers or other internal data structures.
485
486
487 ENOMEM The system was unable to allocate memory for an IPv6
488 socket option or other internal data structures.
489
490
491 ENOPROTOOPT An IP socket option was attempted on an IPv6 socket,
492 or an IPv6 socket option was attempted on an IP
493 socket.
494
495
496 ENOPROTOOPT Invalid socket type for the option.
497
498
500 Applications using the sockets API must use the Advanced Sockets API
501 for IPv6 (RFC 2292) to see elements of the inbound packet's IPv6 header
502 or extension headers.
503
504
505 The ip6 service is managed by the service management facility, smf(5),
506 under the service identifier:
507
508 svc:/network/initial:default
509
510
511
512
513 Administrative actions on this service, such as enabling, disabling, or
514 requesting restart, can be performed using svcadm(1M). The service's
515 status can be queried using the svcs(1) command.
516
517
518
519SunOS 5.11 2 Dec 2008 ip6(7P)