The Windows API contains a very handy function called SendARP. You can give it some source IP and a destination IP and it gives you the MAC address of the client with that destination IP. Also, this function can be used by standard users on Windows, i.e. does not need Administrator privileges.
Does the Linux API have a function that does the same as straightforward as SendARP?
I already thought about doing calls like ping -c 1 xxx.xxx.xxx.xxx
and then parse the output of arp -a -v
(of course while wrapping these commands in popen
), but this seems rather ineffient, not to mention possible security issues that may arise by calling external programs. Sadly, Wine is missing SendARP as well, it is marked as a stub in iphlpapi.
Please note that the answer should be executable as a normal user as well, i.e. without root privileges (otherwise I could just create a raw socket and construct the ARP packet myself, but this requires the executable to have the CAP_NET_RAW capability, which needs to be assigned to it by root, explained here).