Get peer device's IP address in wifi-direct p2p connection

SS. picture SS. · Jun 20, 2012 · Viewed 8.9k times · Source

My app needs to know the peer device’s IP address when my device is a group owner (GO) in a wifi-direct P2P connection (usually GO acts as DHCP server and peer station receives the IP from the server). I figured out that the DHCP client list is stored in /data/misc/dhcp/dnsmasq.leases file, but the app has to be part of “dhcp” group to read that file and I am getting EACCES (Permission denied) when trying to read it.

Is there a permission that I can add in the manifest to read that file? Or is there any other way to get this DHCP client list from java/native Android framework without root?

Answer

damian picture damian · Jun 21, 2012

I solved this by sending out the peer's local ip address (starting with 192.168.x.x) to the group owner. After this "handshake", which doesn't really take time, it's all good to go. Did not find any other way to get the peer's ip addresses, the only information provided by GroupListener/PeerListener/... is the mac address.