Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

arp(7p) [sunos man page]

arp(7P) 							     Protocols								   arp(7P)

NAME
arp, ARP - Address Resolution Protocol SYNOPSIS
#include <sys/fcntl.h> #include <sys/socket.h> #include <net/if_arp.h> #include <netinet/in.h> s = socket(AF_INET, SOCK_DGRAM, 0); d = open ("/dev/arp", oflag); DESCRIPTION
ARP is a protocol used to map dynamically between Internet Protocol (IP) and 10Mb/s Ethernet addresses. It is used by all the 10Mb/s Ether- net datalink providers (interface drivers) and it can be used by other datalink providers that support broadcast, such as FDDI and Token Ring. The only network layer supported in this implementation is the Internet Protocol, although ARP is not specific to that protocol. ARP caches IP-to-link-layer address mappings. When an interface requests a mapping for an address not in the cache, ARP queues the message that requires the mapping and broadcasts a message on the associated network requesting the address mapping. If a response is provided, ARP caches the new mapping and transmits any pending message. ARP will queue a maximum of four packets while awaiting a response to a mapping request; it keeps only the four most recently transmitted packets. APPLICATION PROGRAMMING INTERFACE
The STREAMS device /dev/arp is not a Transport Level Interface (TLI) transport provider and may not be used with the TLI interface. To facilitate communications with systems that do not use ARP, ioctl() requests are provided to enter and delete entries in the IP-to-link address tables. #include <sys/sockio.h> #include <sys/socket.h> #include <net/if.h> #include <net/if_arp.h> struct arpreq arpreq; ioctl(s, SIOCSARP, (caddr_t)&arpreq); ioctl(s, SIOCGARP, (caddr_t)&arpreq); ioctl(s, SIOCDARP, (caddr_t)&arpreq); SIOCSARP, SIOCGARP and SIOCDARP are BSD compatible ioctls. These ioctls do not communicate the mac address length between the user and the kernel (and thus only work for 6 byte wide Ethernet addresses). To manage the ARP cache for media that has different sized mac addresses, use SIOCSXARP, SIOCGXARP and SIOCDXARP ioctls. #include <sys/sockio.h> #include <sys/socket.h> #include <net/if.h> #include <net/if_dl.h> #include <net/if_arp.h> struct xarpreq xarpreq; ioctl(s, SIOCSXARP, (caddr_t)&xarpreq); ioctl(s, SIOCGXARP, (caddr_t)&xarpreq); ioctl(s, SIOCDXARP, (caddr_t)&xarpreq); Each ioctl() request takes the same structure as an argument. SIOCS[X]ARP sets an ARP entry, SIOCG[X]ARP gets an ARP entry, and SIOCD[X]ARP deletes an ARP entry. These ioctl() requests may be applied to any Internet family socket descriptor s, or to a descriptor for the ARP device, but only by the privileged 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 */ }; The xarpreq structure contains: /* * Extended ARP ioctl request */ struct xarpreq { struct sockaddr_storage xarp_pa; /* protocol address */ struct sockaddr_dl xarp_ha; /* hardware address */ int xarp_flags; /* flags */ }; /* arp_flags field values */ #define ATF_COM 0x2 /* completed entry (arp_ha valid) */ #define ATF_PERM 0x4 /* permanent entry */ #define ATF_PUBL 0x8 /* publish (respond for other host) */ #define ATF_USETRAILERS 0x10 /* send trailer packets to host */ The address family for the [x]arp_pa sockaddr must be AF_INET. The only flag bits ([x]arp_flags) that may be written are ATF_PUBL and ATF_USETRAILERS. ATF_PERM makes the entry permanent if the ioctl() request succeeds. The peculiar nature of the ARP tables may cause the ioctl() request to fail if too many permanent IP 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 con- vincing an ARP-only machine to talk to a non-ARP machine. The address family for the arp_ha sockaddr must be AF_UNSPEC. Before invoking any of the SIOC*XARP ioctls, user code must fill in the xarp_pa field with the protocol (IP) address information, similar to the BSD variant. The SIOC*XARP ioctls come in two (legal) varieties, depending on xarp_ha.sdl_nlen: 1. if sdl_nlen = 0, it behaves as an extended BSD ioctl. The kernel uses the IP address to determine the network interface. 2. if (sdl_nlen > 0) and (sdl_nlen < LIFNAMSIZ), the kernel uses the interface name in sdl_data[0] to determine the network interface; sdl_nlen represents the length of the string (excluding terminating null character). 3. if (sdl_nlen >= LIFNAMSIZ), an error (EINVAL) is flagged from the ioctl. Other than the above, the xarp_ha structure should be 0-filled except for SIOCSXARP, where the sdl_alen field must be set to the size of hardware address length and the hardware address itself must be placed in the LLADDR/sdl_data[] area. (EINVAL will be returned if user specified sdl_alen does not match the address length of the identified interface). On return from the kernel on a SIOCGXARP ioctl, the kernel fills in the name of the interface (excluding terminating NULL) and its hardware address, one after another, in the sdl_data/LLADDR area; if the two are larger than can be held in the 244 byte sdl_data[] area, an ENOSPC error is returned. Assuming it fits, the kernel will also set sdl_alen with the length of hardware address, sdl_nlen with the length of name of the interface (excluding terminating NULL), sdl_type with an IFT_* value to indicate the type of the media, sdl_slen with 0, sdl_family with AF_LINK and sdl_index (which if not 0) with system given index for the interface. The information returned is very similar to that returned via routing sockets on an RTM_IFINFO message. ARP is also used to negotiate the use of trailer IP encapsulations. Trailers are an alternate encapsulation used to allow efficient packet alignment for large packets despite variable-sized headers. Hosts that wish to receive trailer encapsulations so indicate by sending gratu- itous ARP translation replies along with replies to IP requests; trailer encapsulations are also sent in reply to IP translation replies. The negotiation is thus fully symmetrical, in that either host or both may request trailers. The ATF_USETRAILERS flag records 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 (that is, a host which responds to an ARP mapping request for the local host's address). SEE ALSO
arp(1M), ifconfig(1M), if_tcp(7P), inet(7P) Leffler, Sam, and Michael Karels, Trailer Encapsulations, RFC 893, Network Information Center, SRI International, Menlo Park, California, April 1984. Plummer, Dave, An Ethernet Address Resolution Protocol -or- Converting Network Protocol Addresses to 48.bit Ethernet Addresses for Trans- mission on Ethernet Hardware, RFC 826, Network Information Center, SRI International, Menlo Park, California, November 1982. DIAGNOSTICS
IP: Hardware address '%x:%x ... %x:%x' trying to be our address '%d.%d.%d.%d'! Duplicate IP address. ARP has discovered another host on the local network which responds to mapping requests for the Internet address of this system. IP: Proxy ARP problem? Hardware address '%x:%x ... %x:%x' thinks it is '%d.%d.%d.%d' This message will appear if arp(1M) has been used to create a published entry, and some other host on the local network responds to mapping requests for the published ARP entry. In the above examples, the "Hardware address" strings include colon (:) separated ascii representations of the link layer addresses, whose lengths depend on the underlying media (for example, 6 bytes for Ethernet). SunOS 5.10 06 Mar 2003 arp(7P)
Man Page