stealthcopter / AndroidNetworkTools

Set of useful android network tools
Apache License 2.0
1.36k stars 283 forks source link

getIPAddressFromMAC returns link-local IPv6 #76

Open rainmasak opened 3 years ago

rainmasak commented 3 years ago

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")

image

stealthcopter commented 3 years ago

Ah good find. I will fix this in the next version!