I need to keep a permanent link to a third-party device on an arbitrary IP network, where the IP address of the devices can be statically or randomly assigned by DHCP. I do not control devices on the network, and I cannot rely on DNS or other ad-hoc network protocols that exist or work with devices.
Therefore, I was tasked with investigating the use of hardware addresses and ARP. This will work, but I do not want to duplicate the code. The kernel must manage the ARP table. On Windows, you can access it using GetIpNetTable , etc.
I hope there is an API to answer these two questions:
- How do I translate from IP to MAC address? (ARP)
- How do I translate from MAC to IP address? (InARP)
If not, then I may have to do it more manually:
- How to read kernel ARP table?
- How to add a record if I have defined the mapping myself?
source
share