ARP(9)
π ARP(9) β ok so this is the kernel developer's manual page for ARP, bestie
Yes hi, hello, welcome to ARP(9), the page where the kernel devs hand you the externally visible ARP functions and trust you to not fumble it. Grab a snack, this is actually kind of iconic. π¦
β¨ NAME β¨
arp, arp_ifinit, arpresolve, arpintr β the externally visible ARP functions, aka the little bridge between the arp module and your network driver. π«Ά
πΈ SYNOPSIS πΈ
#include <netinet/if_inarp.h>
void
arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa);
int
arpresolve(struct ifnet *ifp, const struct rtentry *rt, struct mbuf *m,
const struct sockaddr *dst, void *desten, size_t destlen);
void
arpintr();
Copy those signatures exactly, ngl, don't get creative with them. π
π DESCRIPTION π
The arp functions provide the interface between the arp module and the network drivers which need arp functionality. Like, they're the group chat between your driver and ARP itself. Such drivers must request the arp attribute in their "files" declaration β no attribute, no ARP, periodt. π
arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa)β Sets up the arp specific fields inifa. On top of that, it sends out a gratuitous arp request onifp, so that other machines are warned that we have a (new) address and duplicate addresses can be detected. It's giving "hey besties, I'm HERE and also is anyone else using my address" energy. π
You must call this in your drivers' ioctl function when you get a SIOCSIFADDR request with an AF_INET address family. Not optional, not a vibe, just do it. π
arpresolve(struct ifnet *ifp, const struct rtentry *rt, struct mbuf *m, const struct sockaddr *dst, void *desten, size_t destlen)β is called by network output functions to resolve an IPv4 address. If nortis given, a new one is looked up or created. If the passed or foundrtdoes not contain a valid gateway link level address, a pointer to the packet inmis stored in the route entry, possibly replacing older stored packets, and an arp request is sent instead. (So yeah, your packet is lowkey being held while everyone waits π« .) When an arp reply is received, the last held packet is send. Otherwise, the looked up address is returned and written into the storagedestenpoints to.
arpresolve() returns 1, if a valid address was stored to desten, and the packet can be sent immediately. Else a 0 is returned. Simple as that, slay. β¨
arpintr()β When an arp packet is received, the network driver (class) input interrupt handler queues the packet on thearpintrqqueue, and requests anarpintr()soft interrupt callback.arpintr()dequeues the packets, performs sanity checks and calls (for IPv4 arp packets, which are the only ones supported currently) thein_arpinput()function.
Then 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. The held packet finally gets to leave the house. π
π CODE REFERENCES π
The ARP code is implemented in sys/net/if_arp.h, sys/netinet/if_inarp.h and sys/netinet/if_arp.c. Go read it, bestie, iykyk. π
π SEE ALSO π
ether_ifattach(9)- Plummer, D., "RFC826", An Ethernet Address Resolution Protocol.
β STANDARDS β
RFC 826 β that's the one, that's the blueprint. π
π HISTORY π
Rewritten to support other than Ethernet link level addresses in NetBSD 1.3. A glow-up, honestly. β¨
π§ AUTHORS π§
- UCB CSRG (original implementation)
- Ignatios Souvatzis (support for non-Ethernet)
Two legends, no cap. π«Ά
ok that's the whole page, nothing skipped, every flag and function accounted for, you're welcome π
Debian Β· September 1, 2019 Β· ARP(9) β mwah, that's the sign-off, go resolve some addresses bestie π¦π
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 1997 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms