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. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)icmp.4 8.1 (Berkeley) 6/5/93 33.\" $FreeBSD$ 34.\" 35.Dd March 21, 2003 36.Dt ICMP 4 37.Os 38.Sh NAME 39.Nm icmp 40.Nd Internet Control Message Protocol 41.Sh SYNOPSIS 42.In sys/types.h 43.In sys/socket.h 44.In netinet/in.h 45.Ft int 46.Fn socket AF_INET SOCK_RAW proto 47.Sh DESCRIPTION 48.Tn ICMP 49is the error and control message protocol used 50by 51.Tn IP 52and the Internet protocol family. 53It may be accessed 54through a 55.Dq raw socket 56for network monitoring 57and diagnostic functions. 58The 59.Fa proto 60parameter to the socket call to create an 61.Tn ICMP 62socket 63is obtained from 64.Xr getprotobyname 3 . 65.Tn ICMP 66sockets are connectionless, 67and are normally used with the 68.Xr sendto 2 69and 70.Xr recvfrom 2 71calls, though the 72.Xr connect 2 73call may also be used to fix the destination for future 74packets (in which case the 75.Xr read 2 76or 77.Xr recv 2 78and 79.Xr write 2 80or 81.Xr send 2 82system calls may be used). 83.Pp 84Outgoing packets automatically have an 85.Tn IP 86header prepended to 87them (based on the destination address). 88Incoming packets are received with the 89.Tn IP 90header and options intact. 91.Ss MIB Variables 92The 93.Tn ICMP 94protocol implements a number of variables in the 95.Va net.inet.icmp 96branch of the 97.Xr sysctl 3 98MIB. 99.Bl -tag -width ".Va icmplim_output" 100.It Va maskrepl 101.Pq Vt boolean 102Enable/disable replies to ICMP Address Mask Request packets. 103Defaults to false. 104.It Va maskfake 105.Pq Vt "unsigned integer" 106When 107.Va maskrepl 108is set and this value is non-zero, 109it will be used instead of the real address mask when 110the system replies to an ICMP Address Mask Request packet. 111Defaults to 0. 112.It Va icmplim 113.Pq Vt integer 114Bandwidth limit for ICMP replies in packets/second. 115Used when 116.Va icmplim_output 117is non-zero. 118Defaults to 200. 119.It Va icmplim_output 120.Pq Vt boolean 121Enable/disable bandwidth limiting of ICMP replies. 122Defaults to true. 123.It Va drop_redirect 124.Pq Vt boolean 125Enable/disable dropping of ICMP Redirect packets. 126Defaults to false. 127.It Va log_redirect 128.Pq Vt boolean 129Enable/disable logging of ICMP Redirect packets. 130Defaults to false. 131.It Va bmcastecho 132.Pq Vt boolean 133Enable/disable ICMP replies received via broadcast or multicast. 134Defaults to false. 135.El 136.Sh ERRORS 137A socket operation may fail with one of the following errors returned: 138.Bl -tag -width Er 139.It Bq Er EISCONN 140when trying to establish a connection on a socket which 141already has one, or when trying to send a datagram with the destination 142address specified and the socket is already connected; 143.It Bq Er ENOTCONN 144when trying to send a datagram, but 145no destination address is specified, and the socket hasn't been 146connected; 147.It Bq Er ENOBUFS 148when the system runs out of memory for 149an internal data structure; 150.It Bq Er EADDRNOTAVAIL 151when an attempt is made to create a 152socket with a network address for which no network interface 153exists. 154.El 155.Sh SEE ALSO 156.Xr recv 2 , 157.Xr send 2 , 158.Xr inet 4 , 159.Xr intro 4 , 160.Xr ip 4 161.Sh HISTORY 162The 163.Nm 164protocol appeared in 165.Bx 4.3 . 166