icmp6 - Internet Control Message Protocol for IPv6
socket(AF_INET6, SOCK_RAW, proto);
ICMPv6 is the error and control message protocol used by
IPv6 and the Internet
protocol family. It may be accessed through a ``raw
network monitoring and diagnostic functions. The proto parameter to the
socket call to create an ICMPv6 socket is obtained from
getprotobyname(3), or you can use IPPROTO_ICMPV6. ICMPv6
connectionless, and are normally used with the sendto(2) and
calls, though the connect(2) call may also be used to fix
for future packets (in which case the read(2) or recv(2) and
send(2) system calls may be used).
Outgoing packets automatically have an IPv6 header prepended
(based on the destination address). The ICMPv6 pseudo-header checksum
field (icmp6_cksum) is filled automatically by the kernel.
packets are received without the IPv6 header or IPv6 extension headers.
Notice that this behavior is opposite to that of IPv4 raw
ICMPv6 type/code filter
Each ICMPv6 raw socket has an associated filter whose
datatype is defined
as struct icmp6_filter;
This structure, along with the macros and constants defined
later in this
section, are defined as a result of including the
The current filter is fetched and stored using getsockopt(2)
setsockopt(2) with a level of IPPROTO_ICMPV6 and an option
Six macros operate on an icmp6_filter structure:
void ICMP6_FILTER_SETPASSALL(struct icmp6_filter *)
void ICMP6_FILTER_SETBLOCKALL(struct icmp6_filter *)
void ICMP6_FILTER_SETPASS(int, struct icmp6_filter *)
void ICMP6_FILTER_SETBLOCK(int, struct icmp6_filter *)
int ICMP6_FILTER_WILLPASS(int, const struct
int ICMP6_FILTER_WILLBLOCK(int, const struct
The first argument to the last four macros (an integer) is
an ICMPv6 message
type, between 0 and 255. The pointer argument to all
six macros is
a pointer to a filter that is modified by the first four
by the last two macros.
The first two macros, SETPASSALL and SETBLOCKALL, specify
that all ICMPv6
messages are passed to the application or that all ICMPv6
blocked from being passed to the application.
The next two macros, SETPASS and SETBLOCK, specify that messages of a
given ICMPv6 type should be passed to the application or not
the application (blocked).
The final two macros, WILLPASS and WILLBLOCK, return true or
on whether the specified message type is passed to
or blocked from being passed to the application by the
to by the second argument.
When an ICMPv6 raw socket is created, it will by default
pass all ICMPv6
message types to the application.
For further discussions see RFC 2292.
A socket operation may fail with one of the following errors
[EISCONN] when trying to establish a connection on a
already has one, or when trying to send a
the destination address specified and the
socket is already
[ENOTCONN] when trying to send a datagram, but no destination address
is specified, and the socket hasn't
[ENOBUFS] when the system runs out of memory for an
[EADDRNOTAVAIL] when an attempt is made to create a socket
with a network
address for which no network interface
recv(2), send(2), inet6(4), ip6(4), netintro(4)
W. Stevens and M. Thomas, Advanced Sockets API for IPv6, RFC
A. Conta and S. Deering, Internet Control Message Protocol
the Internet Protocol Version 6 (IPv6) Specification, RFC
The implementation is based on KAME stack (which is a descendant of WIDE
hydrangea IPv6 stack kit).
Part of the document was shamelessly copied from RFC 2292.
OpenBSD 3.6 December 17, 1999
[ Back ]