ICMP6(4) BSD Programmer's Manual ICMP6(4)
icmp6 - Internet Control Message Protocol for IPv6
#include <sys/socket.h> #include <netinet/in.h> #include <netinet/icmp6.h> int socket(AF_INET6, SOCK_RAW, proto);
ICMPv6 is the error and control message protocol used by IPv6 and the In- ternet protocol family. It may be accessed through a "raw socket" for 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 sockets are con- nectionless, and are normally used with the sendto(2) and recvfrom(2) 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). Outgoing packets automatically have an IPv6 header prepended to them (based on the destination address). The ICMPv6 pseudo-header checksum field (icmp6_cksum) is filled automatically by the kernel. Incoming pack- ets are received without the IPv6 header or IPv6 extension headers. No- tice that this behavior is opposite to that of IPv4 raw sockets and ICMPv4 sockets.
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 <netinet/icmp6.h> header. The current filter is fetched and stored using getsockopt(2) and setsockopt(2) with a level of IPPROTO_ICMPV6 and an option name of ICMP6_FILTER. 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 icmp6_filter *) int ICMP6_FILTER_WILLBLOCK(int, const struct icmp6_filter *) The first argument to the last four macros (an integer) is an ICMPv6 mes- sage 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 macros examined 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 messages are 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 passed to the application (blocked). The final two macros, WILLPASS and WILLBLOCK, return true or false depending on whether the specified message type is passed to the applica- tion or blocked from being passed to the application by the filter point- ed 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 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 al- ready connected. [ENOTCONN] when trying to send a datagram, but no destination ad- dress is specified, and the socket hasn't been connect- ed. [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 net- work address for which no network interface exists.
recv(2), send(2), inet6(4), ip6(4), netintro(4) W. Stevens and M. Thomas, Advanced Sockets API for IPv6, RFC 2292, February 1998. A. Conta and S. Deering, Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification, RFC 2463, December 1998.
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. MirOS BSD #10-current December 17, 1999 1
Generated on 2013-04-27 00:20:00 by $MirOS: src/scripts/roff2htm,v 1.77 2013/01/01 20:49:09 tg Exp $
These manual pages and other documentation are copyrighted by their respective writers;
their source is available at our CVSweb,
AnonCVS, and other mirrors. The rest is Copyright © 2002‒2013 The MirOS Project, Germany.
This product includes material provided by Thorsten Glaser.
This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report – diffs preferred.