views:

119

answers:

2

I have a need for some C or C++ code, compilable under Linux, to be able to take a list of IP addresses of some arbitrary number of remote hosts machines and obtain a ethernet MAC address for each one. These host machines may be on the same subnet or they could be on a different subnet behind a router. Its OK if the MAC address of some or all of the remote hosts is the address of the interface on the router. Ultimately, I want to hand off the IP address and MAC address to an FPGA who will use these pieces of information to format and send UDP/IP packets over ethernet to the hosts. Obviously, the FPGA will also be given its own MAC address and IP address to fill in the source MAC and source IP addresses in the packets.

Is there some code I can be pointed to that can create and broadcast ARP packets to these remote machines and receive back the ARP response packets such that the destination MAC addresses can be extracted?

+1  A: 

Part of what you want to do requires some raw socket programming.

http://mixter.void.ru/rawip.html

The source for the linux arp command will give the rest of what you need. Here's a link:

http://www.comp.nus.edu.sg/~cs4236/readings/out/html/arp_8c-source.html

Joshua Smith
A: 

I recommend looking into arping which is doing a somewhat identical job. It takes IPs and MACs and tries to receive additional informationen. Or justs pings them.

http://freshmeat.net/projects/arping/

lhw