1*47675Scael.\" Copyright (c) 1986, 1991 Regents of the University of California. 233126Sbostic.\" All rights reserved. 328253Skarels.\" 443581Strent.\" %sccs.include.redist.man% 528253Skarels.\" 6*47675Scael.\" @(#)icmp.4 6.6 (Berkeley) 03/28/91 733126Sbostic.\" 8*47675Scael.Dd 9*47675Scael.Dt ICMP 4 10*47675Scael.Os BSD 4.3 11*47675Scael.Sh NAME 12*47675Scael.Nm icmp 13*47675Scael.Nd Internet Control Message Protocol 14*47675Scael.Sh SYNOPSIS 15*47675Scael.Fd #include <sys/socket.h> 16*47675Scael.Fd #include <netinet/in.h> 17*47675Scael.Ft int 18*47675Scael.Fn socket AF_INET SOCK_RAW proto 19*47675Scael.Sh DESCRIPTION 20*47675Scael.Tn ICMP 21*47675Scaelis the error and control message protocol used 22*47675Scaelby 23*47675Scael.Tn IP 24*47675Scaeland the Internet protocol family. It may be accessed 25*47675Scaelthrough a 26*47675Scael.Dq raw socket 27*47675Scaelfor network monitoring 2828253Skarelsand diagnostic functions. 2928253SkarelsThe 30*47675Scael.Fa proto 31*47675Scaelparameter to the socket call to create an 32*47675Scael.Tn ICMP 33*47675Scaelsocket 3428253Skarelsis obtained from 35*47675Scael.Xr getprotobyname 3 . 36*47675Scael.Tn ICMP 37*47675Scaelsockets are connectionless, 3828253Skarelsand are normally used with the 39*47675Scael.Xr sendto 4028253Skarelsand 41*47675Scael.Xr recvfrom 4228253Skarelscalls, though the 43*47675Scael.Xr connect 2 4428253Skarelscall may also be used to fix the destination for future 4528253Skarelspackets (in which case the 46*47675Scael.Xr read 2 4728253Skarelsor 48*47675Scael.Xr recv 2 4928253Skarelsand 50*47675Scael.Xr write 2 5128253Skarelsor 52*47675Scael.Xr send 2 5328253Skarelssystem calls may be used). 54*47675Scael.Pp 55*47675ScaelOutgoing packets automatically have an 56*47675Scael.Tn IP 57*47675Scaelheader prepended to 5828253Skarelsthem (based on the destination address). 59*47675ScaelIncoming packets are received with the 60*47675Scael.Tn IP 61*47675Scaelheader and options intact. 62*47675Scael.Sh DIAGNOSTICS 6328253SkarelsA socket operation may fail with one of the following errors returned: 64*47675Scael.Bl -tag -width [EADDRNOTAVAIL] 65*47675Scael.It Bq Er EISCONN 6628253Skarelswhen trying to establish a connection on a socket which 6728253Skarelsalready has one, or when trying to send a datagram with the destination 6828253Skarelsaddress specified and the socket is already connected; 69*47675Scael.It Bq Er ENOTCONN 7028253Skarelswhen trying to send a datagram, but 7128253Skarelsno destination address is specified, and the socket hasn't been 7228253Skarelsconnected; 73*47675Scael.It Bq Er ENOBUFS 7428253Skarelswhen the system runs out of memory for 7528253Skarelsan internal data structure; 76*47675Scael.It Bq Er EADDRNOTAVAIL 7728253Skarelswhen an attempt is made to create a 7828253Skarelssocket with a network address for which no network interface 7928253Skarelsexists. 80*47675Scael.El 81*47675Scael.Sh SEE ALSO 82*47675Scael.Xr send 2 , 83*47675Scael.Xr recv 2 , 84*47675Scael.Xr intro 4 , 85*47675Scael.Xr inet 4 , 86*47675Scael.Xr ip 4 87*47675Scael.Sh HISTORY 88*47675ScaelThe 89*47675Scael.Nm 90*47675Scaelprotocol appeared in 91*47675Scael.Bx 4.3 . 92