MyWebUniversity.com Home Page
 



Darwin Mac OS X man pages main menu
ICMP(4)                  BSD Kernel Interfaces Manual                  ICMP(4)

NAME
     icmp -- Internet Control Message Protocol

SYNOPSIS
     ##include <>
     ##include <>

     int
     socket(AFINET, SOCKRAW, proto);

DESCRIPTION
     ICMP is the error and control message protocol used by IP and the Inter-
     net 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
     and recvfrom 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.

   Non-privileged ICMP
     ICMP sockets can be opened with the SOCKDGRAM socket type without
     requiring root privileges. The synopsis is the following:

     socket(AFINET, SOCKDGRAM, IPROTOICMP)

     This can be used by non root privileged processes to send ICMP echo
     requests to gauge the quality of the connectivity to a host, to receive
     ICMP destination unreachable message for path MTU discovery, or to
     receveive time exceeded message for traceroute.

     Datagram oriented ICMP sockets offer a subset of the functionality avail-
     able to raw ICMP sockets. Only IMCP request messages of the following
     types can be sent: ICMPECHO, ICMPTSTAMP or ICMPMASKREQ.  The code
     field must be the value zero (0).  The minimal length of an ICMP message
     request is eight (8) octets.

     The following IP level option can be used with datagram oriented ICMP
     sockets:

         IPOPTIONS
         IPHDRINCL
         IPTOS
         IPTL
         IPRECVOPTS
         IPRECVRETOPTS
         IPRECVDSTADR
         IPRETOPTS
         IPMULTICASTIF
         IPMULTICASTL
         IPMULTICASTLOP
         IPADMEMBERSHIP
         IPDROPMEMBERSHIP
         IPMULTICASTVIF
         IPORTRANGE
         IPRECVIF
         IPIPSECPOLICY
         IPSTRIPHDR

     When the IP option IPHDRINCL is used, the provided IP header must obey
     the following rules:

         ipv       Must be IPVERSION (4);
         iphl      Between 5 and 10 (inclusive);
         iptos     Any value;
         iplen     Must be the total length of IP datagram (IP header ] ICMP
                    message);
         ipid      Must be zero, will be automatically set;
         ipoff     Must be zero, will be automatically set;
         ipttl     Any value;
         ipp       Must be IPROTOIP;
         ipsum     Value ignored, will be automatically set;
         ipsrc     Must be an IP address currently assigned to one of the
                    local interface or INADRANY;
         ipdst     Any address;
         ipopts    Any option.

     The maximum length of a IMCP message that can be sent is controlled by
     the sysctl variable net.inet.raw.maxdgram.

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

     [EISCON]        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;

     [ENOTCON]       when trying to send a datagram, but no destination
                      address is specified, and the socket hasn't been con-
                      nected;

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

     [EADRNOTAVAIL]  when an attempt is made to create a socket with a net-
                      work address for which no network interface exists;

     [EINVAL]         when an invalid value is used with IMCP datagram socket
                      for a field of the IP or ICMP header.

SEE ALSO
     send(2), recv(2), intro(4), inet(4), ip(4)

HISTORY
     The icmp protocol appeared in 4.3BSD.

4.3 Berkeley Distribution        June 19, 2002       4.3 Berkeley Distribution
Darwin Mac OS X man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™