1*1b6d1992Ssevan.\" $NetBSD: arp.9,v 1.27 2019/09/01 14:49:11 sevan Exp $ 204b62785Sis.\" 32c7fa23cSis.\" Copyright (c) 1997 The NetBSD Foundation, Inc. 404b62785Sis.\" All rights reserved. 504b62785Sis.\" 6dc068e0dSis.\" This code is derived from software contributed to The NetBSD Foundation 7dc068e0dSis.\" by Ignatios Souvatzis. 8dc068e0dSis.\" 904b62785Sis.\" Redistribution and use in source and binary forms, with or without 1004b62785Sis.\" modification, are permitted provided that the following conditions 1104b62785Sis.\" are met: 1204b62785Sis.\" 1. Redistributions of source code must retain the above copyright 1304b62785Sis.\" notice, this list of conditions and the following disclaimer. 1404b62785Sis.\" 2. Redistributions in binary form must reproduce the above copyright 1504b62785Sis.\" notice, this list of conditions and the following disclaimer in the 1604b62785Sis.\" documentation and/or other materials provided with the distribution. 1704b62785Sis.\" 18dc068e0dSis.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19dc068e0dSis.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20dc068e0dSis.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21dc068e0dSis.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22dc068e0dSis.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23dc068e0dSis.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24dc068e0dSis.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25dc068e0dSis.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26dc068e0dSis.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27dc068e0dSis.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28dc068e0dSis.\" POSSIBILITY OF SUCH DAMAGE. 29dc068e0dSis.\" 3004b62785Sis.\" 31*1b6d1992Ssevan.Dd September 1, 2019 3204b62785Sis.Dt ARP 9 33e4c16bfbSgarbled.Os 3404b62785Sis.Sh NAME 356be07a67Smrg.Nm arp , 366be07a67Smrg.Nm arp_ifinit , 376be07a67Smrg.Nm arpresolve , 386be07a67Smrg.Nm arpintr 3904b62785Sis.Nd externally visible ARP functions 4004b62785Sis.Sh SYNOPSIS 41472351e1Swiz.In netinet/if_inarp.h 4204b62785Sis.Ft void 4304b62785Sis.Fn arp_ifinit "struct ifnet *ifp" "struct ifaddr *ifa" 446ecca3f7Sis.Ft int 45*1b6d1992Ssevan.Fn arpresolve "struct ifnet *ifp" "const struct rtentry *rt" "struct mbuf *m" "const struct sockaddr *dst" "void *desten" "size_t destlen" 466ecca3f7Sis.Ft void 476ecca3f7Sis.Fn arpintr 4804b62785Sis.Sh DESCRIPTION 4904b62785SisThe 5004b62785Sis.Nm 5104b62785Sisfunctions provide the interface between the 5204b62785Sis.Nm 5304b62785Sismodule and the network drivers which need 5404b62785Sis.Nm 556bb98532Smycroftfunctionality. 566bb98532SmycroftSuch drivers must request the 576bb98532Smycroft.Ar arp 586ecca3f7Sisattribute in their "files" declaration. 5904b62785Sis.Bl -tag -width "arp_ifinit()" 6004b62785Sis.It Fn arp_ifinit 6104b62785SisSets up the 6204b62785Sis.Nm 6304b62785Sisspecific fields in 6404b62785Sis.Fa ifa . 6565393351SwizAdditionally, it sends out a gratuitous 666ecca3f7Sis.Nm 676ecca3f7Sisrequest on 6804b62785Sis.Fa ifp , 696ecca3f7Sisso that other machines are warned that we have a (new) address and 7004b62785Sisduplicate addresses can be detected. 710e3b2908Slukem.Pp 7210fc645fSisYou must call this in your drivers' ioctl function when you get a 7310fc645fSisSIOCSIFADDR request with an AF_INET address family. 746ecca3f7Sis.It Fn arpresolve 756ecca3f7Sisis called by network output functions to resolve an IPv4 address. 766ecca3f7SisIf no 776ecca3f7Sis.Fa rt 786bb98532Smycroftis given, a new one is looked up or created. 796bb98532SmycroftIf the passed or found 806ecca3f7Sis.Fa rt 816ecca3f7Sisdoes not contain a valid gateway link level address, a pointer to the packet 826ecca3f7Sisin 836ecca3f7Sis.Fa m 846ecca3f7Sisis stored in the route entry, possibly replacing older stored packets, and an 856ecca3f7Sis.Nm 866bb98532Smycroftrequest is sent instead. 876bb98532SmycroftWhen an 886ecca3f7Sis.Nm 896ecca3f7Sisreply is received, the last held packet is send. 906ecca3f7SisOtherwise, the looked up address is returned and written into the storage 916ecca3f7Sis.Fa desten 926ecca3f7Sispoints to. 936ecca3f7Sis.Fn arpresolve 946ecca3f7Sisreturns 1, if a valid address was stored to 956ecca3f7Sis.Fa desten , 966bb98532Smycroftand the packet can be sent immediately. 976bb98532SmycroftElse a 0 is returned. 986ecca3f7Sis.It Fn arpintr 996ecca3f7SisWhen an 1006ecca3f7Sis.Nm 10165393351Swizpacket is received, the network driver (class) input interrupt handler queues 1026ecca3f7Sisthe packet on the arpintrq queue, and requests an 1036ecca3f7Sis.Fn arpintr 10465393351Swizsoft interrupt callback. 1056ecca3f7Sis.Fn arpintr 1066ecca3f7Sisdequeues the packets, performs sanity checks and calls (for IPv4 1076ecca3f7Sis.Nm 10865393351Swizpackets, which are the only ones supported currently) the 1096ecca3f7Sis.Fn in_arpinput 1106ecca3f7Sisfunction. 1116ecca3f7Sis.Fn in_arpinput 1126ecca3f7Siseither generates a reply to request packets, and adds the sender address 113aae59958Srumbletranslation to the routing table, if a matching route entry is found. 1146ecca3f7SisIf the route entry contained a pointer to a held packet, that packet is 1156ecca3f7Sissent. 11604b62785Sis.El 1174119c8fbSwiz.Sh CODE REFERENCES 1184119c8fbSwizThe ARP code is implemented in 1194119c8fbSwiz.Pa sys/net/if_arp.h , 1204119c8fbSwiz.Pa sys/netinet/if_inarp.h 1214119c8fbSwizand 1224119c8fbSwiz.Pa sys/netinet/if_arp.c . 12304b62785Sis.Sh SEE ALSO 1242387d498Sjhawk.Xr ether_ifattach 9 1252387d498Sjhawk.\" .Xr fddi_ifattach 9 , 1262387d498Sjhawk.\" .Xr arc_ifattach 9 1270d16285aSjoerg.Pp 12804b62785SisPlummer, D., "RFC826", An Ethernet Address Resolution Protocol. 129b0b827a2Sjoerg.Sh STANDARDS 130b0b827a2SjoergRFC 826 131b0b827a2Sjoerg.Sh HISTORY 132b0b827a2SjoergRewritten to support other than Ethernet link level addresses in 133b0b827a2Sjoerg.Nx 1.3 . 13404b62785Sis.Sh AUTHORS 1350d16285aSjoerg.An UCB CSRG 1360d16285aSjoerg(original implementation) 1370d16285aSjoerg.An Ignatios Souvatzis 1380d16285aSjoerg(support for non-Ethernet) 139