Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jan 2002 12:42:03 -0800 (PST)
From:      Kenneth Stailey <kstailey@yahoo.com>
To:        Kenneth Stailey <kstailey@yahoo.com>, freebsd-net@FreeBSD.ORG
Subject:   Re: ARP API documentation?
Message-ID:  <20020122204203.11832.qmail@web10001.mail.yahoo.com>
In-Reply-To: <20020122202554.77694.qmail@web10005.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--- Kenneth Stailey <kstailey@yahoo.com> wrote:
> 
> --- Ruslan Ermilov <ru@FreeBSD.ORG> wrote:
> > On Tue, Jan 22, 2002 at 09:22:12AM -0800, Kenneth Stailey wrote:
> > > Hi,
> > > 
> > > I search and search but cannot find any documentation on the user-space
> > level
> > > API for ARP.  I know of only two code examples in the tree
> > (usr.sbin/arp/arp.c
> > > and usr.sbin/ppp/arp.c) and I do not wish to play guessing games about
> the
> > > protocol.
> > > 
> > > It's clear that you open a PF_ROUTE raw socket and write a message to it
> to
> > > manipulate the ARP tables.  Is the format of the message documented
> > anywhere?
> > > 
> > route(4).
> 
> How is ARP documented without using the word "ARP"?
> 
> $ man 4 route | grep -i arp | wc -l
>        0
> 
> Seems the old ioctl(2) interface to ARP had better documentation than that.

Where's stuff like this, only for new API?

% man 4 arp

ARP(4P)             UNIX Programmer's Manual              ARP(4P)

NAME
     arp - Address Resolution Protocol

SYNOPSIS
     /sys/conf/SYSTEM:
          NETHER    1       # ether pseudo-device

DESCRIPTION
     ARP is a protocol used to dynamically map between DARPA
     Internet and 10Mb/s Ethernet addresses.  It is used by all
     the 10Mb/s Ethernet interface drivers.  It is not specific
     to Internet protocols or to 10Mb/s Ethernet, but this imple-
     mentation currently supports only that combination.

     ARP caches Internet-Ethernet address mappings.  When an
     interface requests a mapping for an address not in the
     cache, ARP queues the message which requires the mapping and
     broadcasts a message on the associated network requesting
     the address mapping.  If a response is provided, the new
     mapping is cached and any pending message is transmitted.
     ARP will queue at most one packet while waiting for a map-
     ping request to be responded to; only the most recently
     ``transmitted'' packet is kept.

     To facilitate communications with systems which do not use
     ARP, ioctls are provided to enter and delete entries in the
     Internet-to-Ethernet tables.  Usage:

          #include <sys/ioctl.h>
          #include <sys/socket.h>
          #include <net/if.h>
          struct arpreq arpreq;

          ioctl(s, SIOCSARP, (caddr_t)&arpreq);
          ioctl(s, SIOCGARP, (caddr_t)&arpreq);
          ioctl(s, SIOCDARP, (caddr_t)&arpreq);
     Each ioctl takes the same structure as an argument.
     SIOCSARP sets an ARP entry, SIOCGARP gets an ARP entry, and
     SIOCDARP deletes an ARP entry.  These ioctls may be applied
     to any socket descriptor s, but only by the super-user.  The
     arpreq structure contains:

          /*
           * ARP ioctl request
           */
          struct arpreq {
                   struct sockaddr  arp_pa;  /* protocol address */
                   struct sockaddr  arp_ha;  /* hardware address */
                   int              arp_flags;/* flags */
          };
          /*  arp_flags field values */
          #define ATF_COM           0x02/* completed entry (arp_ha valid) */

Printed 1/8/98           August 1, 1987                         1

ARP(4P)             UNIX Programmer's Manual              ARP(4P)

          #define  ATF_PERM         0x04  /* permanent entry */
          #define  ATF_PUBL         0x08  /* publish (respond for other host)
*/
          #define  ATF_USETRAILERS  0x10  /* send trailer packets to host */

     The address family for the arp_pa sockaddr must be AF_INET;
     for the arp_ha sockaddr it must be AF_UNSPEC.  The only flag
     bits which may be written are ATF_PERM, ATF_PUBL and
     ATF_USETRAILERS.  ATF_PERM causes the entry to be permanent
     if the ioctl call succeeds.  The peculiar nature of the ARP
     tables may cause the ioctl to fail if more than 8 (per-
     manent) Internet host addresses hash to the same slot.
     ATF_PUBL specifies that the ARP code should respond to ARP
     requests for the indicated host coming from other machines.
     This allows a host to act as an ``ARP server,'' which may be
     useful in convincing an ARP-only machine to talk to a non-
     ARP machine.

     ARP is also used to negotiate the use of trailer IP encapsu-
     lations; trailers are an alternate encapsulation used to
     allow efficient packet alignment for large packets despite
     variable-sized headers.  Hosts which wish to receive trailer
     encapsulations so indicate by sending gratuitous ARP trans-
     lation replies along with replies to IP requests; they are
     also sent in reply to IP translation replies.  The negotia-
     tion is thus fully symmetrical, in that either or both hosts
     may request trailers.  The ATF_USETRAILERS flag is used to
     record the receipt of such a reply, and enables the
     transmission of trailer packets to that host.

     ARP watches passively for hosts impersonating the local host
     (i.e. a host which responds to an ARP mapping request for
     the local host's address).

DIAGNOSTICS
     duplicate IP address!! sent from ethernet address:
     %x:%x:%x:%x:%x:%x. ARP has discovered another host on the
     local network which responds to mapping requests for its own
     Internet address.

SEE ALSO
     ec(4), de(4), il(4), inet(4F), arp(8C), ifconfig(8C)
     ``An Ethernet Address Resolution Protocol,'' RFC826, Dave
     Plummer, Network Information Center, SRI.
     ``Trailer Encapsulations,'' RFC893, S.J. Leffler and M.J.
     Karels, Network Information Center, SRI.

BUGS
     ARP packets on the Ethernet use only 42 bytes of data; how-
     ever, the smallest legal Ethernet packet is 60 bytes (not
     including CRC).  Some systems may not enforce the minimum
     packet size, others will.

Printed 1/8/98           August 1, 1987                         2

% uname -a
BSD pdp11.xxxx.com 2.11 2.11 BSD UNIX #11: Fri Jan 4 14:59:26 EST 2002    
kstailey@pdp11.xxxx.com:/usr/src/sys/HIPPON  pdp11


> > Cheers,
> > -- 
> > Ruslan Ermilov		Oracle Developer/DBA,
> > ru@sunbay.com		Sunbay Software AG,
> > ru@FreeBSD.org		FreeBSD committer,
> > +380.652.512.251	Simferopol, Ukraine
> > 
> > http://www.FreeBSD.org	The Power To Serve
> > http://www.oracle.com	Enabling The Information Age
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-net" in the body of the message


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020122204203.11832.qmail>