Question

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??

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top