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_USETRAILERS 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 The ARP ioctls have several additional restrictions and
175 enhancements when used in conjunction with IPMP:
176
177 * The ARP mappings for IPMP data and test addresses are
178 managed by the kernel, and thus cannot be changed
179 through any ARP ioctls, though they may be retrieved
180 using *SIOCGARP* or *SIOCGXARP*.
181
182 * ARP mappings for a given IPMP group must be consistent
183 across the group. Therefore, ARP mappings cannot be
184 associated with individual underlying IP interfaces in
185 an IPMP group, and must instead be associated with the
186 corresponding IPMP IP interface.
187
188 * Proxy ARP mappings for an IPMP group are automatically
189 managed by the kernel. Specifically, if the hardware
190 address in a *SIOCSARP* or *SIOCSXARP* request matches
191 the hardware address of an IP interface in an IPMP
192 group, and the IP address is not local to the system,
193 the kernel will regard this as a IPMP Proxy ARP entry.
194 This IPMP Proxy ARP entry will have its hardware
195 address automatically adjusted in order to keep the IP
196 address reachable (provided the IPMP group has not
197 entirely failed).
198
199 ARP performs duplicate address detection for local
200 addresses. When a logical interface is brought up (IFF_UP)
201 or any time the hardware link goes up (IFF_RUNNING), ARP
202 sends probes (ar$spa == 0) for the assigned address. If a
203 conflict is found, the interface is torn down. See
204 ifconfig(1M) for more details.
205
206 ARP watches for hosts impersonating the local host, that is,
207 any host that responds to an ARP request for the local
208 host's address, and any address for which the local host is
209 an authority. ARP defends local addresses and logs those
210 with ATF_AUTHORITY set, and can tear down local addresses on
211 an excess of conflicts.
212
213 ARP also handles UNARP messages received from other nodes.
214 It does not generate these messages.
215
216 PACKET EVENTS
217 The arp driver registers itself with the netinfo interface.
218 To gain access to these events, a handle from
219 net_protocol_lookup must be acquired by passing it the value
220 NHF_ARP. Through this interface, two packet events are sup-
221 ported:
222
223 SunOS 5.10 Last change: 2 Dec 2008 4
224
225 Protocols arp(7P)
226
227 Physical in - ARP packets received via a network inter face
228
229 Physical out - ARP packets to be sent out via a network
230 interface
231
232 For ARP packets, the hook_pkt_event structure is filled out
233 as follows:
234
235 hpe_ifp
236
237 Identifier indicating the inbound interface for pack-
238 ets received with the "physical in" event.
239
240 hpe_ofp
241
242 Identifier indicating the outbound interface for pack-
243 ets received with the "physical out" event.
244
245 hpe_hdr
246
247 Pointer to the start of the ARP header (not the eth-
248 ernet header).
249
250 hpe_mp
251
252 Pointer to the start of the mblk_t chain containing the
253 ARP packet.
254
255 hpe_mb
256
257 Pointer to the mblk_t with the ARP header in it.
258
259 NETWORK INTERFACE EVENTS
260 In addition to events describing packets as they move
261 through the system, it is also possible to receive notifica-
262 tion of events relating to network interfaces. These events
263 are all reported back through the same callback. The list
264 of events is as follows:
265
266 plumb
267
268 A new network interface has been instantiated.
269
270 SunOS 5.10 Last change: 2 Dec 2008 5
271
272 Protocols arp(7P)
273
274 unplumb
275
276 A network interface is no longer associated with ARP.
277
278 SEE ALSO
279 arp(1M), ifconfig(1M), privileges(5), if_tcp(7P), inet(7P),
280 netinfo(9F)
281
282 Plummer, Dave, An Ethernet Address Resolution Protocol or
283 Converting Network Protocol Addresses to 48 .bit Ethernet
284 Addresses for Transmission on Ethernet Hardware, RFC 826,
285 STD 0037, November 1982.
286
287 Malkin, Gary, ARP Extension - UNARP, RFC 1868, November,
288 1995
289
290 DIAGNOSTICS
291 Several messages can be written to the system logs (by the
292 IP module) when errors occur. In the following examples, the
293 hardware address strings include colon (:) separated ASCII
294 representations of the link layer addresses, whose lengths
295 depend on the underlying media (for example, 6 bytes for
296 Ethernet).
297
298 Node %x:%x ... %x:%x is using our IP address %d.%d.%d.%d on
299 %s.
300
301 Duplicate IP address warning. ARP has discovered another
302 host on a local network that responds to mapping
303 requests for the Internet address of this system, and
304 has defended the system against this node by re-
305 announcing the ARP entry.
306
307 %s has duplicate address %d.%d.%d.%d (in use by %x:%x ...
308 %x:%x); disabled.
309
310 Duplicate IP address detected while performing initial
311 probing. The newly-configured interface has been shut
312 down.
313
314 %s has duplicate address %d.%d.%d.%d (claimed by %x:%x ...
315 %x:%x); disabled.
316
317 Duplicate IP address detected on a running IP interface.
318 The conflict cannot be resolved, and the interface has
319 been disabled to protect the network.
320
321 SunOS 5.10 Last change: 2 Dec 2008 6
322
323 Protocols arp(7P)
324
325 Recovered address %d.%d.%d.%d on %s.
326
327 An interface with a previously-conflicting IP address
328 has been recovered automatically and reenabled. The con-
329 flict has been resolved.
330
331 Proxy ARP problem? Node '%x:%x ... %x:%x' is using
332 %d.%d.%d.%d on %s
333
334 This message appears if arp(1M) has been used to create
335 a published permanent (ATF_AUTHORITY) entry, and some
336 other host on the local network responds to mapping
337 requests for the published ARP entry.
338