xref: /netbsd-src/share/man/man4/icmp6.4 (revision 3b01aba77a7a698587faaae455bbfe740923c1f5)
1.\"	$NetBSD: icmp6.4,v 1.3 2001/06/12 12:00:19 wiz 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."
66.Sh NAME
67.Nm icmp6
68.Nd Internet Control Message Protocol for IPv6
69."
70.Sh SYNOPSIS
71.Fd #include <sys/socket.h>
72.Fd #include <netinet/in.h>
73.Fd #include <netinet/icmp6.h>
74.Ft int
75.Fn socket AF_INET6 SOCK_RAW proto
76."
77.Sh DESCRIPTION
78.Tn ICMPv6
79is the error and control message protocol used
80by
81.Tn IPv6
82and the Internet protocol family.
83It may be accessed through a
84.Dq raw socket
85for network monitoring and diagnostic functions.
86The
87.Fa proto
88parameter to the socket call to create an
89.Tn ICMPv6
90socket is obtained from
91.Xr getprotobyname 3 ,
92or you can use
93.Dv IPPROTO_ICMPV6 .
94.Tn ICMPv6
95sockets are connectionless, and are normally used with the
96.Xr sendto 2
97and
98.Xr recvfrom 2
99calls, though the
100.Xr connect 2
101call may also be used to fix the destination for future packets
102(in which case the
103.Xr read 2
104or
105.Xr recv 2
106and
107.Xr write 2
108or
109.Xr send 2
110system calls may be used).
111.Pp
112Outgoing packets automatically have an
113.Tn IPv6
114header prepended to them
115.Pq based on the destination address .
116.Tn ICMPv6
117pseudo header checksum field
118.Pq Li icmp6_cksum
119will be filled automatically by the kernel.
120Incoming packets are received without the
121.Tn IPv6
122header nor IPv6 extension headers.
123Notice that this behavior is opposite from
124.Tn IPv4
125raw sockets and.
126.Tn ICMPv4
127sockets.
128.Pp
129.Ss ICMPv6 type/code filter
130Each
131.Tn ICMPv6
132raw socket has an associated filter whose datatype is defined as
133.Li struct icmp6_filter ;
134.Pp
135This structure, along with the macros and constants defined later in
136this section, are defined as a result of including the
137.Aq Li netinet/icmp6.h
138header.
139.Pp
140The current filter is fetched and stored using
141.Xr getsockopt 2
142and
143.Xr setsockopt 2
144with a level of
145.Dv IPPROTO_ICMPV6
146and an option name of
147.Dv ICMP6_FILTER .
148.Pp
149Six macros operate on an icmp6_filter structure:
150.\" is "Fn" legal for macros?
151.Bl -item -compact -offset indent
152.It Ft void
153.Fn ICMP6_FILTER_SETPASSALL "struct icmp6_filter *"
154.It Ft void
155.Fn ICMP6_FILTER_SETBLOCKALL "struct icmp6_filter *"
156.It Ft void
157.Fn ICMP6_FILTER_SETPASS "int" "struct icmp6_filter *"
158.It Ft void
159.Fn ICMP6_FILTER_SETBLOCK "int" "struct icmp6_filter *"
160.It Ft int
161.Fn ICMP6_FILTER_WILLPASS "int" "const struct icmp6_filter *"
162.It Ft int
163.Fn ICMP6_FILTER_WILLBLOCK "int" "const struct icmp6_filter *"
164.El
165.Pp
166The first argument to the last four macros
167.Pq an integer
168is an
169.Tn ICMPv6
170message type, between 0 and 255.
171The pointer argument to all six
172macros is a pointer to a filter that is modified by the first four
173macros examined by the last two macros.
174.Pp
175The first two macros,
176.Dv SETPASSALL
177and
178.Dv SETBLOCKALL ,
179let us specify that
180all
181.Tn ICMPv6 messages are passed to the application or that all
182.Tn ICMPv6
183messages are blocked from being passed to the application.
184.Pp
185The next two macros,
186.Dv SETPASS
187and
188.Dv SETBLOCK ,
189let us specify that
190messages of a given
191.Tn ICMPv6
192type should be passed to the application
193or not passed to the application
194.Pq blocked .
195.Pp
196The final two macros,
197.Dv WILLPASS
198and
199.Dv WILLBLOCK ,
200return true or false
201depending whether the specified message type is passed to the
202application or blocked from being passed to the application by the
203filter pointed to by the second argument.
204.Pp
205When an
206.Tn ICMPv6
207raw socket is created, it will by default pass all
208.Tn ICMPv6
209message types to the application.
210.Pp
211For further discussions see RFC2292.
212.\"
213.Sh DIAGNOSTICS
214A socket operation may fail with one of the following errors returned:
215.Bl -tag -width [EADDRNOTAVAIL]
216.It Bq Er EISCONN
217when trying to establish a connection on a socket which
218already has one, or when trying to send a datagram with the destination
219address specified and the socket is already connected;
220.It Bq Er ENOTCONN
221when trying to send a datagram, but
222no destination address is specified, and the socket hasn't been
223connected;
224.It Bq Er ENOBUFS
225when the system runs out of memory for
226an internal data structure;
227.It Bq Er EADDRNOTAVAIL
228when an attempt is made to create a
229socket with a network address for which no network interface exists.
230.El
231."
232.Sh SEE ALSO
233.Xr send 2 ,
234.Xr recv 2 ,
235.Xr intro 4 ,
236.Xr inet6 4 ,
237.Xr ip6 4
238.Rs
239.%A W. Stevens
240.%A M. Thomas
241.%R RFC
242.%N 2292
243.%D February 1998
244.%T "Advanced Sockets API for IPv6"
245.Re
246.Rs
247.%A A. Conta
248.%A S. Deering
249.%R RFC
250.%N 2463
251.%D December 1998
252.%T "Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification"
253.Re
254."
255.Sh HISTORY
256The implementation is based on KAME stack
257.Po
258which is descendant of WIDE hydrangea IPv6 stack kit
259.Pc .
260.Pp
261Part of the document was shamelessly copied from RFC2292.
262