1 NAME
   2      arp, ARP - Address Resolution Protocol
   3 
   4 SYNOPSIS
   5      #include <sys/fcntl.h>
   6 
   7      #include <sys/socket.h>
   8 
   9      #include <net/if_arp.h>
  10 
  11      #include <netinet/in.h>
  12 
  13      s = socket(AF_INET, SOCK_DGRAM, 0);
  14 
  15      d = open ("/dev/arp", oflag);
  16 
  17 DESCRIPTION
  18      ARP is a protocol used to map  dynamically between  Internet
  19      Protocol (IP) and Ethernet addresses. It is used by all Eth-
  20      ernet datalink providers (network drivers) and can  be  used
  21      by  other datalink providers that support broadcast, includ-
  22      ing FDDI  and Token Ring. The  only network layer  supported
  23      in  this  implementation  is the Internet Protocol, although
  24      ARP is not specific to that protocol.
  25 
  26      ARP caches IP-to-link-layer address mappings. When an inter-
  27      face requests a mapping for an address not in the cache, ARP
  28      queues the message that requires the mapping and  broadcasts
  29      a  message  on the associated network requesting the address
  30      mapping. If a response is provided, ARP caches the new  map-
  31      ping  and  transmits  any  pending message. ARP will queue a
  32      maximum of four packets while awaiting a response to a  map-
  33      ping   request.  ARP  keeps  only the first four transmitted
  34      packets.
  35 
  36 APPLICATION PROGRAMMING INTERFACE
  37      The STREAMS device /dev/arp is not a Transport Level  Inter-
  38      face  (TLI)  transport provider and may not be used with the
  39      TLI interface.
  40 
  41      To facilitate  communications with  systems that do  not use
  42      ARP,   ioctl()  requests are  provided  to  enter and delete
  43      entries  in  the  IP-to-link address  tables.  Ioctls   that
  44      change the table  contents require sys_net_config privilege.
  45 
  46 SunOS 5.10           Last change: 2 Dec 2008                    1
  47 
  48 Protocols                                                 arp(7P)
  49 
  50      See privileges(5).
  51 
  52        #include <sys/sockio.h>
  53        #include <sys/socket.h>
  54        #include <net/if.h>
  55        #include <net/if_arp.h>
  56        struct arpreq arpreq;
  57        ioctl(s, SIOCSARP, (caddr_t)&arpreq);
  58        ioctl(s, SIOCGARP, (caddr_t)&arpreq);
  59        ioctl(s, SIOCDARP, (caddr_t)&arpreq);
  60 
  61      SIOCSARP, SIOCGARP and SIOCDARP are BSD  compatible  ioctls.
  62      These  ioctls  do  not  communicate  the  mac address length
  63      between the user and the kernel (and thus only  work  for  6
  64      byte  wide  Ethernet addresses). To manage the ARP cache for
  65      media that has different sized mac addresses, use SIOCSXARP,
  66      SIOCGXARP and SIOCDXARP ioctls.
  67 
  68        #include <sys/sockio.h>
  69        #include <sys/socket.h>
  70        #include <net/if.h>
  71        #include <net/if_dl.h>
  72        #include <net/if_arp.h>
  73        struct xarpreq xarpreq;
  74        ioctl(s, SIOCSXARP, (caddr_t)&xarpreq);
  75        ioctl(s, SIOCGXARP, (caddr_t)&xarpreq);
  76        ioctl(s, SIOCDXARP, (caddr_t)&xarpreq);
  77 
  78      Each ioctl() request takes the same structure  as  an  argu-
  79      ment. SIOCS[X]ARP sets an ARP entry, SIOCG[X]ARP gets an ARP
  80      entry, and SIOCD[X]ARP deletes an ARP entry.  These  ioctl()
  81      requests  may  be  applied  to  any  Internet  family socket
  82      descriptors, or to a descriptor for  the  ARP  device.  Note
  83      that  SIOCS[X]ARP and SIOCD[X]ARP require a privileged user,
  84      while SIOCG[X]ARP does not.
  85 
  86      The arpreq structure contains
  87 
  88        /*
  89        * ARP ioctl request
  90        */
  91        struct arpreq {
  92           struct sockaddr arp_pa;  /* protocol address */
  93           struct sockaddr arp_ha; /* hardware address */
  94           int  arp_flags;         /* flags */
  95        };
  96 
  97 SunOS 5.10           Last change: 2 Dec 2008                    2
  98 
  99 Protocols                                                 arp(7P)
 100 
 101      The xarpreq structure contains:
 102 
 103        /*
 104        * Extended ARP ioctl request
 105        */
 106        struct xarpreq {
 107           struct sockaddr_storage xarp_pa; /* protocol address */
 108           struct sockaddr_dl xarp_ha;     /* hardware address */
 109           int xarp_flags;                 /* arp_flags field values */
 110        };
 111        #define ATF_COM 0x2          /* completed entry (arp_ha valid) */
 112        #define ATF_PERM 0x4         /* permanent (non-aging) entry */
 113        #define ATF_PUBL 0x8         /* publish (respond for other host) */
 114        #define ATF_USETRAILERS 0x10 /* send trailer pckts to host */
 115        #define ATF_AUTHORITY 0x20   /* hardware address is authoritative */
 116 
 117      The address  family  for  the  [x]arp_pa  sockaddr  must  be
 118      AF_INET.  The  ATF_COM  flag  bits  ([x]arp_flags) cannot be
 119      altered.  ATF_USETRAILER  is not implemented on Solaris  and
 120      is  retained   for  compatibility  only.  ATF_PERM makes the
 121      entry permanent (disables aging)   if  the  ioctl()  request
 122      succeeds.  ATF_PUBL specifies that the system should respond
 123      to ARP requests for the indicated  protocol  address  coming
 124      from  other  machines.  This allows a host to act as an "ARP
 125      server," which may  be  useful  in  convincing  an  ARP-only
 126      machine  to  talk to a non-ARP  machine. ATF_AUTHORITY indi-
 127      cates that this machine  owns  the  address.  ARP  does  not
 128      update the entry based on received packets.
 129 
 130      The  address  family  for  the  arp_ha  sockaddr   must   be
 131      AF_UNSPEC.
 132 
 133      Before invoking any of the SIOC*XARP ioctls, user code  must
 134      fill  in  the  xarp_pa  field with the protocol (IP) address
 135      information, similar  to  the  BSD  variant.  The  SIOC*XARP
 136      ioctls   come   in   two  (legal)  varieties,  depending  on
 137      xarp_ha.sdl_nlen:
 138        1. if sdl_nlen = 0, it behaves as an extended  BSD  ioctl.
 139        The  kernel  uses  the IP address to determine the network
 140        interface.
 141        2. if (sdl_nlen > 0) and (sdl_nlen < LIFNAMSIZ), the  ker-
 142        nel  uses  the  interface name in sdl_data[0] to determine
 143        the network interface; sdl_nlen represents the  length  of
 144        the string (excluding terminating null character).
 145        3. if  (sdl_nlen  >=  LIFNAMSIZ),  an  error  (EINVAL)  is
 146        flagged from the ioctl.
 147 
 148 SunOS 5.10           Last change: 2 Dec 2008                    3
 149 
 150 Protocols                                                 arp(7P)
 151 
 152      Other than the above, the xarp_ha  structure  should  be  0-
 153      filled  except  for SIOCSXARP, where the sdl_alen field must
 154      be set to the  size  of  hardware  address  length  and  the
 155      hardware    address   itself   must   be   placed   in   the
 156      LLADDR/sdl_data[] area. (EINVAL will  be  returned  if  user
 157      specified  sdl_alen does not match the address length of the
 158      identified interface).
 159 
 160      On return from the kernel on a SIOCGXARP ioctl,  the  kernel
 161      fills  in  the  name of the interface (excluding terminating
 162      NULL) and its hardware address, one after  another,  in  the
 163      sdl_data/LLADDR area; if the two are larger than can be held
 164      in  the  244  byte  sdl_data[]  area,  an  ENOSPC  error  is
 165      returned.  Assuming  it  fits,  the  kernel  will  also  set
 166      sdl_alen with the length of hardware address,  sdl_nlen with
 167      the  length  of name of the interface (excluding terminating
 168      NULL), sdl_type with an IFT_* value to indicate the type  of
 169      the  media,  sdl_slen  with  0,  sdl_family with AF_LINK and
 170      sdl_index (which if not 0) with system given index  for  the
 171      interface.  The information returned is very similar to that
 172      returned via routing sockets on an RTM_IFINFO message.
 173 
 174      ARP  performs  duplicate   address   detection   for   local
 175      addresses.  When a logical  interface is brought up (IFF_UP)
 176      or any time the hardware link goes  up   (IFF_RUNNING),  ARP
 177      sends  probes (ar$spa == 0) for the assigned address.  If  a
 178      conflict  is   found,  the  interface  is  torn  down.   See
 179      ifconfig(1M) for more details.
 180 
 181      ARP watches for hosts impersonating the local host, that is,
 182      any  host  that  responds  to  an  ARP request for the local
 183      host's address, and any address for which the local host  is
 184      an  authority.  ARP  defends  local addresses and logs those
 185      with ATF_AUTHORITY set, and can tear down local addresses on
 186      an excess of conflicts.
 187 
 188      ARP also  handles UNARP messages received  from other nodes.
 189      It does not generate these messages.
 190 
 191 PACKET EVENTS
 192      The arp driver registers itself with the netinfo  interface.
 193      To   gain   access   to    these   events,   a  handle  from
 194      net_protocol_lookup must be acquired by passing it the value
 195      NHF_ARP.  Through this interface, two packet events are sup-
 196      ported:
 197 
 198 SunOS 5.10           Last change: 2 Dec 2008                    4
 199 
 200 Protocols                                                 arp(7P)
 201 
 202      Physical in - ARP packets received via a network  inter face
 203 
 204      Physical out - ARP packets to be sent  out  via  a   network
 205      interface
 206 
 207      For ARP packets, the hook_pkt_event structure is filled  out
 208      as follows:
 209 
 210      hpe_ifp
 211 
 212          Identifier indicating the  inbound  interface for  pack-
 213          ets received with the "physical in" event.
 214 
 215      hpe_ofp
 216 
 217          Identifier indicating the outbound  interface  for pack-
 218          ets received with the "physical out" event.
 219 
 220      hpe_hdr
 221 
 222          Pointer to the start of the ARP  header  (not  the  eth-
 223          ernet header).
 224 
 225      hpe_mp
 226 
 227          Pointer to the start of the mblk_t chain containing  the
 228          ARP packet.
 229 
 230      hpe_mb
 231 
 232          Pointer to the mblk_t with the ARP header in it.
 233 
 234 NETWORK INTERFACE EVENTS
 235      In addition  to events  describing  packets  as  they   move
 236      through the system, it is also possible to receive notifica-
 237      tion of events relating to network interfaces. These  events
 238      are   all  reported back through the same callback. The list
 239      of events is as follows:
 240 
 241      plumb
 242 
 243          A new network interface has been instantiated.
 244 
 245 SunOS 5.10           Last change: 2 Dec 2008                    5
 246 
 247 Protocols                                                 arp(7P)
 248 
 249      unplumb
 250 
 251          A network interface is no longer  associated with ARP.
 252 
 253 SEE ALSO
 254      arp(1M), ifconfig(1M), privileges(5), if_tcp(7P),  inet(7P),
 255      netinfo(9F)
 256 
 257      Plummer, Dave, An Ethernet Address  Resolution  Protocol  or
 258      Converting  Network  Protocol  Addresses to 48 .bit Ethernet
 259      Addresses for Transmission on Ethernet  Hardware, RFC   826,
 260      STD 0037, November 1982.
 261 
 262      Malkin,  Gary, ARP  Extension  - UNARP, RFC 1868,  November,
 263      1995
 264 
 265 DIAGNOSTICS
 266      Several messages can be written to the system  logs (by  the
 267      IP module) when errors occur. In the following examples, the
 268      hardware address strings include colon (:)  separated  ASCII
 269      representations  of  the link layer addresses, whose lengths
 270      depend on the underlying media (for  example,  6  bytes  for
 271      Ethernet).
 272 
 273      Node %x:%x ... %x:%x is using our IP address %d.%d.%d.%d on
 274      %s.
 275 
 276          Duplicate IP address warning. ARP has discovered another
 277          host  on  a  local  network  that  responds  to  mapping
 278          requests for the Internet  address of this  system,  and
 279          has  defended  the  system  against  this  node  by  re-
 280          announcing the ARP entry.
 281 
 282      %s has duplicate address %d.%d.%d.%d (in use by %x:%x ...
 283      %x:%x); disabled.
 284 
 285          Duplicate IP address detected while  performing  initial
 286          probing.  The   newly-configured interface has been shut
 287          down.
 288 
 289      %s has duplicate address %d.%d.%d.%d (claimed by %x:%x ...
 290      %x:%x); disabled.
 291 
 292          Duplicate IP address detected on a running IP interface.
 293          The  conflict  cannot be resolved, and the interface has
 294          been disabled to protect the network.
 295 
 296 SunOS 5.10           Last change: 2 Dec 2008                    6
 297 
 298 Protocols                                                 arp(7P)
 299 
 300      Recovered address %d.%d.%d.%d on %s.
 301 
 302          An interface with a  previously-conflicting  IP  address
 303          has been recovered automatically and reenabled. The con-
 304          flict has been resolved.
 305 
 306      Proxy ARP problem?  Node '%x:%x ... %x:%x' is using
 307      %d.%d.%d.%d on %s
 308 
 309          This  message appears if arp(1M) has been used to create
 310          a  published  permanent  (ATF_AUTHORITY) entry, and some
 311          other host on the  local  network  responds  to  mapping
 312          requests for the published ARP entry.
 313