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
ConstructorsConstructorDescriptionCidrBlock(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. 0 refers to the most significant byte of the address.asString()clearLeastSignificantBits(int bits) booleancontains(InetAddress address) booleanstatic CidrBlockfromString(String cidr) intgetByte(int byteOffset) Return the byte at the given offset. 0 refers to the most significant byte of the address.inthashCode()booleanisIpv6()booleanoverlapsWith(CidrBlock other) intresize(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'. 0 refers to the most significant byte of the address.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
-