IP6(4P) | Protocols | IP6(4P) |
ip6 - Internet Protocol Version 6
#include <sys/socket.h> #include <netinet/in.h> #include <netinet/ip6.h>
s = socket(AF_INET6, SOCK_RAW, proto);
t = t_open ("/dev/rawip6", O_RDWR);
The IPv6 protocol is the next generation of the internetwork datagram delivery protocol of the Internet protocol family. Programs may use IPv6 through higher-level protocols such as the Transmission Control Protocol (TCP) or the User Datagram Protocol (UDP), or may interface directly to IPv6. See tcp(4P) and udp(4P). Direct access may be by means of the socket interface, using a "raw socket," or by means of the Transport Level Interface (TLI). The protocol options and IPv6 extension headers defined in the IPv6 specification may be set in outgoing datagrams.
The STREAMS driver /dev/rawip6 is the TLI transport provider that provides raw access to IPv6.
Raw IPv6 sockets are connectionless and are normally used with the sendto() and recvfrom() calls (see send(3SOCKET) and recv(3SOCKET)), although the connect(3SOCKET) call may also be used to fix the destination for future datagrams. In this case, the read(2) or recv(3SOCKET) and write(2) or send(3SOCKET) calls may be used. Ancillary data may also be sent or received over raw IPv6 sockets using the sendmsg(3SOCKET) and recvmsg(3SOCKET) system calls.
Unlike raw IP, IPv6 applications do not include a complete IPv6 header when sending; there is no IPv6 analog to the IP IP_HDRINCL socket option. IPv6 header values may be specified or received as ancillary data to a sendmsg(3SOCKET) or recvmsg(3SOCKET) system call, or may be specified as "sticky" options on a per-socket basis by using the setsockopt(3SOCKET) system call. Such sticky options are applied to all outbound packets unless overridden by ancillary data. If any ancillary data is specified in a sendmsg(3SOCKET) call, all sticky options not explicitly overridden revert to default values for that datagram only; the sticky options persist as set for subsequent datagrams.
Since sendmsg(3SOCKET) is not supported for SOCK_STREAM upper level protocols such as TCP, ancillary data is unsupported for TCP. Sticky options, however, are supported.
Since sendmsg(3SOCKET) is supported for SOCK_DGRAM upper level protocols, both ancillary data and sticky options are supported for UDP, ICMP6, and raw IPv6 sockets.
The socket options supported at the IPv6 level are:
IPV6_BOUND_IF
IPV6_UNSPEC_SRC
IPV6_UNICAST_HOPS
IPV6_MINHOPCOUNT
IPV6_CHECKSUM
IPV6_SEC_OPT
IPV6_DONTFRAG
IPV6_USE_MIN_MTU
IPV6_V6ONLY
IPV6_SRC_PREFERENCES
The following options are boolean switches controlling the reception of ancillary data:
IPV6_RECVPKTINFO
IPV6_RECVHOPLIMIT
IPV6_RECVHOPOPTS
IPV6_RECVDSTOPTS
IPV6_RECVRTHDR
IPV6_RECVRTHDRDSTOPTS
IPV6_RECVTCLASS
IPV6_RECVPATHMTU
The following options may be set as sticky options with setsockopt(3SOCKET) or as ancillary data to a sendmsg(3SOCKET) system call:
IPV6_PKTINFO
IPV6_HOPLIMIT
IPV6_NEXTHOP
IPV6_HOPOPTS
IPV6_DSTOPTS
IPV6_RTHDR
IPV6_RTHDRDSTOPTS
IPV6_PATHMTU
IPV6_TCLASS
The following options affect the socket's multicast behavior:
IPV6_JOIN_GROUP
IPV6_LEAVE_GROUP
MCAST_JOIN_GROUP
MCAST_BLOCK_SOURCE
MCAST_UNBLOCK_SOURCE
MCAST_LEAVE_GROUP
MCAST_JOIN_SOURCE_GROUP
MCAST_LEAVE_SOURCE_GROUP
IPV6_MULTICAST_IF
IPV6_MULTICAST_HOPS
IPV6_MULTICAST_LOOP
The multicast socket options can be used with any datagram socket type in the IPv6 family.
At the socket level, the socket option SO_DONTROUTE may be applied. This option forces datagrams being sent to bypass routing and forwarding by forcing the IPv6 hoplimit field to 1, meaning that the packet will not be forwarded by routers.
Raw IPv6 datagrams can also be sent and received using the TLI connectionless primitives.
Datagrams flow through the IPv6 layer in two directions: from the network up to user processes and from user processes down to the network. Using this orientation, IPv6 is layered above the network interface drivers and below the transport protocols such as UDP and TCP. The Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) is logically a part of IPv6. See icmp6(4P).
Unlike IP, IPv6 provides no checksum of the IPv6 header. Also unlike IP, upper level protocol checksums are required. IPv6 will compute the ULP/data portion checksum if the checksum field contains a zero (see IPV6_CHECKSUM option above).
IPv6 extension headers in received datagrams are processed in the IPv6 layer according to the protocol specification. Currently recognized IPv6 extension headers include hop-by-hop options header, destination options header, routing header (currently, only type 0 routing headers are supported), and fragment header.
By default, the IPv6 layer will not forward IPv6 packets that are not addressed to it. This behavior can be overridden by using routeadm(8) to enable the ipv6-forwarding option. IPv6 forwarding is configured at boot time based on the setting of routeadm(8)'s ipv6-forwarding option.
For backwards compatibility, IPv6 forwarding can be enabled or disabled using ndd(8)'s ip_forwarding variable. It is set to 1 if IPv6 forwarding is enabled, or 0 if it is disabled.
Additionally, finer-grained forwarding can be configured in IPv6. Each interface can be configured to forward IPv6 packets by setting the IFF_ROUTER interface flag. This flag can be set and cleared using ifconfig(8)'s router and -router options. If an interface's IFF_ROUTER flag is set, packets can be forwarded to or from the interface. If it is clear, packets will neither be forwarded from this interface to others, nor forwarded to this interface. Setting the ip6_forwarding variable sets all of the IPv6 interfaces' IFF_ROUTER flags.
For backwards compatibility, each interface creates an <ifname>ip6_forwarding /dev/ip6 variable that can be modified using ndd(8). An interface's :ip6_forwarding ndd variable is a boolean variable that mirrors the status of its IFF_ROUTER interface flag. It is set to 1 if the flag is set, or 0 if it is clear. This interface specific <ifname>:ip6_forwarding ndd variable is obsolete and may be removed in a future release of Solaris. The ifconfig(8) router and -router interfaces are preferred.
The IPv6 layer will send an ICMP6 message back to the source host in many cases when it receives a datagram that can not be handled. A "time exceeded" ICMP6 message will be sent if the ip6_hops field in the IPv6 header drops to zero in the process of forwarding a datagram. A "destination unreachable" message will be sent by a router or by the originating host if a datagram can not be sent on because there is no route to the final destination; it will be sent by a router when it encounters a firewall prohibition; it will be sent by a destination node when the transport protocol (that is, TCP) has no listener. A "packet too big" message will be sent by a router if the packet is larger than the MTU of the outgoing link (this is used for Path MTU Discovery). A "parameter problem" message will be sent if there is a problem with a field in the IPv6 header or any of the IPv6 extension headers such that the packet cannot be fully processed.
The IPv6 layer supports fragmentation and reassembly. Datagrams are fragmented on output if the datagram is larger than the maximum transmission unit (MTU) of the network interface. Fragments of received datagrams are dropped from the reassembly queues if the complete datagram is not reconstructed within a short time period.
Errors in sending discovered at the network interface driver layer are passed by IPv6 back up to the user process.
svcs(1), read(2), write(2), bind(3SOCKET), connect(3SOCKET), getsockopt(3SOCKET), recv(3SOCKET), recvmsg(3SOCKET), send(3SOCKET), sendmsg(3SOCKET), setsockopt(3SOCKET), icmp6(4P), if_tcp(4P), inet6(4P), ipsec(4P), routing(4P), tcp(4P), udp(4P), defaultrouter(5), smf(7), ndd(8), routeadm(8), svcadm(8)
Deering, S. and Hinden, B. RFC 2460, Internet Protocol, Version 6 (IPv6) Specification. The Internet Society. December, 1998.
Stevens, W., and Thomas, M. RFC 2292, Advanced Sockets API for IPv6. Network Working Group. February 1998.
A socket operation may fail with one of the following errors returned:
EPROTONOSUPPORT
EACCES
EADDRINUSE
EADDRNOTAVAIL
EINVAL
EINVAL
EINVAL
EISCONN
EISCONN
EMSGSIZE
ENETUNREACH
ENOTCONN
ENOBUFS
ENOMEM
ENOPROTOOPT
ENOPROTOOPT
Applications using the sockets API must use the Advanced Sockets API for IPv6 (RFC 2292) to see elements of the inbound packet's IPv6 header or extension headers.
The ip6 service is managed by the service management facility, smf(7), under the service identifier:
svc:/network/initial:default
Administrative actions on this service, such as enabling, disabling, or requesting restart, can be performed using svcadm(8). The service's status can be queried using the svcs(1) command.
April 17, 2024 | OmniOS |