1.\" $NetBSD: icmp6.4,v 1.6 2002/02/13 08:17:35 ross Exp $ 2.\" $KAME: icmp6.4,v 1.3 2000/11/24 08:44:40 itojun Exp $ 3.\" 4.\" Copyright (C) 1999 WIDE Project. 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the project nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" Copyright (c) 1986, 1991, 1993 32.\" The Regents of the University of California. All rights reserved. 33.\" 34.\" Redistribution and use in source and binary forms, with or without 35.\" modification, are permitted provided that the following conditions 36.\" are met: 37.\" 1. Redistributions of source code must retain the above copyright 38.\" notice, this list of conditions and the following disclaimer. 39.\" 2. Redistributions in binary form must reproduce the above copyright 40.\" notice, this list of conditions and the following disclaimer in the 41.\" documentation and/or other materials provided with the distribution. 42.\" 3. All advertising materials mentioning features or use of this software 43.\" must display the following acknowledgement: 44.\" This product includes software developed by the University of 45.\" California, Berkeley and its contributors. 46.\" 4. Neither the name of the University nor the names of its contributors 47.\" may be used to endorse or promote products derived from this software 48.\" without specific prior written permission. 49.\" 50.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 51.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 53.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 54.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 58.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60.\" SUCH DAMAGE. 61.\" 62.Dd December 17, 1999 63.Dt ICMP6 4 64.Os 65.Sh NAME 66.Nm icmp6 67.Nd Internet Control Message Protocol for IPv6 68.Sh SYNOPSIS 69.Fd #include \*[Lt]sys/socket.h\*[Gt] 70.Fd #include \*[Lt]netinet/in.h\*[Gt] 71.Fd #include \*[Lt]netinet/icmp6.h\*[Gt] 72.Ft int 73.Fn socket AF_INET6 SOCK_RAW proto 74.Sh DESCRIPTION 75.Tn ICMPv6 76is the error and control message protocol used 77by 78.Tn IPv6 79and the Internet protocol family. 80It may be accessed through a 81.Dq raw socket 82for network monitoring and diagnostic functions. 83The 84.Fa proto 85parameter to the socket call to create an 86.Tn ICMPv6 87socket is obtained from 88.Xr getprotobyname 3 , 89or you can use 90.Dv IPPROTO_ICMPV6 . 91.Tn ICMPv6 92sockets are connectionless, and are normally used with the 93.Xr sendto 2 94and 95.Xr recvfrom 2 96calls, though the 97.Xr connect 2 98call may also be used to fix the destination for future packets 99(in which case the 100.Xr read 2 101or 102.Xr recv 2 103and 104.Xr write 2 105or 106.Xr send 2 107system calls may be used). 108.Pp 109Outgoing packets automatically have an 110.Tn IPv6 111header prepended to them 112.Pq based on the destination address . 113.Tn ICMPv6 114pseudo header checksum field 115.Pq Li icmp6_cksum 116will be filled automatically by the kernel. 117Incoming packets are received without the 118.Tn IPv6 119header nor IPv6 extension headers. 120Notice that this behavior is opposite from 121.Tn IPv4 122raw sockets and. 123.Tn ICMPv4 124sockets. 125.Ss ICMPv6 type/code filter 126Each 127.Tn ICMPv6 128raw socket has an associated filter whose datatype is defined as 129.Li struct icmp6_filter ; 130.Pp 131This structure, along with the macros and constants defined later in 132this section, are defined as a result of including the 133.Aq Li netinet/icmp6.h 134header. 135.Pp 136The current filter is fetched and stored using 137.Xr getsockopt 2 138and 139.Xr setsockopt 2 140with a level of 141.Dv IPPROTO_ICMPV6 142and an option name of 143.Dv ICMP6_FILTER . 144.Pp 145Six macros operate on an icmp6_filter structure: 146.\" is "Fn" legal for macros? 147.Bl -item -compact -offset indent 148.It Ft void 149.Fn ICMP6_FILTER_SETPASSALL "struct icmp6_filter *" 150.It Ft void 151.Fn ICMP6_FILTER_SETBLOCKALL "struct icmp6_filter *" 152.It Ft void 153.Fn ICMP6_FILTER_SETPASS "int" "struct icmp6_filter *" 154.It Ft void 155.Fn ICMP6_FILTER_SETBLOCK "int" "struct icmp6_filter *" 156.It Ft int 157.Fn ICMP6_FILTER_WILLPASS "int" "const struct icmp6_filter *" 158.It Ft int 159.Fn ICMP6_FILTER_WILLBLOCK "int" "const struct icmp6_filter *" 160.El 161.Pp 162The first argument to the last four macros 163.Pq an integer 164is an 165.Tn ICMPv6 166message type, between 0 and 255. 167The pointer argument to all six 168macros is a pointer to a filter that is modified by the first four 169macros examined by the last two macros. 170.Pp 171The first two macros, 172.Dv SETPASSALL 173and 174.Dv SETBLOCKALL , 175let us specify that 176all 177.Tn ICMPv6 messages are passed to the application or that all 178.Tn ICMPv6 179messages are blocked from being passed to the application. 180.Pp 181The next two macros, 182.Dv SETPASS 183and 184.Dv SETBLOCK , 185let us specify that 186messages of a given 187.Tn ICMPv6 188type should be passed to the application 189or not passed to the application 190.Pq blocked . 191.Pp 192The final two macros, 193.Dv WILLPASS 194and 195.Dv WILLBLOCK , 196return true or false 197depending whether the specified message type is passed to the 198application or blocked from being passed to the application by the 199filter pointed to by the second argument. 200.Pp 201When an 202.Tn ICMPv6 203raw socket is created, it will by default pass all 204.Tn ICMPv6 205message types to the application. 206.Pp 207For further discussions see RFC2292. 208.\" 209.Sh DIAGNOSTICS 210A socket operation may fail with one of the following errors returned: 211.Bl -tag -width [EADDRNOTAVAIL] 212.It Bq Er EISCONN 213when trying to establish a connection on a socket which 214already has one, or when trying to send a datagram with the destination 215address specified and the socket is already connected; 216.It Bq Er ENOTCONN 217when trying to send a datagram, but 218no destination address is specified, and the socket hasn't been 219connected; 220.It Bq Er ENOBUFS 221when the system runs out of memory for 222an internal data structure; 223.It Bq Er EADDRNOTAVAIL 224when an attempt is made to create a 225socket with a network address for which no network interface exists. 226.El 227.Sh SEE ALSO 228.Xr recv 2 , 229.Xr send 2 , 230.Xr inet6 4 , 231.Xr intro 4 , 232.Xr ip6 4 233.Rs 234.%A W. Stevens 235.%A M. Thomas 236.%R RFC 237.%N 2292 238.%D February 1998 239.%T "Advanced Sockets API for IPv6" 240.Re 241.Rs 242.%A A. Conta 243.%A S. Deering 244.%R RFC 245.%N 2463 246.%D December 1998 247.%T "Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification" 248.Re 249.Sh HISTORY 250The implementation is based on KAME stack 251.Po 252which is descendant of WIDE hydrangea IPv6 stack kit 253.Pc . 254.Pp 255Part of the document was shamelessly copied from RFC2292. 256