Package org.graylog2.utilities
Class IpSubnet
java.lang.Object
org.graylog2.utilities.IpSubnet
A class that enables to get an IP range from CIDR specification. It supports
both IPv4 and IPv6.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
contains
(InetAddress address) boolean
formatCIDR
(String value) Formats the given value in CIDR notation.int
int
hashCode()
toString()
-
Constructor Details
-
IpSubnet
- Throws:
UnknownHostException
-
-
Method Details
-
getNetworkAddress
-
getBroadcastAddress
-
contains
- Throws:
UnknownHostException
-
contains
-
getPrefixLength
public int getPrefixLength() -
equals
-
hashCode
public int hashCode() -
toString
-
formatCIDR
Formats the given value in CIDR notation. If the value is already valid CIDR just return it. Otherwise, check if the value is an individual IP address. If it is, add the appropriate /32 or /128 depending on if the IP is v4 or v6. If the value is not already valid CIDR notation or an IP address, return empty.- Parameters:
value
- string value to be formatted as CIDR- Returns:
- optional valid CIDR formatted String
-