xref: /freebsd-13-stable/share/man/man4/icmp.4 (revision 6bcc3ae6d61d2a4d972bbd839016ab63c6394935)
1.\" Copyright (c) 1986, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     @(#)icmp.4	8.1 (Berkeley) 6/5/93
29.\"
30.Dd December 11, 2024
31.Dt ICMP 4
32.Os
33.Sh NAME
34.Nm icmp
35.Nd Internet Control Message Protocol
36.Sh SYNOPSIS
37.In sys/types.h
38.In sys/socket.h
39.In netinet/in.h
40.Ft int
41.Fn socket AF_INET SOCK_RAW proto
42.Sh DESCRIPTION
43.Tn ICMP
44is the error and control message protocol used
45by
46.Tn IP
47and the Internet protocol family.
48It may be accessed
49through a
50.Dq raw socket
51for network monitoring
52and diagnostic functions.
53The
54.Fa proto
55parameter to the socket call to create an
56.Tn ICMP
57socket
58is obtained from
59.Xr getprotobyname 3 .
60.Tn ICMP
61sockets are connectionless,
62and are normally used with the
63.Xr sendto 2
64and
65.Xr recvfrom 2
66calls, though the
67.Xr connect 2
68call may also be used to fix the destination for future
69packets (in which case the
70.Xr read 2
71or
72.Xr recv 2
73and
74.Xr write 2
75or
76.Xr send 2
77system calls may be used).
78.Pp
79Outgoing packets automatically have an
80.Tn IP
81header prepended to
82them (based on the destination address).
83Incoming packets are received with the
84.Tn IP
85header and options intact.
86.Ss Types
87ICMP messages are classified according to the type and code fields
88present in the ICMP header.
89The abbreviations for the types and codes may be used in rules in
90.Xr pf.conf 5 .
91The following types are defined:
92.Bl -column x xxxxxxxxxxxx -offset indent
93.It Sy Num Ta Sy Abbrev. Ta Sy Description
94.It 0 Ta echorep Ta "Echo reply"
95.It 3 Ta unreach Ta "Destination unreachable"
96.It 4 Ta squench Ta "Packet loss, slow down"
97.It 5 Ta redir Ta "Shorter route exists"
98.It 6 Ta althost Ta "Alternate host address"
99.It 8 Ta echoreq Ta "Echo request"
100.It 9 Ta routeradv Ta "Router advertisement"
101.It 10 Ta routersol Ta "Router solicitation"
102.It 11 Ta timex Ta "Time exceeded"
103.It 12 Ta paramprob Ta "Invalid IP header"
104.It 13 Ta timereq Ta "Timestamp request"
105.It 14 Ta timerep Ta "Timestamp reply"
106.It 15 Ta inforeq Ta "Information request"
107.It 16 Ta inforep Ta "Information reply"
108.It 17 Ta maskreq Ta "Address mask request"
109.It 18 Ta maskrep Ta "Address mask reply"
110.It 30 Ta trace Ta Traceroute
111.It 31 Ta dataconv Ta "Data conversion problem"
112.It 32 Ta mobredir Ta "Mobile host redirection"
113.It 33 Ta ipv6-where Ta "IPv6 where-are-you"
114.It 34 Ta ipv6-here Ta "IPv6 i-am-here"
115.It 35 Ta mobregreq Ta "Mobile registration request"
116.It 36 Ta mobregrep Ta "Mobile registration reply"
117.It 39 Ta skip Ta SKIP
118.It 40 Ta photuris Ta Photuris
119.El
120.Pp
121The following codes are defined:
122.Bl -column x xxxxxxxxxxxx xxxxxxxx -offset indent
123.It Sy Num Ta Sy Abbrev. Ta Sy Type Ta Sy Description
124.It 0 Ta net-unr Ta unreach Ta "Network unreachable"
125.It 1 Ta host-unr Ta unreach Ta "Host unreachable"
126.It 2 Ta proto-unr Ta unreach Ta "Protocol unreachable"
127.It 3 Ta port-unr Ta unreach Ta "Port unreachable"
128.It 4 Ta needfrag Ta unreach Ta "Fragmentation needed but DF bit set"
129.It 5 Ta srcfail Ta unreach Ta "Source routing failed"
130.It 6 Ta net-unk Ta unreach Ta "Network unknown"
131.It 7 Ta host-unk Ta unreach Ta "Host unknown"
132.It 8 Ta isolate Ta unreach Ta "Host isolated"
133.It 9 Ta net-prohib Ta unreach Ta "Network administratively prohibited"
134.It 10 Ta host-prohib Ta unreach Ta "Host administratively prohibited"
135.It 11 Ta net-tos Ta unreach Ta "Invalid TOS for network"
136.It 12 Ta host-tos Ta unreach Ta "Invalid TOS for host"
137.It 13 Ta filter-prohib Ta unreach Ta "Prohibited access"
138.It 14 Ta host-preced Ta unreach Ta "Precedence violation"
139.It 15 Ta cutoff-preced Ta unreach Ta "Precedence cutoff"
140.It 0 Ta redir-net Ta redir Ta "Shorter route for network"
141.It 1 Ta redir-host Ta redir Ta "Shorter route for host"
142.It 2 Ta redir-tos-net Ta redir Ta "Shorter route for TOS and network"
143.It 3 Ta redir-tos-host Ta redir Ta "Shorter route for TOS and host"
144.It 0 Ta normal-adv Ta routeradv Ta "Normal advertisement"
145.It 16 Ta common-adv Ta routeradv Ta "Selective advertisement"
146.It 0 Ta transit Ta timex Ta "Time exceeded in transit"
147.It 1 Ta reassemb Ta timex Ta "Time exceeded in reassembly"
148.It 0 Ta badhead Ta paramprob Ta "Invalid option pointer"
149.It 1 Ta optmiss Ta paramprob Ta "Missing option"
150.It 2 Ta badlen Ta paramprob Ta "Invalid length"
151.It 1 Ta unknown-ind Ta photuris Ta "Unknown security index"
152.It 2 Ta auth-fail Ta photuris Ta "Authentication failed"
153.It 3 Ta decrypt-fail Ta photuris Ta "Decryption failed"
154.El
155.Ss MIB Variables
156The
157.Tn ICMP
158protocol implements a number of variables in the
159.Va net.inet.icmp
160branch of the
161.Xr sysctl 3
162MIB.
163.Bl -tag -width ".Va icmplim_output"
164.It Va maskrepl
165.Pq Vt boolean
166Enable/disable replies to ICMP Address Mask Request packets.
167Defaults to false.
168.It Va maskfake
169.Pq Vt "unsigned integer"
170When
171.Va maskrepl
172is set and this value is non-zero,
173it will be used instead of the real address mask when
174the system replies to an ICMP Address Mask Request packet.
175Defaults to 0.
176.It Va icmplim
177.Pq Vt unsigned integer
178Mean rate limit for replies in packets/second.
179The actual limit is
180.Va icmplim
181plus a random jitter limited by
182.Va icmplim_jitter .
183If set to zero, no limiting will occur.
184Defaults to 200.
185.It Va icmplim_jitter
186.Pq Vt unsigned integer
187A random jitter between the negative of
188.Va icmplim_jitter
189and
190.Va icmplim_jitter
191is applied to
192.Va icmplim
193for limiting the sending rate of replies.
194.Va icmplim_jitter
195must be smaller than
196.Va icmplim ,
197if
198.Va icmplim
199is not zero.
200If set to zero, no jitter will be applied.
201Defaults to 16.
202.It Va icmplim_output
203.Pq Vt boolean
204Enable/disable logging of ICMP replies bandwidth limiting.
205Defaults to true.
206.It Va drop_redirect
207.Pq Vt boolean
208Enable/disable dropping of ICMP Redirect packets.
209Defaults to false.
210.It Va log_redirect
211.Pq Vt boolean
212Enable/disable logging of ICMP Redirect packets.
213Defaults to false.
214.It Va bmcastecho
215.Pq Vt boolean
216Enable/disable ICMP replies received via broadcast or multicast.
217Defaults to false.
218.It Va reply_src
219.Pq Vt str
220An interface name used for the ICMP reply source in response to packets
221which are not directly addressed to us.
222By default continue with normal source selection.
223.It Va reply_from_interface
224.Pq Vt boolean
225Use the IP address of the interface the packet came through in for
226responses to packets which are not directly addressed to us.
227If enabled, this rule is processed before all others.
228By default, continue with normal source selection.
229Enabling this option is particularly useful on routers because it
230makes external traceroutes show the actual path a packet has taken
231instead of the possibly different return path.
232.It Va quotelen
233.Pq Vt integer
234Number of bytes from original packet to quote in ICMP reply.
235This number is internally enforced to be at least 8 bytes (per RFC792)
236and at most the maximal space left in the ICMP reply mbuf.
237.It Va tstamprepl
238.Pq Vt boolean
239Enable/disable replies to ICMP Timestamp packets.
240Defaults to true.
241.El
242.Sh ERRORS
243A socket operation may fail with one of the following errors returned:
244.Bl -tag -width Er
245.It Bq Er EISCONN
246when trying to establish a connection on a socket which
247already has one, or when trying to send a datagram with the destination
248address specified and the socket is already connected;
249.It Bq Er ENOTCONN
250when trying to send a datagram, but
251no destination address is specified, and the socket has not been
252connected;
253.It Bq Er ENOBUFS
254when the system runs out of memory for
255an internal data structure;
256.It Bq Er EADDRNOTAVAIL
257when an attempt is made to create a
258socket with a network address for which no network interface
259exists.
260.El
261.Sh SEE ALSO
262.Xr recv 2 ,
263.Xr send 2 ,
264.Xr inet 4 ,
265.Xr intro 4 ,
266.Xr ip 4 ,
267.Xr pf.conf 5
268.Sh HISTORY
269The
270.Nm
271protocol appeared in
272.Bx 4.3 .
273