.\" $NetBSD: arp.9,v 1.26.28.1 2019/09/02 17:17:12 martin Exp $ .\" .\" Copyright (c) 1997 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation .\" by Ignatios Souvatzis. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .\" .Dd September 1, 2019 .Dt ARP 9 .Os .Sh NAME .Nm arp , .Nm arp_ifinit , .Nm arpresolve , .Nm arpintr .Nd externally visible ARP functions .Sh SYNOPSIS .In netinet/if_inarp.h .Ft void .Fn arp_ifinit "struct ifnet *ifp" "struct ifaddr *ifa" .Ft int .Fn arpresolve "struct ifnet *ifp" "const struct rtentry *rt" "struct mbuf *m" "const struct sockaddr *dst" "void *desten" "size_t destlen" .Ft void .Fn arpintr .Sh DESCRIPTION The .Nm functions provide the interface between the .Nm module and the network drivers which need .Nm functionality. Such drivers must request the .Ar arp attribute in their "files" declaration. .Bl -tag -width "arp_ifinit()" .It Fn arp_ifinit Sets up the .Nm specific fields in .Fa ifa . Additionally, it sends out a gratuitous .Nm request on .Fa ifp , so that other machines are warned that we have a (new) address and duplicate addresses can be detected. .Pp You must call this in your drivers' ioctl function when you get a SIOCSIFADDR request with an AF_INET address family. .It Fn arpresolve is called by network output functions to resolve an IPv4 address. If no .Fa rt is given, a new one is looked up or created. If the passed or found .Fa rt does not contain a valid gateway link level address, a pointer to the packet in .Fa m is stored in the route entry, possibly replacing older stored packets, and an .Nm request is sent instead. When an .Nm reply is received, the last held packet is send. Otherwise, the looked up address is returned and written into the storage .Fa desten points to. .Fn arpresolve returns 1, if a valid address was stored to .Fa desten , and the packet can be sent immediately. Else a 0 is returned. .It Fn arpintr When an .Nm packet is received, the network driver (class) input interrupt handler queues the packet on the arpintrq queue, and requests an .Fn arpintr soft interrupt callback. .Fn arpintr dequeues the packets, performs sanity checks and calls (for IPv4 .Nm packets, which are the only ones supported currently) the .Fn in_arpinput function. .Fn in_arpinput either generates a reply to request packets, and adds the sender address translation to the routing table, if a matching route entry is found. If the route entry contained a pointer to a held packet, that packet is sent. .El .Sh CODE REFERENCES The ARP code is implemented in .Pa sys/net/if_arp.h , .Pa sys/netinet/if_inarp.h and .Pa sys/netinet/if_arp.c . .Sh SEE ALSO .Xr ether_ifattach 9 .\" .Xr fddi_ifattach 9 , .\" .Xr arc_ifattach 9 .Pp Plummer, D., "RFC826", An Ethernet Address Resolution Protocol. .Sh STANDARDS RFC 826 .Sh HISTORY Rewritten to support other than Ethernet link level addresses in .Nx 1.3 . .Sh AUTHORS .An UCB CSRG (original implementation) .An Ignatios Souvatzis (support for non-Ethernet)