Internet Control Message Protocol for IP6
#include <sys/socket.h> #include <netinet/in.h> #include <netinet/icmp6.h> int socket( AF_INET6, SOCK_RAW, proto);
ICMP6 is the error and control message protocol that IP6 and the Internet Protocol family use. It may be accessed through a “raw socket” for network monitoring and diagnostic functions. Use the getprotobyname() function to obtain the proto parameter to the socket() function, or simply pass IPPROTO_ICMPV6.
ICMPv6 sockets are connectionless, and are normally used with the sendto() and recvfrom() functions. You may also use the connect() function to fix the destination for future packets (in which case, you may also use the read() or recv() functions and the write() or send() system calls).
Outgoing packets automatically have an IP6 header prepended to them (based on the destination address). The ICMP6 pseudo header checksum field (icmp6_cksum, found in the icmp6_hdr structure in <netinet/icmp6.h>) is filled automatically by the socket manager. Incoming packets are received without the IP6 header or extension headers.
|This behavior is opposite from both IPv4 raw sockets and ICMPv4 sockets.|
Each ICMP6 raw socket has an associated filter whose data type is defined as struct icmp6_filter. This structure, along with the macros and constants defined below are defined in the <netinet/icmp6.h> header.
You can get and set the current filter by calling getsockopt() and setsockopt() with a level of IPPROTO_ICMPV6 and an option name of ICMP6_FILTER.
The following macros operate on an icmp6_filter structure. If the first argument is an integer, it represents an ICMP6 message type, with a value between 0 and 255. The pointer arguments are pointers to the filters that are either set or examined, depending on the macro:
When you create an ICMP6 raw socket, it passes all ICMPv6 message types to the application by default.
For more information, see RFC 2292.
INET6, IP6 protocols
connect(), getprotobyname(), getsockopt(), read(), recv(), recvfrom(), send(), sendto(), setsockopt(), socket(), write()
Based on RFC 2292