xref: /netbsd/share/man/man9/arp.9 (revision c4a72b64)
1.\"	$NetBSD: arp.9,v 1.20 2002/08/03 14:56:18 soren Exp $
2.\"
3.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Ignatios Souvatzis.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.\"
38.Dd March 3, 1997
39.Dt ARP 9
40.Os
41.Sh NAME
42.Nm arp ,
43.Nm arp_ifinit ,
44.Nm arpresolve ,
45.Nm arpintr
46.Nd externally visible ARP functions
47.Sh SYNOPSIS
48.Fd #include \*[Lt]netinet/if_inarp.h\*[Gt]
49.Ft void
50.Fn arp_ifinit "struct ifnet *ifp" "struct ifaddr *ifa"
51.Ft int
52.Fn arpresolve "struct ifnet *ifp" "struct rtentry *rt" "struct mbuf *m" "struct sockaddr *dst" "u_char *desten"
53.Ft void
54.Fn arpintr
55.Sh DESCRIPTION
56The
57.Nm
58functions provide the interface between the
59.Nm
60module and the network drivers which need
61.Nm
62functionality.
63Such drivers must request the
64.Ar arp
65attribute in their "files" declaration.
66.Bl -tag -width "arp_ifinit()"
67.It Fn arp_ifinit
68Sets up the
69.Nm
70specific fields in
71.Fa ifa .
72Additionally, it sends out a gratuitous
73.Nm
74request on
75.Fa ifp ,
76so that other machines are warned that we have a (new) address and
77duplicate addresses can be detected.
78.Pp
79You must call this in your drivers' ioctl function when you get a
80SIOCSIFADDR request with an AF_INET address family.
81.It Fn arpresolve
82is called by network output functions to resolve an IPv4 address.
83If no
84.Fa rt
85is given, a new one is looked up or created.
86If the passed or found
87.Fa rt
88does not contain a valid gateway link level address, a pointer to the packet
89in
90.Fa m
91is stored in the route entry, possibly replacing older stored packets, and an
92.Nm
93request is sent instead.
94When an
95.Nm
96reply is received, the last held packet is send.
97Otherwise, the looked up address is returned and written into the storage
98.Fa desten
99points to.
100.Fn arpresolve
101returns 1, if a valid address was stored to
102.Fa desten ,
103and the packet can be sent immediately.
104Else a 0 is returned.
105.It Fn arpintr
106When an
107.Nm
108packet is received, the network driver (class) input interrupt handler queues
109the packet on the arpintrq queue, and requests an
110.Fn arpintr
111soft interrupt callback.
112.Fn arpintr
113dequeues the packets, performs sanity checks and calls (for IPv4
114.Nm
115packets, which are the only ones supported currently) the
116.Fn in_arpinput
117function.
118.Fn in_arpinput
119either generates a reply to request packets, and adds the sender address
120translation to to the routing table, if a matching route entry is found.
121If the route entry contained a pointer to a held packet, that packet is
122sent.
123.El
124.Sh SEE ALSO
125.Xr ether_ifattach 9
126.\" .Xr fddi_ifattach 9 ,
127.\" .Xr arc_ifattach 9
128.br
129Plummer, D., "RFC826", An Ethernet Address Resolution Protocol.
130.Sh AUTHORS
131UCB CSRG (original implementation)
132.br
133Ignatios Souvatzis (support for non-Ethernet)
134.Sh CODE REFERENCES
135The ARP code is implemented in
136.Pa sys/net/if_arp.h ,
137.Pa sys/netinet/if_inarp.h
138and
139.Pa sys/netinet/if_arp.c .
140.Sh STANDARDS
141RFC 826
142.Sh HISTORY
143Rewritten to support other than Ethernet link level addresses in
144.Nx 1.3 .
145