I have an InterfaceAddress that returns an ipv4 address (4 octets). However the network prefix length seems to be for the ipv6 address associated with the interface (it's returning as 128). How do I find the correct network prefix length?
Enumeration<NetworkInterface> NetworkInterface.getNetworkInterfaces()
for (; interfaces.hasMoreElements();) {
final List<InterfaceAddress>interfaceAddresses =
interfaces.nextElement().getInterfaceAddresses();
for (final InterfaceAddress address : interfaceAddresses) {
assert(address.getAddress().getAddress().length == 4); // [sic]
assert(address.getNetworkPrefixLength() < 32); // <- Fails. Actually equals 128
}
}