views:

1287

answers:

3

I'm working on an embedded linux system in C, I'm looking for the source code to the equivalet of SendARP in Windows. Any pointers?

A: 

This may be of interest: http://cvs.linux-ha.org/viewcvs/viewcvs.cgi/linux-ha/resources/heartbeat/SendArp.in?rev=1.4

It is an implmenetation in a Bourne Shell script.

mmattax
I really need C - but that's the right idea
Jeff
A: 

I've never seen anything specifically for ARP, but I think you can send any kind of packet you want using libpcap and the appropriate RFCs.

jbourque
+1  A: 

Take a look at arping. The quick and dirty way of sending an arp would be to do:


foo = system("/somepath/arping somehost");

But a look through the arping source should be able to give you a better solution.

For the all-out solution though, you can construct your own by hand and use either a raw socket or libpcap to send it.


btw. If all you're trying to do is force an arp to be sent (but necessarily from you) you could achieve that by deleting any arp entry that you already have for your host. The next access to that address will require an arp to be sent.

eg. /usr/sbin/arp -d destination_host_ip

Andrew Edgecombe