2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH IP6 7P "Dec 2, 2008"
8 ip6 \- Internet Protocol Version 6
12 #include <sys/socket.h>
13 #include <netinet/in.h>
14 #include <netinet/ip6.h>
19 s = socket(AF_INET6, SOCK_RAW, proto);
24 t = t_open ("/dev/rawip6", O_RDWR);
30 The \fBIPv6\fR protocol is the next generation of the internetwork datagram
31 delivery protocol of the Internet protocol family. Programs may use \fBIPv6\fR
32 through higher-level protocols such as the Transmission Control Protocol
33 (\fBTCP\fR) or the User Datagram Protocol (\fBUDP\fR), or may interface
34 directly to \fBIPv6\fR. See \fBtcp\fR(7P) and \fBudp\fR(7P). Direct access may
35 be by means of the socket interface, using a "raw socket," or by means of the
36 Transport Level Interface (\fBTLI\fR). The protocol options and \fBIPv6\fR
37 extension headers defined in the \fBIPv6\fR specification may be set in
39 .SH APPLICATION PROGRAMMING INTERFACE
42 The \fBSTREAMS\fR driver \fB/dev/rawip6\fR is the \fBTLI\fR transport provider
43 that provides raw access to \fBIPv6\fR.
46 Raw \fBIPv6\fR sockets are connectionless and are normally used with the
47 \fBsendto()\fR and \fBrecvfrom()\fR calls (see \fBsend\fR(3SOCKET) and
48 \fBrecv\fR(3SOCKET)), although the \fBconnect\fR(3SOCKET) call may also be used
49 to fix the destination for future datagrams. In this case, the \fBread\fR(2) or
50 \fBrecv\fR(3SOCKET) and \fBwrite\fR(2) or \fBsend\fR(3SOCKET) calls may be
51 used. Ancillary data may also be sent or received over raw \fBIPv6\fR sockets
52 using the \fBsendmsg\fR(3SOCKET) and \fBrecvmsg\fR(3SOCKET) system calls.
55 Unlike raw \fBIP\fR, \fBIPv6\fR applications do not include a complete
56 \fBIPv6\fR header when sending; there is no \fBIPv6\fR analog to the \fBIP\fR
57 \fBIP_HDRINCL\fR socket option. \fBIPv6\fR header values may be specified or
58 received as ancillary data to a \fBsendmsg\fR(3SOCKET) or
59 \fBrecvmsg\fR(3SOCKET) system call, or may be specified as "sticky" options on
60 a per-socket basis by using the \fBsetsockopt\fR(3SOCKET) system call. Such
61 sticky options are applied to all outbound packets unless overridden by
62 ancillary data. If any ancillary data is specified in a \fBsendmsg\fR(3SOCKET)
63 call, all sticky options not explicitly overridden revert to default values for
64 that datagram only; the sticky options persist as set for subsequent datagrams.
67 Since \fBsendmsg\fR(3SOCKET) is not supported for \fBSOCK_STREAM\fR upper level
68 protocols such as \fBTCP\fR, ancillary data is unsupported for \fBTCP\fR.
69 Sticky options, however, are supported.
72 Since \fBsendmsg\fR(3SOCKET) is supported for \fBSOCK_DGRAM\fR upper level
73 protocols, both ancillary data and sticky options are supported for \fBUDP\fR,
74 \fBICMP6\fR, and raw \fBIPv6\fR sockets.
77 The socket options supported at the \fBIPv6\fR level are:
81 \fB\fBIPV6_BOUND_IF\fR\fR
84 Limit reception and transmission of packets to this interface. Takes an integer
85 as an argument; the integer is the selected interace index.
91 \fB\fBIPV6_UNSPEC_SRC\fR\fR
94 Boolean. Allow/disallow sending with a zero source address.
100 \fB\fBIPV6_UNICAST_HOPS\fR\fR
103 Default hop limit for unicast datagrams. This option takes an integer as an
104 argument. Its value becomes the new default value for \fBip6_hops\fR that
105 \fBIPv6\fR will use on outgoing unicast datagrams sent from that socket. The
106 initial default is \fB60\fR.
112 \fB\fBIPV6_CHECKSUM\fR\fR
115 Specify the integer offset in bytes into the user data of the checksum
116 location. Does not apply to the \fBICMP6\fR protocol. Note: checksums are
117 required for all \fBIPv6\fR datagrams; this is different from \fBIP\fR, in
118 which datagram checksums were optional. \fBIPv6\fR will compute the \fBULP\fR
119 checksum if the value in the checksum field is zero.
125 \fB\fBIPV6_SEC_OPT\fR\fR
128 Enable or obtain IPsec security settings for this socket. For more details on
129 the protection services of IPsec, see \fBipsec\fR(7P).
135 \fB\fBIPV6_DONTFRAG\fR\fR
138 Boolean. Control fragmentation.
144 \fB\fBIPV6_USE_MIN_MTU\fR\fR
147 Controls whether path MTU discovery is used. If set to 1, path MTU discovery is
148 never used and IPv6 packets are sent with the IPv6 minimum MTU. If set to -1,
149 path MTU discovery is not used for multicast and multicast packets are sent
150 with the IPv6 minimum MTU. If set to 0, path MTU is always performed.
156 \fB\fBIPV6_V6ONLY\fR\fR
159 Boolean. If set, only V6 packets can be sent or received
165 \fB\fBIPV6_SRC_PREFERENCES\fR\fR
168 Enable or obtain Source Address Selection rule settings for this socket. For
169 more details on the Source Address Selection rules, see \fBinet6\fR(7P).
174 The following options are boolean switches controlling the reception of
179 \fB\fBIPV6_RECVPKTINFO\fR\fR
182 Enable/disable receipt of the index of the interface the packet arrived on, and
183 of the inbound packet's destination address.
189 \fB\fBIPV6_RECVHOPLIMIT\fR\fR
192 Enable/disable receipt of the inbound packet's current hoplimit.
198 \fB\fBIPV6_RECVHOPOPTS\fR\fR
201 Enable/disable receipt of the inbound packet's \fBIPv6\fR hop-by-hop extension
208 \fB\fBIPV6_RECVDSTOPTS\fR\fR
211 Enable/disable receipt of the inbound packet's \fBIPv6\fR destination options
218 \fB\fBIPV6_RECVRTHDR\fR\fR
221 Enable/disable receipt of the inbound packet's \fBIPv6\fR routing header.
227 \fB\fBIPV6_RECVRTHDRDSTOPTS\fR\fR
230 Enable/disable receipt of the inbound packet's intermediate-hops options
231 extension header. This option is obsolete. IPV6_RECVDSTOPTS turns on receipt of
232 both destination option headers.
238 \fB\fBIPV6_RECVTCLASS\fR\fR
241 Enable/disable receipt of the traffic class of the inbound packet.
247 \fB\fBIPV6_RECVPATHMTU\fR\fR
250 Enable/disable receipt of the path mtu of the inbound packet.
255 The following options may be set as sticky options with
256 \fBsetsockopt\fR(3SOCKET) or as ancillary data to a \fBsendmsg\fR(3SOCKET)
261 \fB\fBIPV6_PKTINFO\fR\fR
264 Set the source address and/or interface out which the packet(s) will be sent.
265 Takes a \fBstruct\fR \fBin6_pktinfo\fR as the parameter.
271 \fB\fBIPV6_HOPLIMIT\fR\fR
274 Set the initial hoplimit for outbound datagrams. Takes an integer as the
275 parameter. Note: This option sets the hoplimit only for ancillary data or
276 sticky options and does not change the default hoplimit for the socket; see
277 \fBIPV6_UNICAST_HOPS\fR and \fBIPV6_MULTICAST_HOPS\fR to change the socket's
284 \fB\fBIPV6_NEXTHOP\fR\fR
287 Specify the \fBIPv6\fR address of the first hop, which must be a neighbor of
288 the sending host. Takes a \fBstruct\fR \fBsockaddr_in6\fR as the parameter.
289 When this option specifies the same address as the destination \fBIPv6\fR
290 address of the datagram, this is equivalent to the existing \fBSO_DONTROUTE\fR
297 \fB\fBIPV6_HOPOPTS\fR\fR
300 Specify one or more hop-by-hop options. Variable length. Takes a complete
301 \fBIPv6\fR hop-by-hop options extension header as the parameter.
307 \fB\fBIPV6_DSTOPTS\fR\fR
310 Specify one or more destination options. Variable length. Takes a complete
311 \fBIPv6\fR destination options extension header as the parameter.
317 \fB\fBIPV6_RTHDR\fR\fR
320 Specify the \fBIPv6\fR routing header. Variable length. Takes a complete
321 \fBIPv6\fR routing header as the parameter. Currently, only type 0 routing
322 headers are supported.
328 \fB\fBIPV6_RTHDRDSTOPTS\fR\fR
331 Specify one or more destination options for all intermediate hops. May be
332 configured, but will not be applied unless an \fBIPv6\fR routing header is also
333 configured. Variable length. Takes a complete \fBIPv6\fR destination options
334 extension header as the parameter.
340 \fB\fBIPV6_PATHMTU\fR\fR
343 Get the path MTU associated with a connected socket. Takes a ip6_mtuinfo as the
350 \fB\fBIPV6_TCLASS\fR\fR
353 Set the traffic class associated with outgoing packets. The parameter is an
354 integer. If the parameter is less then -1 or greater then 256, EINVAL is
355 returned. If the parameter is equal to -1, use the default. If the parameter is
356 between 0 and 255 inclusive, use that value.
361 The following options affect the socket's multicast behavior:
365 \fB\fBIPV6_JOIN_GROUP\fR\fR
368 Join a multicast group. Takes a \fBstruct\fR \fBipv6_mreq\fR as the parameter;
369 the structure contains a multicast address and an interface index.
375 \fB\fBIPV6_LEAVE_GROUP\fR\fR
378 Leave a multicast group. Takes a \fBstruct\fR \fBipv6_mreq\fR as the parameter;
379 the structure contains a multicast address and an interface index.
385 \fB\fBMCAST_JOIN_GROUP\fR\fR
388 Functionally equivalent to IPV6_JOIN_GROUP. Takes a \fBstruct\fR
389 \fBgroup_req\fR as the parameter. The structure contains a multicast address
390 and an interface index.
396 \fB\fBMCAST_BLOCK_SOURCE\fR\fR
399 Block multicast packets on a particular multicast group whose source address
400 matches the given source address. The specified group must be joined previously
401 using IPV6_JOIN_GROUP or MCAST_JOIN_GROUP. Takes a \fBstruct\fR
402 \fBgroup_source_req\fR as the parameter. The structure contains an interface
403 index, a multicast address, and a source address.
409 \fB\fBMCAST_UNBLOCK_SOURCE\fR\fR
412 Unblock multicast packets which were previously blocked using
413 MCAST_BLOCK_SOURCE. Takes a \fBstruct\fR \fBgroup_source_req\fR as the
414 parameter. The structure contains an interface index, a multicast address, and
421 \fB\fBMCAST_LEAVE_GROUP\fR\fR
424 Functionally equivalent to IPV6_LEAVE_GROUP. Takes a \fBstruct\fR
425 \fBgroup_req\fR as the parameter. The structure contains a multicast address
426 and an interface index.
432 \fB\fBMCAST_JOIN_SOURCE_GROUP\fR\fR
435 Begin receiving packets for the given multicast group whose source address
436 matches the specified address. Takes a \fBstruct\fR \fBgroup_source_req\fR as
437 the parameter. The structure contains an interface index, a multicast address,
438 and a source address.
444 \fB\fBMCAST_LEAVE_SOURCE_GROUP\fR\fR
447 Stop receiving packets for the given multicast group whose source address
448 matches the specified address. Takes a \fBstruct\fR \fBgroup_source_req\fR as
449 the parameter. The structure contains an interface index, a multicast address,
450 and a source address.
456 \fB\fBIPV6_MULTICAST_IF\fR\fR
459 The outgoing interface for multicast packets. This option takes an integer as
460 an argument; the integer is the interface index of the selected interface.
466 \fB\fBIPV6_MULTICAST_HOPS\fR\fR
469 Default hop limit for multicast datagrams. This option takes an integer as an
470 argument. Its value becomes the new default value for \fBip6_hops\fR that
471 \fBIPv6\fR will use on outgoing multicast datagrams sent from that socket. The
472 initial default is \fB1\fR.
478 \fB\fBIPV6_MULTICAST_LOOP\fR\fR
481 Loopback for multicast datagrams. Normally multicast datagrams are delivered to
482 members on the sending host. Setting the unsigned character argument to 0 will
483 cause the opposite behavior.
488 The multicast socket options can be used with any datagram socket type in the
492 At the socket level, the socket option \fBSO_DONTROUTE\fR may be applied. This
493 option forces datagrams being sent to bypass routing and forwarding by forcing
494 the \fBIPv6\fR hoplimit field to \fB1\fR, meaning that the packet will not be
495 forwarded by routers.
498 Raw \fBIPv6\fR datagrams can also be sent and received using the \fBTLI\fR
499 connectionless primitives.
502 Datagrams flow through the \fBIPv6\fR layer in two directions: from the network
503 \fIup\fR to user processes and from user processes \fIdown\fR to the network.
504 Using this orientation, \fBIPv6\fR is layered \fIabove\fR the network interface
505 drivers and \fIbelow\fR the transport protocols such as \fBUDP\fR and
506 \fBTCP\fR. The Internet Control Message Protocol (\fBICMPv6\fR) for the
507 Internet Protocol Version 6 (\fBIPv6\fR) is logically a part of \fBIPv6\fR. See
511 Unlike \fBIP\fR, \fBIPv6\fR provides no checksum of the \fBIPv6\fR header. Also
512 unlike \fBIP\fR, upper level protocol checksums are required. \fBIPv6\fR will
513 compute the \fBULP\fR/data portion checksum if the checksum field contains a
514 zero (see \fBIPV6_CHECKSUM\fR option above).
517 \fBIPv6\fR extension headers in received datagrams are processed in the
518 \fBIPv6\fR layer according to the protocol specification. Currently recognized
519 \fBIPv6\fR extension headers include hop-by-hop options header, destination
520 options header, routing header (currently, only type 0 routing headers are
521 supported), and fragment header.
524 By default, the IPv6 layer will not forward IPv6 packets that are not addressed
525 to it. This behavior can be overridden by using \fBrouteadm\fR(1M) to enable
526 the ipv6-forwarding option. IPv6 forwarding is configured at boot time based on
527 the setting of \fBrouteadm\fR(1M)'s ipv6-forwarding option.
530 For backwards compatibility, IPv6 forwarding can be enabled or disabled using
531 \fBndd\fR(1M)'s ip_forwarding variable. It is set to 1 if IPv6 forwarding is
532 enabled, or 0 if it is disabled.
535 Additionally, finer-grained forwarding can be configured in IPv6. Each
536 interface can be configured to forward IPv6 packets by setting the IFF_ROUTER
537 interface flag. This flag can be set and cleared using \fBifconfig\fR(1M)'s
538 router and -router options. If an interface's IFF_ROUTER flag is set, packets
539 can be forwarded to or from the interface. If it is clear, packets will neither
540 be forwarded from this interface to others, nor forwarded to this interface.
541 Setting the ip6_forwarding variable sets all of the IPv6 interfaces' IFF_ROUTER
545 For backwards compatibility, each interface creates an
546 \fB<ifname>ip6_forwarding /dev/ip6\fR variable that can be modified using
547 \fBndd\fR(1M). An interface's \fB:ip6_forwarding ndd\fR variable is a boolean
548 variable that mirrors the status of its IFF_ROUTER interface flag. It is set to
549 1 if the flag is set, or 0 if it is clear. This interface specific
550 \fB<ifname>:ip6_forwarding ndd\fR variable is obsolete and may be removed in a
551 future release of Solaris. The \fBifconfig\fR(1M) router and -router interfaces
555 The \fBIPv6\fR layer will send an \fBICMP6\fR message back to the source host
556 in many cases when it receives a datagram that can not be handled. A
557 "\fBtime\fR \fBexceeded\fR" \fBICMP6\fR message will be sent if the
558 \fBip6_hops\fR field in the \fBIPv6\fR header drops to zero in the process of
559 forwarding a datagram. A "\fBdestination\fR \fBunreachable\fR" message will be
560 sent by a router or by the originating host if a datagram can not be sent on
561 because there is no route to the final destination; it will be sent by a router
562 when it encounters a firewall prohibition; it will be sent by a destination
563 node when the transport protocol (that is, \fBTCP\fR) has no listener. A
564 "\fBpacket\fR \fBtoo\fR \fBbig\fR" message will be sent by a router if the
565 packet is larger than the \fBMTU\fR of the outgoing link (this is used for Path
566 \fBMTU\fR Discovery). A "\fBparameter\fR \fBproblem\fR" message will be sent if
567 there is a problem with a field in the \fBIPv6\fR header or any of the
568 \fBIPv6\fR extension headers such that the packet cannot be fully processed.
571 The \fBIPv6\fR layer supports fragmentation and reassembly. Datagrams are
572 fragmented on output if the datagram is larger than the maximum transmission
573 unit (\fBMTU\fR) of the network interface. Fragments of received datagrams are
574 dropped from the reassembly queues if the complete datagram is not
575 reconstructed within a short time period.
578 Errors in sending discovered at the network interface driver layer are passed
579 by IPv6 back up to the user process.
583 \fBsvcs\fR(1), \fBndd\fR(1M), \fBrouteadm\fR(1M), \fBsvcadm\fR(1M),
584 \fBread\fR(2), \fBwrite\fR(2), \fBbind\fR(3SOCKET), \fBconnect\fR(3SOCKET),
585 \fBgetsockopt\fR(3SOCKET), \fBrecv\fR(3SOCKET), \fBrecvmsg\fR(3SOCKET),
586 \fBsend\fR(3SOCKET), \fBsendmsg\fR(3SOCKET), \fBsetsockopt\fR(3SOCKET),
587 \fBdefaultrouter\fR(4), \fBsmf\fR(5), \fBicmp6\fR(7P), \fBif_tcp\fR(7P),
588 \fBipsec\fR(7P), \fBinet6\fR(7P), \fBrouting\fR(7P), \fBtcp\fR(7P),
592 Deering, S. and Hinden, B. \fI RFC 2460, Internet Protocol, Version 6 (IPv6)
593 Specification\fR. The Internet Society. December, 1998.
596 Stevens, W., and Thomas, M. \fIRFC 2292, Advanced Sockets API for IPv6\fR.
597 Network Working Group. February 1998.
601 A socket operation may fail with one of the following errors returned:
605 \fB\fBEPROTONOSUPPORT\fR\fR
608 Unsupported protocol (for example, IPPROTO_RAW.)
617 A \fBbind()\fR operation was attempted with a "reserved" port number and the
618 effective user ID of the process was not the privileged user.
624 \fB\fBEADDRINUSE\fR\fR
627 A \fBbind()\fR operation was attempted on a socket with a network address/port
628 pair that has already been bound to another socket.
634 \fB\fBEADDRNOTAVAIL\fR\fR
637 A \fBbind()\fR operation was attempted for an address that is not configured on
647 A \fBsendmsg()\fR operation with a non-NULL \fBmsg_accrights\fR was attempted.
656 A \fBgetsockopt()\fR or \fBsetsockopt()\fR operation with an unknown socket
657 option name was given.
666 A \fBgetsockopt()\fR or \fBsetsockopt()\fR operation was attempted with the
667 \fBIPv6\fR option field improperly formed; an option field was shorter than the
668 minimum value or longer than the option buffer provided; the value in the
669 option field was invalid.
678 A \fBconnect()\fR operation was attempted on a socket on which a
679 \fBconnect()\fR operation had already been performed, and the socket could not
680 be successfully disconnected before making the new connection.
689 A \fBsendto()\fR or \fBsendmsg()\fR operation specifying an address to which
690 the message should be sent was attempted on a socket on which a \fBconnect()\fR
691 operation had already been performed.
700 A \fBsend()\fR, \fBsendto()\fR, or \fBsendmsg()\fR operation was attempted to
701 send a datagram that was too large for an interface, but was not allowed to be
702 fragmented (such as broadcasts).
708 \fB\fBENETUNREACH\fR\fR
711 An attempt was made to establish a connection via \fBconnect()\fR, or to send a
712 datagram by means of \fBsendto()\fR or \fBsendmsg()\fR, where there was no
713 matching entry in the routing table; or if an \fBICMP\fR "\fBdestination
714 unreachable\fR" message was received.
723 A \fBsend()\fR or \fBwrite()\fR operation, or a \fBsendto()\fR or
724 \fBsendmsg()\fR operation not specifying an address to which the message should
725 be sent, was attempted on a socket on which a \fBconnect()\fR operation had not
726 already been performed.
735 The system ran out of memory for fragmentation buffers or other internal data
745 The system was unable to allocate memory for an \fBIPv6\fR socket option or
746 other internal data structures.
752 \fB\fBENOPROTOOPT\fR\fR
755 An \fBIP\fR socket option was attempted on an \fBIPv6\fR socket, or an
756 \fBIPv6\fR socket option was attempted on an \fBIP\fR socket.
762 \fB\fBENOPROTOOPT\fR\fR
765 Invalid socket type for the option.
771 Applications using the sockets \fBAPI\fR must use the Advanced Sockets
772 \fBAPI\fR for \fBIPv6\fR (\fIRFC 2292\fR) to see elements of the inbound
773 packet's \fBIPv6\fR header or extension headers.
776 The \fBip6\fR service is managed by the service management facility,
777 \fBsmf\fR(5), under the service identifier:
781 svc:/network/initial:default
788 Administrative actions on this service, such as enabling, disabling, or
789 requesting restart, can be performed using \fBsvcadm\fR(1M). The service's
790 status can be queried using the \fBsvcs\fR(1) command.