Reference

icmp(4)

Internet Control Message Protocol

NAME

icmp – Internet Control Message Protocol

SYNOPSIS

#include <sys/socket.h>

#include <netinet/in.h>

int

socket(AF_INET, SOCK_RAW, proto);

DESCRIPTION

ICMP is the error and control message protocol used by IP and the Internet protocol family. It may be accessed through a “raw socket” for network monitoring and diagnostic functions. The proto parameter to the socket call to create an ICMP socket is obtained from getprotobyname(3). ICMP sockets are connectionless, and are normally used with the sendto(2) and recvfrom(2) calls, though the connect(2) call may also be used to fix the destination for future packets (in which case the read(2) or recv(2) and write(2) or send(2) system calls may be used).

Outgoing packets automatically have an IP header prepended to them (based on the destination address). Incoming packets are received with the IP header and options intact.

Types

ICMP messages are classified according to the type and code fields present in the ICMP header. The abbreviations for the types and codes may be used in rules in pf.conf(5). The following types are defined:

NumAbbrev.Description
0echorepEcho reply
3unreachDestination unreachable
4squenchPacket loss, slow down
5redirShorter route exists
6althostAlternate host address
8echoreqEcho request
9routeradvRouter advertisement
10routersolRouter solicitation
11timexTime exceeded
12paramprobInvalid IP header
13timereqTimestamp request
14timerepTimestamp reply
15inforeqInformation request
16inforepInformation reply
17maskreqAddress mask request
18maskrepAddress mask reply
30traceTraceroute
31dataconvData conversion problem
32mobredirMobile host redirection
33ipv6-whereIPv6 where-are-you
34ipv6-hereIPv6 i-am-here
35mobregreqMobile registration request
36mobregrepMobile registration reply
39skipSKIP
40photurisPhoturis

The following codes are defined:

NumAbbrev.TypeDescription
0net-unrunreachNetwork unreachable
1host-unrunreachHost unreachable
2proto-unrunreachProtocol unreachable
3port-unrunreachPort unreachable
4needfragunreachFragmentation needed but DF bit set
5srcfailunreachSource routing failed
6net-unkunreachNetwork unknown
7host-unkunreachHost unknown
8isolateunreachHost isolated
9net-prohibunreachNetwork administratively prohibited
10host-prohibunreachHost administratively prohibited
11net-tosunreachInvalid TOS for network
12host-tosunreachInvalid TOS for host
13filter-prohibunreachProhibited access
14host-precedunreachPrecedence violation
15cutoff-precedunreachPrecedence cutoff
0redir-netredirShorter route for network
1redir-hostredirShorter route for host
2redir-tos-netredirShorter route for TOS and network
3redir-tos-hostredirShorter route for TOS and host
0normal-advrouteradvNormal advertisement
16common-advrouteradvSelective advertisement
0transittimexTime exceeded in transit
1reassembtimexTime exceeded in reassembly
0badheadparamprobInvalid option pointer
1optmissparamprobMissing option
2badlenparamprobInvalid length
1unknown-indphoturisUnknown security index
2auth-failphoturisAuthentication failed
3decrypt-failphoturisDecryption failed

DIAGNOSTICS

A socket operation may fail with one of the following errors returned:

[EISCONN]

when trying to establish a connection on a socket which already has one, or when trying to send a datagram with the destination address specified and the socket is already connected;

[ENOTCONN]

when trying to send a datagram, but no destination address is specified, and the socket hasn't been connected;

[ENOBUFS]

when the system runs out of memory for an internal data structure;

[EADDRNOTAVAIL]

when an attempt is made to create a socket with a network address for which no network interface exists.

SEE ALSO

recv(2), send(2), inet(4), ip(4), netintro(4)

HISTORY

The icmp protocol appeared in 4.3BSD.

History