xref: /freebsd/share/man/man4/icmp.4 (revision 61afd5bb22d787b0641523e7b9b95c964d669bd5)
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.\"	$Id$
34.\"
35.Dd June 5, 1993
36.Dt ICMP 4
37.Os BSD 4.3
38.Sh NAME
39.Nm icmp
40.Nd Internet Control Message Protocol
41.Sh SYNOPSIS
42.Fd #include <sys/socket.h>
43.Fd #include <netinet/in.h>
44.Ft int
45.Fn socket AF_INET SOCK_RAW proto
46.Sh DESCRIPTION
47.Tn ICMP
48is the error and control message protocol used
49by
50.Tn IP
51and the Internet protocol family.  It may be accessed
52through a
53.Dq raw socket
54for network monitoring
55and diagnostic functions.
56The
57.Fa proto
58parameter to the socket call to create an
59.Tn ICMP
60socket
61is obtained from
62.Xr getprotobyname 3 .
63.Tn ICMP
64sockets are connectionless,
65and are normally used with the
66.Xr sendto 2
67and
68.Xr recvfrom 2
69calls, though the
70.Xr connect 2
71call may also be used to fix the destination for future
72packets (in which case the
73.Xr read 2
74or
75.Xr recv 2
76and
77.Xr write 2
78or
79.Xr send 2
80system calls may be used).
81.Pp
82Outgoing packets automatically have an
83.Tn IP
84header prepended to
85them (based on the destination address).
86Incoming packets are received with the
87.Tn IP
88header and options intact.
89.Sh DIAGNOSTICS
90A socket operation may fail with one of the following errors returned:
91.Bl -tag -width [EADDRNOTAVAIL]
92.It Bq Er EISCONN
93when trying to establish a connection on a socket which
94already has one, or when trying to send a datagram with the destination
95address specified and the socket is already connected;
96.It Bq Er ENOTCONN
97when trying to send a datagram, but
98no destination address is specified, and the socket hasn't been
99connected;
100.It Bq Er ENOBUFS
101when the system runs out of memory for
102an internal data structure;
103.It Bq Er EADDRNOTAVAIL
104when an attempt is made to create a
105socket with a network address for which no network interface
106exists.
107.El
108.Sh SEE ALSO
109.Xr recv 2 ,
110.Xr send 2 ,
111.Xr inet 4 ,
112.Xr intro 4 ,
113.Xr ip 4
114.Sh HISTORY
115The
116.Nm
117protocol appeared in
118.Bx 4.3 .
119