IPV6(4)

NAME
ipv6 - Internet Protocol, version 6

SYNOPSIS
#include <sys/socket.h>
#include <netinet6/in6.h>
int
socket(AF_INET6, SOCK_RAW, proto);

DESCRIPTION
IPv6 is the network layer protocol used by version 6 of the Internet protocol family. Options may be set at the IPv6 level when using higher-level protocols that are based on IPv6 (such as TCP and UDP). It may also be accessed through a “raw socket” when developing new protocols, or special-purpose applications.

There are several IPv6-level setsockopt(2) / getsockopt(2) options.

<And I'll detail them later.>

  Multicast Options

IPv6 multicasting is supported only on AF_INET sockets of type SOCK_DGRAM and SOCK_RAW.

<Details are forthcoming.>

  Raw IPv6 Sockets

Raw IPv6 sockets are connectionless, and are normally used with the sendto and recvfrom calls, though the connect(2) call may also be used to fix the destination for future packets (in which case the read(2) or recv(2) and write(2) or send(2) system calls may be used).

If proto is 0, the default protocol NEXTHDR_RAW is used for outgoing packets, and only incoming packets destined for that protocol are received. (In IPv6, "next header" is the same as IP's "protocol" field.) If proto is non-zero, that protocol number will be used on outgoing packets and to filter incoming packets.

Outgoing packets automatically have an IP header prepended to them (based on the destination address and the protocol number the socket is created with), unless the IP_HDRINCL option has been set. Incoming packets are received with IP header and options intact.

DIAGNOSTICS
A socket operation may fail with one of the following errors returned:

[EISCONN]
    when trying to establish a connection on a socket which already has one, or when trying to send a datagram with the destination address specified and the socket is already connected;

[ENOTCONN]
    when trying to send a datagram, but no destination address is specified, and the socket hasn't been connected;

[ENOBUFS]
    when the system runs out of memory for an internal data structure;

[EADDRNOTAVAIL]
    when an attempt is made to create a socket with a network address for which no network interface exists.

[EACESS]
    when an attempt is made to create a raw IP socket by a non-privileged process.

The following errors specific to IP may occur when setting or getting IP options:

[EINVAL]
    An unknown socket option name was given.

[EINVAL]
    The IP option field was improperly formed; an option field was shorter than the minimum value or longer than the option buffer provided.

SEE ALSO
getsockopt(2), send(2), recv(2), netintro(4), icmpv6(4), inet6(4)

HISTORY
The ipv6 protocol first appeared in NRL's 4.4BSD IPv6 networking distribution. The IPv6 extensions were written by Ran Atkinson, Dan McDonald, Craig Metz, and Bao Phan of the U. S. Naval Research Laboratory.