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. It may be accessed 53through a 54.Dq raw socket 55for network monitoring 56and diagnostic functions. 57The 58.Fa proto 59parameter to the socket call to create an 60.Tn ICMP 61socket 62is obtained from 63.Xr getprotobyname 3 . 64.Tn ICMP 65sockets are connectionless, 66and are normally used with the 67.Xr sendto 2 68and 69.Xr recvfrom 2 70calls, though the 71.Xr connect 2 72call may also be used to fix the destination for future 73packets (in which case the 74.Xr read 2 75or 76.Xr recv 2 77and 78.Xr write 2 79or 80.Xr send 2 81system calls may be used). 82.Pp 83Outgoing packets automatically have an 84.Tn IP 85header prepended to 86them (based on the destination address). 87Incoming packets are received with the 88.Tn IP 89header and options intact. 90.Ss MIB Variables 91The 92.Tn ICMP 93protocol implements a number of variables in the 94.Va net.inet.icmp 95branch of the 96.Xr sysctl 3 97MIB. 98.Bl -tag -width ".Va icmplim_output" 99.It Va maskrepl 100.Pq Vt boolean 101Enable/disable replies to ICMP Address Mask Request packets. 102Defaults to false. 103.It Va maskfake 104.Pq Vt "unsigned integer" 105When 106.Va maskrepl 107is set and this value is non-zero, 108it will be used instead of the real address mask when 109the system replies to an ICMP Address Mask Request packet. 110Defaults to 0. 111.It Va icmplim 112.Pq Vt integer 113Bandwidth limit for ICMP replies in packets/second. 114Used when 115.Va icmplim_output 116is non-zero. 117Defaults to 200. 118.It Va icmplim_output 119.Pq Vt boolean 120Enable/disable bandwidth limiting of ICMP replies. 121Defaults to true. 122.It Va drop_redirect 123.Pq Vt boolean 124Enable/disable dropping of ICMP Redirect packets. 125Defaults to false. 126.It Va log_redirect 127.Pq Vt boolean 128Enable/disable logging of ICMP Redirect packets. 129Defaults to false. 130.It Va bmcastecho 131.Pq Vt boolean 132Enable/disable ICMP replies received via broadcast or multicast. 133Defaults to false. 134.El 135.Sh ERRORS 136A socket operation may fail with one of the following errors returned: 137.Bl -tag -width Er 138.It Bq Er EISCONN 139when trying to establish a connection on a socket which 140already has one, or when trying to send a datagram with the destination 141address specified and the socket is already connected; 142.It Bq Er ENOTCONN 143when trying to send a datagram, but 144no destination address is specified, and the socket hasn't been 145connected; 146.It Bq Er ENOBUFS 147when the system runs out of memory for 148an internal data structure; 149.It Bq Er EADDRNOTAVAIL 150when an attempt is made to create a 151socket with a network address for which no network interface 152exists. 153.El 154.Sh SEE ALSO 155.Xr recv 2 , 156.Xr send 2 , 157.Xr inet 4 , 158.Xr intro 4 , 159.Xr ip 4 160.Sh HISTORY 161The 162.Nm 163protocol appeared in 164.Bx 4.3 . 165