xref: /original-bsd/share/man/man4/icmp.4 (revision c3e32dec)
1.\" Copyright (c) 1986, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)icmp.4	8.1 (Berkeley) 06/05/93
7.\"
8.Dd
9.Dt ICMP 4
10.Os BSD 4.3
11.Sh NAME
12.Nm icmp
13.Nd Internet Control Message Protocol
14.Sh SYNOPSIS
15.Fd #include <sys/socket.h>
16.Fd #include <netinet/in.h>
17.Ft int
18.Fn socket AF_INET SOCK_RAW proto
19.Sh DESCRIPTION
20.Tn ICMP
21is the error and control message protocol used
22by
23.Tn IP
24and the Internet protocol family.  It may be accessed
25through a
26.Dq raw socket
27for network monitoring
28and diagnostic functions.
29The
30.Fa proto
31parameter to the socket call to create an
32.Tn ICMP
33socket
34is obtained from
35.Xr getprotobyname 3 .
36.Tn ICMP
37sockets are connectionless,
38and are normally used with the
39.Xr sendto
40and
41.Xr recvfrom
42calls, though the
43.Xr connect 2
44call may also be used to fix the destination for future
45packets (in which case the
46.Xr read 2
47or
48.Xr recv 2
49and
50.Xr write 2
51or
52.Xr send 2
53system calls may be used).
54.Pp
55Outgoing packets automatically have an
56.Tn IP
57header prepended to
58them (based on the destination address).
59Incoming packets are received with the
60.Tn IP
61header and options intact.
62.Sh DIAGNOSTICS
63A socket operation may fail with one of the following errors returned:
64.Bl -tag -width [EADDRNOTAVAIL]
65.It Bq Er EISCONN
66when trying to establish a connection on a socket which
67already has one, or when trying to send a datagram with the destination
68address specified and the socket is already connected;
69.It Bq Er ENOTCONN
70when trying to send a datagram, but
71no destination address is specified, and the socket hasn't been
72connected;
73.It Bq Er ENOBUFS
74when the system runs out of memory for
75an internal data structure;
76.It Bq Er EADDRNOTAVAIL
77when an attempt is made to create a
78socket with a network address for which no network interface
79exists.
80.El
81.Sh SEE ALSO
82.Xr send 2 ,
83.Xr recv 2 ,
84.Xr intro 4 ,
85.Xr inet 4 ,
86.Xr ip 4
87.Sh HISTORY
88The
89.Nm
90protocol appeared in
91.Bx 4.3 .
92