arp-cache #
Read the host's ARP cache from OCaml.
The kernel already knows the hardware (MAC) address of every IPv4 neighbour it
has talked to recently, and tools that discover devices on a local network
often need that mapping without sending any packet. arp-cache reads it: on
Linux from /proc/net/arp, and on macOS and the BSDs by parsing the output of
arp -a. Incomplete entries are left out: an incomplete entry is one for which
the kernel has sent an ARP request and has had no reply yet, so it holds an IP
address and no MAC address. /proc/net/arp shows it with flags 0x0 and the
address 00:00:00:00:00:00, and arp -a prints (incomplete).
The line parsers, parse_proc_net_arp and parse_arp_a_output, are pure;
only table, lookup and lookup_mac touch the operating system. To encode
and decode ARP packets on the wire, use
nox-arp.
Installation #
Install with opam:
$ opam install arp-cache
If opam cannot find the package, it has probably not reached the public
opam-repository yet. Add the overlay repository, then install it:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install arp-cache
Usage #
Arp_cache.table () is the cache as a list of { ip; mac; interface }
entries, and Arp_cache.lookup_mac ip resolves one address. The arp-cache
command prints the table.
Licence #
ISC