In Android (or Java, I suppose), it's easy enough to determine whether a given address is site-local:

InetAddress a = InetAddress.getByName (addr_string);
if (a.isSiteLocalAddress())
    ...

However, each of the three flavors of site-local addresses has a different netmask associated with it. Is there a quick and easy to generate the netmask from the address??

有帮助吗?

解决方案

The netmask is used to establish which part of an addres is the network address, which part is dedicated to the hosts and which one is broadcast.

You make a bit-by-bit and between ip address and subnet mask in order to individuate each part.

You need more information than ip address in order to get netmask.

Hope this helps.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top