getAllIPAndMACAddressesInARPCache() returns two items with same value. (one for IPv4, one for link-local IPv6)
While iterating over keys, it encounters the wrong key/value pair first and therefore getIPAddressFromMAC returns the wrong key.
I suggest you either let user decide, which IP format they prefer (IPv6 or IPv4), or check for IP pattern before return (according to documentation, it should return IP in format "192.168.0.1")
getAllIPAndMACAddressesInARPCache() returns two items with same value. (one for IPv4, one for link-local IPv6) While iterating over keys, it encounters the wrong key/value pair first and therefore getIPAddressFromMAC returns the wrong key.
I suggest you either let user decide, which IP format they prefer (IPv6 or IPv4), or check for IP pattern before return (according to documentation, it should return IP in format "192.168.0.1")