Reversed MAC lookup inside FreeBSD kernel?

Bruce M Simpson bms at spc.org
Fri Aug 29 11:06:40 PDT 2003


On Fri, Aug 29, 2003 at 11:17:16AM -0500, Khoa A. To wrote:
> I need to get a translation of MAC addresses to IP addresses in the kernel.
> I saw some postings about how to translate MAC to IP in the user level, but
> they seem to require the host to send a packet to that MAC address and some
> other ways that also require the host to actually send some request packets
> out.  All my MAC-IP addresses are already set statically using "arp -s" in
> the ARP table.  When I'm in the kernel, how do I get a hold of the ARP table
> and do some kind of reversed search to get the IP address out?

ARP information is held in the routing table.
Look at the output of netstat -arn and look for routes containing the L
flag (LLINFO). If you need to walk through the routing table, look at how
rtalloc() does it. 'struct rtentry' should be pretty self explanatory...

BMS


More information about the freebsd-net mailing list