/** * Return a {@link SubnetInfo} instance that contains subnet-specific statistics * @return new instance */ public final SubnetInfo getInfo() { return new SubnetInfo(); }
public String getAddress() { return format(toArray(address())); }
public String getAddress() { return format(toArray(address())); }
public String getBroadcastAddress() { return format(toArray(broadcast())); }
/** * {@inheritDoc} * @since 2.2 */ @Override public String toString() { return "CIDR Signature:\t[" + getCidrSignature() + "] Netmask: [" + getNetmask() + "]\n" + "Network:\t[" + getNetworkAddress() + "]\n" + "Broadcast:\t[" + getBroadcastAddress() + "]\n" + "First Address:\t[" + getLowAddress() + "]\n" + "Last Address:\t[" + getHighAddress() + "]\n" + "# Addresses:\t[" + getAddressCount() + "]\n" ; } }
public String getBroadcastAddress() { return format(toArray(broadcast())); }
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()); } }
public String[] getAllAddresses() { int ct = getAddressCount(); String[] addresses = new String[ct]; if (ct == 0) { return addresses; } for (int add = low(), j=0; add <= high(); ++add, ++j) { addresses[j] = format(toArray(add)); } return addresses; }
public String[] getAllAddresses() { int ct = getAddressCount(); String[] addresses = new String[ct]; if (ct == 0) { return addresses; } for (int add = low(), j=0; add <= high(); ++add, ++j) { addresses[j] = format(toArray(add)); } return addresses; }
/** * {@inheritDoc} * @since 2.2 */ @Override public String toString() { return "CIDR Signature:\t[" + getCidrSignature() + "] Netmask: [" + getNetmask() + "]\n" + "Network:\t[" + getNetworkAddress() + "]\n" + "Broadcast:\t[" + getBroadcastAddress() + "]\n" + "First Address:\t[" + getLowAddress() + "]\n" + "Last Address:\t[" + getHighAddress() + "]\n" + "# Addresses:\t[" + getAddressCount() + "]\n" ; } }
/** * Get the count of available addresses. * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false. * @return the count of addresses, may be zero. */ public int getAddressCount() { int count = broadcast() - network() + (isInclusiveHostCount() ? 1 : -1); return count < 0 ? 0 : count; }
/** * Get the count of available addresses. * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false. * @return the count of addresses, may be zero. */ public int getAddressCount() { int count = broadcast() - network() + (isInclusiveHostCount() ? 1 : -1); return count < 0 ? 0 : count; }
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()); } }
/** * Return a {@link SubnetInfo} instance that contains subnet-specific statistics * @return new instance */ public final SubnetInfo getInfo() { return new SubnetInfo(); }