xref: /netbsd/share/man/man4/icmp.4 (revision bf9ec67e)
1.\"	$NetBSD: icmp.4,v 1.7 2002/02/13 08:17:35 ross Exp $
2.\"
3.\" Copyright (c) 1986, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     @(#)icmp.4	8.1 (Berkeley) 6/5/93
35.\"
36.Dd June 5, 1993
37.Dt ICMP 4
38.Os
39.Sh NAME
40.Nm icmp
41.Nd Internet Control Message Protocol
42.Sh SYNOPSIS
43.Fd #include \*[Lt]sys/socket.h\*[Gt]
44.Fd #include \*[Lt]netinet/in.h\*[Gt]
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 through a
54.Dq raw socket
55for network monitoring and diagnostic functions.
56The
57.Fa proto
58parameter to the socket call to create an
59.Tn ICMP
60socket is obtained from
61.Xr getprotobyname 3 .
62.Tn ICMP
63sockets are connectionless, and 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 packets
70(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 them (based on the destination address).
83Incoming packets are received with the
84.Tn IP
85header and options intact.
86.Sh DIAGNOSTICS
87A socket operation may fail with one of the following errors returned:
88.Bl -tag -width [EADDRNOTAVAIL]
89.It Bq Er EISCONN
90when trying to establish a connection on a socket which
91already has one, or when trying to send a datagram with the destination
92address specified and the socket is already connected;
93.It Bq Er ENOTCONN
94when trying to send a datagram, but
95no destination address is specified, and the socket hasn't been
96connected;
97.It Bq Er ENOBUFS
98when the system runs out of memory for
99an internal data structure;
100.It Bq Er EADDRNOTAVAIL
101when an attempt is made to create a
102socket with a network address for which no network interface exists.
103.El
104.Sh SEE ALSO
105.Xr recv 2 ,
106.Xr send 2 ,
107.Xr inet 4 ,
108.Xr intro 4 ,
109.Xr ip 4
110.Rs
111.%R RFC
112.%N 792
113.%D September 1981
114.%T "Internet Control Message Protocol"
115.Re
116.Rs
117.%R RFC
118.%N 1122
119.%D October 1989
120.%T "Requirements for Internet Hosts -- Communication Layers"
121.Re
122.Sh HISTORY
123The
124.Nm
125protocol appeared in
126.Bx 4.3 .
127