|
NAMEicmp6 —
Internet Control Message Protocol for IPv6
SYNOPSIS#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/icmp6.h>
int
DESCRIPTIONICMPv6 is the error and control message protocol used by IPv6 and the IPv6 protocol family (see ip6(4) and inet6(4)). It may be accessed through a “raw socket” for network monitoring and diagnostic functions.The proto parameter to the socket(2) call to create an ICMPv6 socket may be obtained from getprotobyname(3). ICMPv6 sockets are connectionless, 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 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). Incoming packets on the socket are received with the IPv6 header and any extension headers removed. TypesICMPv6 messages are classified according to the type and code fields present in the ICMPv6 header. The abbreviations for the types and codes may be used in rules in pf.conf(5). The following types are defined:
The following codes are defined:
HeadersAll ICMPv6 messages are prefixed with an ICMPv6 header. This header corresponds to the icmp6_hdr structure and has the following definition:struct icmp6_hdr { uint8_t icmp6_type; /* type field */ uint8_t icmp6_code; /* code field */ uint16_t icmp6_cksum; /* checksum field */ union { uint32_t icmp6_un_data32[1]; /* type-specific */ uint16_t icmp6_un_data16[2]; /* type-specific */ uint8_t icmp6_un_data8[4]; /* type-specific */ } icmp6_dataun; } __packed; #define icmp6_data32 icmp6_dataun.icmp6_un_data32 #define icmp6_data16 icmp6_dataun.icmp6_un_data16 #define icmp6_data8 icmp6_dataun.icmp6_un_data8 #define icmp6_pptr icmp6_data32[0] /* parameter prob */ #define icmp6_mtu icmp6_data32[0] /* packet too big */ #define icmp6_id icmp6_data16[0] /* echo request/reply */ #define icmp6_seq icmp6_data16[1] /* echo request/reply */ #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership*/ icmp6_type describes the type of the message. Suitable values are defined in ⟨netinet/icmp6.h⟩. icmp6_code describes the sub-type of the message and depends on icmp6_type. icmp6_cksum contains the checksum for the message and is filled in by the kernel on outgoing messages. The other fields are used for type-specific purposes. FiltersBecause of the extra functionality of ICMPv6 in comparison to ICMPv4, a larger number of messages may be potentially received on an ICMPv6 socket. Input filters may therefore be used to restrict input to a subset of the incoming ICMPv6 messages so only interesting messages are returned by the recv(2) family of calls to an application.The icmp6_filter structure may be used to refine the input message set according to the ICMPv6 type. By default, all messages types are allowed on newly created raw ICMPv6 sockets. The following macros may be used to refine the input set:
The
getsockopt(2)
and
setsockopt(2)
calls may be used to obtain and install the filter on ICMPv6 sockets at
option level SEE ALSOgetsockopt(2), recv(2), send(2), setsockopt(2), socket(2), getprotobyname(3), 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. W. Stevens, M. Thomas, E. Nordmark, and T. Jinmei, Advanced Sockets Application Program Interface (API) for IPv6, RFC 3542, May 2003. A. Conta, S. Deering, and M. Gupta, Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification, RFC 4443, March 2006.
Visit the GSP FreeBSD Man Page Interface. |