Package ai.vespa.net
Class CidrBlock
java.lang.Object
ai.vespa.net.CidrBlock
Represents a single IPv4 or IPv6 CIDR block.
- Author:
- valerijf
-
Constructor Summary
ConstructorDescriptionCidrBlock
(byte[] address, int prefixLength) CidrBlock
(InetAddress inetAddress) Creates a CIDR block that only contains the provided IP address (/32 if IPv4, /128 if IPv6)CidrBlock
(InetAddress inetAddress, int prefixLength) -
Method Summary
Modifier and TypeMethodDescriptionaddByte
(int byteOffset, int n) Add 'n' to the byte at the given offset, truncating overflow bits.asString()
clearLeastSignificantBits
(int bits) boolean
contains
(InetAddress address) boolean
static CidrBlock
fromString
(String cidr) int
getByte
(int byteOffset) Return the byte at the given offset.int
hashCode()
boolean
isIpv6()
boolean
overlapsWith
(CidrBlock other) int
resize
(int newPrefixLength) Returns a copy of this resized to the given newPrefixLengthsetByte
(int byteOffset, int n) Set the byte at the given offset to 'n'.toString()
-
Constructor Details
-
CidrBlock
Creates a CIDR block that only contains the provided IP address (/32 if IPv4, /128 if IPv6) -
CidrBlock
-
CidrBlock
public CidrBlock(byte[] address, int prefixLength)
-
-
Method Details
-
getInetAddress
- Returns:
- The first IP address in this CIDR block
-
prefixLength
public int prefixLength()- Returns:
- the number of bits in the network mask
-
isIpv6
public boolean isIpv6() -
contains
- Returns:
- true iff the address is in this CIDR network.
-
resize
Returns a copy of this resized to the given newPrefixLength -
clearLeastSignificantBits
-
clearHostIdentifier
- Returns:
- a copy of this CIDR block with the host identifier bits cleared
-
getByte
public int getByte(int byteOffset) Return the byte at the given offset. 0 refers to the most significant byte of the address. -
setByte
Set the byte at the given offset to 'n'. 0 refers to the most significant byte of the address. -
addByte
Add 'n' to the byte at the given offset, truncating overflow bits. 0 refers to the most significant byte of the address. -
overlapsWith
-
getDomainName
- Returns:
- the .arpa address for this CIDR block, does not include bit outside the prefix
-
iterableCidrs
- Returns:
- iterable over all CIDR blocks of the same prefix size, from the current one and up
-
iterableIps
-
equals
-
hashCode
public int hashCode() -
toString
-
asString
-
fromString
-