Results 1 to 6 of 6
Can somebody tell me how to resolve MAC address of the next hop, in the C program ? I have the IP address of next hop....
- 09-30-2007 #1Just Joined!
- Join Date
- Sep 2007
- Posts
- 3
resolving MAC address of the next hop
Can somebody tell me how to resolve MAC address of the next hop, in the C program ? I have the IP address of next hop.
- 09-30-2007 #2Linux Enthusiast
- Join Date
- Apr 2004
- Location
- UK
- Posts
- 658
To the best of my knowledge, you can't easily get MAC addresses beyond your broadcast range, normally your default gateway.
If you can tell us what you are trying to do, we may be able to suggest an alternate method.
Let us know how you get on,
Chris...To be good, you must first be bad. "Newbie" is a rank, not a slight.
- 09-30-2007 #3Just Joined!
- Join Date
- Sep 2007
- Posts
- 3
- 09-30-2007 #4Linux Enthusiast
- Join Date
- Apr 2004
- Location
- UK
- Posts
- 658
If it's directly connected then yes, it will be in your broadcast range and you should be able to look up the MAC address for it. Check by running "arp -a"
The ARP cache is a list of IPs and MAC addresses stored in the kernel along with a few other details. You could probably access this directly but you'd need someone else's help there.
A quick and dirty solution would be to read /proc/net/arp. It contains the information you need in a reasonably verbose format. You should be able to parse it for the information you need.
Let us know how you get on,
Chris...To be good, you must first be bad. "Newbie" is a rank, not a slight.
- 09-30-2007 #5Just Joined!
- Join Date
- Sep 2007
- Posts
- 3
resolving MAC
I want to code whole process in C program i.e sending arp, getting MAC etc.
I have Next hop IP address with me.
Is there any system call which I can call in my program (user space)? or any alternative way in program.
Thanks
- 10-07-2007 #6Just Joined!
- Join Date
- Oct 2005
- Posts
- 10
Resolving MAC address from C code
Hi,
Yes you can do this by invoking this instruction in your C program as given below code...
system("arp -a IP-address");
Regards
Jyothi Vajja




