private void setNetmask(InterfaceAddress it) throws Exception { if ( ( isLoopback || ( it.getNetworkPrefixLength() != 0 ) ) && ( address instanceof Inet4Address) ) { String subnet = ipAddress() + "/" + it.getNetworkPrefixLength(); if ( isLoopback ) { subnet = ipAddress() + "/8"; // because getNetworkPrefixLength() incorrectly returns 0 for IPv4 loopback } SubnetUtils utils = new SubnetUtils(subnet); netmask = utils.getInfo().getNetmask(); } else if ( (it.getNetworkPrefixLength() != 0 ) && ( address instanceof Inet6Address) ) { netmask = SocketUtilsIPV6.getIPV6NetMask(ipAddress() + "/" + it.getNetworkPrefixLength()); } }
private void setNetmask(InterfaceAddress it) throws Exception { if ( ( isLoopback || ( it.getNetworkPrefixLength() != 0 ) ) && ( address instanceof Inet4Address) ) { String subnet = ipAddress() + "/" + it.getNetworkPrefixLength(); if ( isLoopback ) { subnet = ipAddress() + "/8"; // because getNetworkPrefixLength() incorrectly returns 0 for IPv4 loopback } SubnetUtils utils = new SubnetUtils(subnet); netmask = utils.getInfo().getNetmask(); } else if ( (it.getNetworkPrefixLength() != 0 ) && ( address instanceof Inet6Address) ) { netmask = SocketUtilsIPV6.getIPV6NetMask(ipAddress() + "/" + it.getNetworkPrefixLength()); } }