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