xref: /openbsd-src/share/man/man4/icmp6.4 (revision 4bf9eb95b5742a80d214e44bae1cd590f4112945)
1*4bf9eb95Sflorian.\"	$OpenBSD: icmp6.4,v 1.31 2017/08/03 17:36:06 florian Exp $
2b61b837cSitojun.\"	$KAME: icmp6.4,v 1.6 2004/12/27 05:30:56 itojun Exp $
3b61b837cSitojun.\"
4f4934894Sjaredy.\" Copyright (c) 1986, 1991, 1993
5f4934894Sjaredy.\"     The Regents of the University of California.  All rights reserved.
6f4934894Sjaredy.\"
7f4934894Sjaredy.\" Redistribution and use in source and binary forms, with or without
8f4934894Sjaredy.\" modification, are permitted provided that the following conditions
9f4934894Sjaredy.\" are met:
10f4934894Sjaredy.\" 1. Redistributions of source code must retain the above copyright
11f4934894Sjaredy.\"    notice, this list of conditions and the following disclaimer.
12f4934894Sjaredy.\" 2. Redistributions in binary form must reproduce the above copyright
13f4934894Sjaredy.\"    notice, this list of conditions and the following disclaimer in the
14f4934894Sjaredy.\"    documentation and/or other materials provided with the distribution.
15f4934894Sjaredy.\" 3. Neither the name of the University nor the names of its contributors
16f4934894Sjaredy.\"    may be used to endorse or promote products derived from this software
17f4934894Sjaredy.\"    without specific prior written permission.
18f4934894Sjaredy.\"
19f4934894Sjaredy.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20f4934894Sjaredy.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21f4934894Sjaredy.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22f4934894Sjaredy.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23f4934894Sjaredy.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24f4934894Sjaredy.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25f4934894Sjaredy.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26f4934894Sjaredy.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27f4934894Sjaredy.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28f4934894Sjaredy.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29f4934894Sjaredy.\" SUCH DAMAGE.
30*4bf9eb95Sflorian.Dd $Mdocdate: August 3 2017 $
31f4934894Sjaredy.Dt ICMP6 4
32f4934894Sjaredy.Os
33f4934894Sjaredy.Sh NAME
34f4934894Sjaredy.Nm icmp6
35f4934894Sjaredy.Nd Internet Control Message Protocol for IPv6
36f4934894Sjaredy.Sh SYNOPSIS
37f4934894Sjaredy.In sys/socket.h
38f4934894Sjaredy.In netinet/in.h
39f4934894Sjaredy.In netinet/icmp6.h
40f4934894Sjaredy.Ft int
41f4934894Sjaredy.Fn socket AF_INET6 SOCK_RAW IPPROTO_ICMPV6
42f4934894Sjaredy.Sh DESCRIPTION
43f4934894SjaredyICMPv6 is the error and control message protocol used by IPv6 and the
44f4934894SjaredyIPv6 protocol family (see
45f4934894Sjaredy.Xr ip6 4
46f4934894Sjaredyand
47f4934894Sjaredy.Xr inet6 4 ) .
48f4934894SjaredyIt may be accessed through a
49f4934894Sjaredy.Dq raw socket
50f4934894Sjaredyfor network monitoring and diagnostic functions.
51f4934894Sjaredy.Pp
52f4934894SjaredyThe
53f4934894Sjaredy.Fa proto
54f4934894Sjaredyparameter to the
55f4934894Sjaredy.Xr socket 2
56f4934894Sjaredycall to create an ICMPv6 socket may be obtained from
57f4934894Sjaredy.Xr getprotobyname 3 .
58f4934894SjaredyICMPv6 sockets are connectionless, and are normally used with the
59f4934894Sjaredy.Xr sendto 2
60f4934894Sjaredyand
61f4934894Sjaredy.Xr recvfrom 2
62f4934894Sjaredycalls, though the
63f4934894Sjaredy.Xr connect 2
64f4934894Sjaredycall may also be used to fix the destination for future packets
65f4934894Sjaredy(in which case
66f4934894Sjaredy.Xr read 2
67f4934894Sjaredyor
68f4934894Sjaredy.Xr recv 2
69f4934894Sjaredyand
70f4934894Sjaredy.Xr write 2
71f4934894Sjaredyor
72f4934894Sjaredy.Xr send 2
73f4934894Sjaredysystem calls may be used).
74f4934894Sjaredy.Pp
75f4934894SjaredyOutgoing packets automatically have an IPv6 header prepended to them
76f4934894Sjaredy(based on the destination address).
77f4934894SjaredyIncoming packets on the socket are received with the IPv6 header and any
78f4934894Sjaredyextension headers removed.
79df5a36ebSjaredy.Ss Types
80df5a36ebSjaredyICMPv6 messages are classified according to the type and code fields
81df5a36ebSjaredypresent in the ICMPv6 header.
82df5a36ebSjaredyThe abbreviations for the types and codes may be used in rules in
83df5a36ebSjaredy.Xr pf.conf 5 .
84df5a36ebSjaredyThe following types are defined:
85e324319bSjmc.Bl -column "Num" "listendone" "Description" -offset indent
86e324319bSjmc.It Sy Num Ta Sy "Abbrev." Ta Sy Description
87df5a36ebSjaredy.It 1 Ta unreach Ta "Destination unreachable"
88df5a36ebSjaredy.It 2 Ta toobig Ta "Packet too big"
89df5a36ebSjaredy.It 3 Ta timex Ta "Time exceeded"
90df5a36ebSjaredy.It 4 Ta paramprob Ta "Invalid IPv6 header"
91df5a36ebSjaredy.It 128 Ta echoreq Ta "Echo service request"
92df5a36ebSjaredy.It 129 Ta echorep Ta "Echo service reply"
93df5a36ebSjaredy.It 130 Ta groupqry Ta "Group membership query"
94df5a36ebSjaredy.It 130 Ta listqry Ta "Multicast listener query"
95df5a36ebSjaredy.It 131 Ta grouprep Ta "Group membership report"
96df5a36ebSjaredy.It 131 Ta listenrep Ta "Multicast listener report"
97df5a36ebSjaredy.It 132 Ta groupterm Ta "Group membership termination"
98b5137cf0Sjmc.It 132 Ta listendone Ta "Multicast listener done"
99df5a36ebSjaredy.It 133 Ta routersol Ta "Router solicitation"
100df5a36ebSjaredy.It 134 Ta routeradv Ta "Router advertisement"
101df5a36ebSjaredy.It 135 Ta neighbrsol Ta "Neighbor solicitation"
102df5a36ebSjaredy.It 136 Ta neighbradv Ta "Neighbor advertisement"
103df5a36ebSjaredy.It 137 Ta redir Ta "Shorter route exists"
104df5a36ebSjaredy.It 138 Ta routrrenum Ta "Route renumbering"
105df5a36ebSjaredy.It 139 Ta fqdnreq Ta "FQDN query"
106df5a36ebSjaredy.It 139 Ta niqry Ta "Node information query"
107df5a36ebSjaredy.It 139 Ta wrureq Ta "Who-are-you request"
108df5a36ebSjaredy.It 140 Ta fqdnrep Ta "FQDN reply"
109df5a36ebSjaredy.It 140 Ta nirep Ta "Node information reply"
110df5a36ebSjaredy.It 140 Ta wrurep Ta "Who-are-you reply"
111df5a36ebSjaredy.It 200 Ta mtraceresp Ta "mtrace response"
112df5a36ebSjaredy.It 201 Ta mtrace Ta "mtrace messages"
113df5a36ebSjaredy.El
114f4934894Sjaredy.Pp
115df5a36ebSjaredyThe following codes are defined:
116e324319bSjmc.Bl -column "Num" "redironlink" "paramprob" "Description" -offset indent
117e324319bSjmc.It Sy Num Ta Sy "Abbrev." Ta Sy Type Ta Sy Description
118df5a36ebSjaredy.It 0 Ta noroute-unr Ta unreach Ta "No route to destination"
119df5a36ebSjaredy.It 1 Ta admin-unr Ta unreach Ta "Administratively prohibited"
120df5a36ebSjaredy.It 2 Ta beyond-unr Ta unreach Ta "Beyond scope of source address"
121df5a36ebSjaredy.It 3 Ta addr-unr Ta unreach Ta "Address unreachable"
122df5a36ebSjaredy.It 4 Ta port-unr Ta unreach Ta "Port unreachable"
123df5a36ebSjaredy.It 0 Ta transit Ta timex Ta "Time exceeded in transit"
124df5a36ebSjaredy.It 1 Ta reassemb Ta timex Ta "Time exceeded in reassembly"
125df5a36ebSjaredy.It 0 Ta badhead Ta paramprob Ta "Erroneous header field"
126df5a36ebSjaredy.It 1 Ta nxthdr Ta paramprob Ta "Unrecognized next header"
1274fc43319Sjmc.It 2 Ta "" Ta paramprob Ta "Unrecognized option"
128df5a36ebSjaredy.It 0 Ta redironlink Ta redir Ta "Redirection to on-link node"
129df5a36ebSjaredy.It 1 Ta redirrouter Ta redir Ta "Redirection to better router"
130df5a36ebSjaredy.El
131df5a36ebSjaredy.Ss Headers
132f4934894SjaredyAll ICMPv6 messages are prefixed with an ICMPv6 header.
133f4934894SjaredyThis header corresponds to the
134f4934894Sjaredy.Vt icmp6_hdr
135f4934894Sjaredystructure and has the following definition:
136f4934894Sjaredy.Bd -literal -offset indent
137f4934894Sjaredystruct icmp6_hdr {
138f4934894Sjaredy	u_int8_t	icmp6_type;	/* type field */
139f4934894Sjaredy	u_int8_t	icmp6_code;	/* code field */
140f4934894Sjaredy	u_int16_t	icmp6_cksum;	/* checksum field */
141f4934894Sjaredy	union {
142f4934894Sjaredy		u_int32_t icmp6_un_data32[1]; /* type-specific */
143f4934894Sjaredy		u_int16_t icmp6_un_data16[2]; /* type-specific */
144f4934894Sjaredy		u_int8_t  icmp6_un_data8[4];  /* type-specific */
145f4934894Sjaredy	} icmp6_dataun;
146f4934894Sjaredy} __packed;
147f4934894Sjaredy
148f4934894Sjaredy#define icmp6_data32	icmp6_dataun.icmp6_un_data32
149f4934894Sjaredy#define icmp6_data16	icmp6_dataun.icmp6_un_data16
150f4934894Sjaredy#define icmp6_data8	icmp6_dataun.icmp6_un_data8
151f4934894Sjaredy#define icmp6_pptr	icmp6_data32[0]	/* parameter prob */
152f4934894Sjaredy#define icmp6_mtu	icmp6_data32[0]	/* packet too big */
153f4934894Sjaredy#define icmp6_id	icmp6_data16[0]	/* echo request/reply */
154f4934894Sjaredy#define icmp6_seq	icmp6_data16[1]	/* echo request/reply */
155f4934894Sjaredy#define icmp6_maxdelay	icmp6_data16[0]	/* mcast group membership*/
156f4934894Sjaredy.Ed
157f4934894Sjaredy.Pp
158f4934894Sjaredy.Va icmp6_type
159f4934894Sjaredydescribes the type of the message.
160f4934894SjaredySuitable values are defined in
161369bef3aSschwarze.In netinet/icmp6.h .
162f4934894Sjaredy.Va icmp6_code
163f4934894Sjaredydescribes the sub-type of the message and depends on
164f4934894Sjaredy.Va icmp6_type .
165f4934894Sjaredy.Va icmp6_cksum
166f4934894Sjaredycontains the checksum for the message and is filled in by the
167f4934894Sjaredykernel on outgoing messages.
168f4934894SjaredyThe other fields are used for type-specific purposes.
169df5a36ebSjaredy.Ss Filters
170f4934894SjaredyBecause of the extra functionality of ICMPv6 in comparison to ICMPv4,
171f4934894Sjaredya larger number of messages may be potentially received on an ICMPv6
172f4934894Sjaredysocket.
173f4934894SjaredyInput filters may therefore be used to restrict input to a subset of the
174f4934894Sjaredyincoming ICMPv6 messages so only interesting messages are returned by the
175f4934894Sjaredy.Xr recv 2
176f4934894Sjaredyfamily of calls to an application.
177f4934894Sjaredy.Pp
178f4934894SjaredyThe
179f4934894Sjaredy.Vt icmp6_filter
180f4934894Sjaredystructure may be used to refine the input message set according to the
181f4934894SjaredyICMPv6 type.
182f4934894SjaredyBy default, all messages types are allowed on newly created raw ICMPv6
183f4934894Sjaredysockets.
184f4934894SjaredyThe following macros may be used to refine the input set:
185f4934894Sjaredy.Bl -tag -width Ds
186f4934894Sjaredy.It Fn "void ICMP6_FILTER_SETPASSALL" "struct icmp6_filter *filterp"
187f4934894SjaredyAllow all incoming messages.
188f4934894Sjaredy.Va filterp
189f4934894Sjaredyis modified to allow all message types.
190f4934894Sjaredy.It Fn "void ICMP6_FILTER_SETBLOCKALL" "struct icmp6_filter *filterp"
191f4934894SjaredyIgnore all incoming messages.
192f4934894Sjaredy.Va filterp
193f4934894Sjaredyis modified to ignore all message types.
194f4934894Sjaredy.It Fn "void ICMP6_FILTER_SETPASS" "int type" \
195f4934894Sjaredy    "struct icmp6_filter *filterp"
196f4934894SjaredyAllow ICMPv6 messages with the given
197f4934894Sjaredy.Fa type .
198f4934894Sjaredy.Va filterp
199f4934894Sjaredyis modified to allow such messages.
200f4934894Sjaredy.It Fn "void ICMP6_FILTER_SETBLOCK" "int type" \
201f4934894Sjaredy    "struct icmp6_filter *filterp"
202f4934894SjaredyIgnore ICMPv6 messages with the given
203f4934894Sjaredy.Fa type .
204f4934894Sjaredy.Va filterp
205f4934894Sjaredyis modified to ignore such messages.
206f4934894Sjaredy.It Fn "int ICMP6_FILTER_WILLPASS" "int type" \
207f4934894Sjaredy    "const struct icmp6_filter *filterp"
208f4934894SjaredyDetermine if the given filter will allow an ICMPv6 message of the given
209f4934894Sjaredytype.
210f4934894Sjaredy.It Fn "int ICMP6_FILTER_WILLBLOCK" "int type" \
211f4934894Sjaredy    "const struct icmp6_filter *filterp"
212f4934894SjaredyDetermine if the given filter will ignore an ICMPv6 message of the given
213f4934894Sjaredytype.
214f4934894Sjaredy.El
215f4934894Sjaredy.Pp
216f4934894SjaredyThe
217f4934894Sjaredy.Xr getsockopt 2
218f4934894Sjaredyand
219f4934894Sjaredy.Xr setsockopt 2
220f4934894Sjaredycalls may be used to obtain and install the filter on ICMPv6 sockets at
221f4934894Sjaredyoption level
222f4934894Sjaredy.Dv IPPROTO_ICMPV6
223f4934894Sjaredyand name
2246e164ab3Sjca.Dv ICMP6_FILTER
225f4934894Sjaredywith a pointer to the
226f4934894Sjaredy.Vt icmp6_filter
227f4934894Sjaredystructure as the option value.
228f4934894Sjaredy.Sh SEE ALSO
229f4934894Sjaredy.Xr getsockopt 2 ,
230f4934894Sjaredy.Xr recv 2 ,
231f4934894Sjaredy.Xr send 2 ,
232f4934894Sjaredy.Xr setsockopt 2 ,
233f4934894Sjaredy.Xr socket 2 ,
234f4934894Sjaredy.Xr getprotobyname 3 ,
235f4934894Sjaredy.Xr inet6 4 ,
236f4934894Sjaredy.Xr ip6 4 ,
237f4934894Sjaredy.Xr netintro 4
23804152b69Sjmc.Sh STANDARDS
239f4934894Sjaredy.Rs
2404339cb21Sjmc.%A W. Stevens
2414339cb21Sjmc.%A M. Thomas
2424339cb21Sjmc.%A E. Nordmark
2434339cb21Sjmc.%A T. Jinmei
2444339cb21Sjmc.%D May 2003
24517fd6cd1Sjmc.%R RFC 3542
24617fd6cd1Sjmc.%T Advanced Sockets Application Program Interface (API) for IPv6
24717fd6cd1Sjmc.Re
24804152b69Sjmc.Pp
24917fd6cd1Sjmc.Rs
25017fd6cd1Sjmc.%A A. Conta
25117fd6cd1Sjmc.%A S. Deering
25217fd6cd1Sjmc.%A M. Gupta
25317fd6cd1Sjmc.%D March 2006
25417fd6cd1Sjmc.%R RFC 4443
25517fd6cd1Sjmc.%T "Internet Control Message Protocol (ICMPv6) for the Internet" \
25617fd6cd1Sjmc    "Protocol Version 6 (IPv6) Specification"
2574339cb21Sjmc.Re
258