سؤال

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