xref: /freebsd/share/man/man4/icmp.4 (revision 38a52bd3b5cac3da6f7f6eef3dd050e6aa08ebb3)
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.\" $FreeBSD$
30.\"
31.Dd August 1, 2022
32.Dt ICMP 4
33.Os
34.Sh NAME
35.Nm icmp
36.Nd Internet Control Message Protocol
37.Sh SYNOPSIS
38.In sys/types.h
39.In sys/socket.h
40.In netinet/in.h
41.Ft int
42.Fn socket AF_INET SOCK_RAW proto
43.Sh DESCRIPTION
44.Tn ICMP
45is the error and control message protocol used
46by
47.Tn IP
48and the Internet protocol family.
49It may be accessed
50through a
51.Dq raw socket
52for network monitoring
53and diagnostic functions.
54The
55.Fa proto
56parameter to the socket call to create an
57.Tn ICMP
58socket
59is obtained from
60.Xr getprotobyname 3 .
61.Tn ICMP
62sockets are connectionless,
63and are normally used with the
64.Xr sendto 2
65and
66.Xr recvfrom 2
67calls, though the
68.Xr connect 2
69call may also be used to fix the destination for future
70packets (in which case the
71.Xr read 2
72or
73.Xr recv 2
74and
75.Xr write 2
76or
77.Xr send 2
78system calls may be used).
79.Pp
80Outgoing packets automatically have an
81.Tn IP
82header prepended to
83them (based on the destination address).
84Incoming packets are received with the
85.Tn IP
86header and options intact.
87.Ss Types
88ICMP messages are classified according to the type and code fields
89present in the ICMP header.
90The abbreviations for the types and codes may be used in rules in
91.Xr pf.conf 5 .
92The following types are defined:
93.Bl -column x xxxxxxxxxxxx -offset indent
94.It Sy Num Ta Sy Abbrev. Ta Sy Description
95.It 0 Ta echorep Ta "Echo reply"
96.It 3 Ta unreach Ta "Destination unreachable"
97.It 4 Ta squench Ta "Packet loss, slow down"
98.It 5 Ta redir Ta "Shorter route exists"
99.It 6 Ta althost Ta "Alternate host address"
100.It 8 Ta echoreq Ta "Echo request"
101.It 9 Ta routeradv Ta "Router advertisement"
102.It 10 Ta routersol Ta "Router solicitation"
103.It 11 Ta timex Ta "Time exceeded"
104.It 12 Ta paramprob Ta "Invalid IP header"
105.It 13 Ta timereq Ta "Timestamp request"
106.It 14 Ta timerep Ta "Timestamp reply"
107.It 15 Ta inforeq Ta "Information request"
108.It 16 Ta inforep Ta "Information reply"
109.It 17 Ta maskreq Ta "Address mask request"
110.It 18 Ta maskrep Ta "Address mask reply"
111.It 30 Ta trace Ta Traceroute
112.It 31 Ta dataconv Ta "Data conversion problem"
113.It 32 Ta mobredir Ta "Mobile host redirection"
114.It 33 Ta ipv6-where Ta "IPv6 where-are-you"
115.It 34 Ta ipv6-here Ta "IPv6 i-am-here"
116.It 35 Ta mobregreq Ta "Mobile registration request"
117.It 36 Ta mobregrep Ta "Mobile registration reply"
118.It 39 Ta skip Ta SKIP
119.It 40 Ta photuris Ta Photuris
120.El
121.Pp
122The following codes are defined:
123.Bl -column x xxxxxxxxxxxx xxxxxxxx -offset indent
124.It Sy Num Ta Sy Abbrev. Ta Sy Type Ta Sy Description
125.It 0 Ta net-unr Ta unreach Ta "Network unreachable"
126.It 1 Ta host-unr Ta unreach Ta "Host unreachable"
127.It 2 Ta proto-unr Ta unreach Ta "Protocol unreachable"
128.It 3 Ta port-unr Ta unreach Ta "Port unreachable"
129.It 4 Ta needfrag Ta unreach Ta "Fragmentation needed but DF bit set"
130.It 5 Ta srcfail Ta unreach Ta "Source routing failed"
131.It 6 Ta net-unk Ta unreach Ta "Network unknown"
132.It 7 Ta host-unk Ta unreach Ta "Host unknown"
133.It 8 Ta isolate Ta unreach Ta "Host isolated"
134.It 9 Ta net-prohib Ta unreach Ta "Network administratively prohibited"
135.It 10 Ta host-prohib Ta unreach Ta "Host administratively prohibited"
136.It 11 Ta net-tos Ta unreach Ta "Invalid TOS for network"
137.It 12 Ta host-tos Ta unreach Ta "Invalid TOS for host"
138.It 13 Ta filter-prohib Ta unreach Ta "Prohibited access"
139.It 14 Ta host-preced Ta unreach Ta "Precedence violation"
140.It 15 Ta cutoff-preced Ta unreach Ta "Precedence cutoff"
141.It 0 Ta redir-net Ta redir Ta "Shorter route for network"
142.It 1 Ta redir-host Ta redir Ta "Shorter route for host"
143.It 2 Ta redir-tos-net Ta redir Ta "Shorter route for TOS and network"
144.It 3 Ta redir-tos-host Ta redir Ta "Shorter route for TOS and host"
145.It 0 Ta normal-adv Ta routeradv Ta "Normal advertisement"
146.It 16 Ta common-adv Ta routeradv Ta "Selective advertisement"
147.It 0 Ta transit Ta timex Ta "Time exceeded in transit"
148.It 1 Ta reassemb Ta timex Ta "Time exceeded in reassembly"
149.It 0 Ta badhead Ta paramprob Ta "Invalid option pointer"
150.It 1 Ta optmiss Ta paramprob Ta "Missing option"
151.It 2 Ta badlen Ta paramprob Ta "Invalid length"
152.It 1 Ta unknown-ind Ta photuris Ta "Unknown security index"
153.It 2 Ta auth-fail Ta photuris Ta "Authentication failed"
154.It 3 Ta decrypt-fail Ta photuris Ta "Decryption failed"
155.El
156.Ss MIB (sysctl) Variables
157The
158.Tn ICMP
159protocol implements a number of variables in the
160.Va net.inet.icmp
161branch of the
162.Xr sysctl 3
163MIB, which can also be read or modified with
164.Xr sysctl 8 .
165.Bl -tag -width ".Va icmplim_output"
166.It Va bmcastecho
167.Pq Vt boolean
168Enable/disable ICMP replies received via broadcast or multicast.
169Defaults to false.
170.It Va drop_redirect
171.Pq Vt boolean
172Enable/disable dropping of ICMP Redirect packets.
173Defaults to false.
174.It Va icmplim
175.Pq Vt integer
176Bandwidth limit for ICMP replies in packets/second.
177If set to zero, no limiting will occur.
178Defaults to 200.
179.It Va icmplim_output
180.Pq Vt boolean
181Enable/disable logging of ICMP replies bandwidth limiting.
182Defaults to true.
183.It Va log_redirect
184.Pq Vt boolean
185Enable/disable logging of ICMP Redirect packets.
186Defaults to false.
187.It Va maskfake
188.Pq Vt "unsigned integer"
189When
190.Va maskrepl
191is set and this value is non-zero,
192it will be used instead of the real address mask when
193the system replies to an ICMP Address Mask Request packet.
194Defaults to 0.
195.It Va maskrepl
196.Pq Vt boolean
197Enable/disable replies to ICMP Address Mask Request packets.
198Defaults to false.
199.It Va quotelen
200.Pq Vt integer
201Number of bytes from original packet to quote in ICMP reply.
202This number is internally enforced to be at least 8 bytes (per RFC792)
203and at most the maximal space left in the ICMP reply mbuf.
204.It Va redirtimeout
205.Pq Vt integer
206Delay in seconds before expiring route created by ICMP redirect.
207.It Va reply_from_interface
208.Pq Vt boolean
209Use the IP address of the interface the packet came in through for
210responses to packets which are not directly addressed to us.
211If enabled, this rule is processed before all others.
212By default, continue with normal source selection.
213Enabling this option is particularly useful on routers because it
214makes external traceroutes show the actual path a packet has taken
215instead of the possibly different return path.
216.It Va reply_src
217.Pq Vt str
218An interface name used for the ICMP reply source in response to packets
219which are not directly addressed to us.
220By default continue with normal source selection.
221.It Va tstamprepl
222.Pq Vt boolean
223Enable/disable replies to ICMP Timestamp packets.
224Defaults to true.
225.El
226.Sh ERRORS
227A socket operation may fail with one of the following errors returned:
228.Bl -tag -width Er
229.It Bq Er EISCONN
230when trying to establish a connection on a socket which
231already has one, or when trying to send a datagram with the destination
232address specified and the socket is already connected;
233.It Bq Er ENOTCONN
234when trying to send a datagram, but
235no destination address is specified, and the socket has not been
236connected;
237.It Bq Er ENOBUFS
238when the system runs out of memory for
239an internal data structure;
240.It Bq Er EADDRNOTAVAIL
241when an attempt is made to create a
242socket with a network address for which no network interface
243exists.
244.El
245.Sh SEE ALSO
246.Xr recv 2 ,
247.Xr send 2 ,
248.Xr sysctl 3 ,
249.Xr inet 4 ,
250.Xr intro 4 ,
251.Xr ip 4 ,
252.Xr pf.conf 5 ,
253.Xr sysctl 8
254.Sh HISTORY
255The
256.Nm
257protocol implementation appeared in
258.Bx 4.2 .
259