public class IPv4Address extends IPAddress<IPv4Address> implements Writeable
Modifier and Type | Field and Description |
---|---|
static IPv4Address |
FULL_MASK |
static IPv4Address |
NO_MASK |
static IPv4Address |
NONE |
static org.projectfloodlight.openflow.types.IPv4Address.Reader |
READER |
Modifier and Type | Method and Description |
---|---|
IPv4Address |
and(IPv4Address other)
Perform a low level AND operation on the bits of two IPAddress objects
|
IPv4Address |
applyMask(IPv4Address mask) |
int |
asCidrMaskLength()
If this IPAddress represents a valid CIDR style netmask (see
isCidrMask()) returns the length of the prefix (the number of "1" bits).
|
int |
compareTo(IPv4Address o) |
boolean |
equals(Object obj) |
byte[] |
getBytes()
Returns the raw IP address of this
IPAddress object. |
int |
getInt() |
IPVersion |
getIpVersion()
Returns the Internet Protocol (IP) version of this object
|
int |
getLength() |
int |
hashCode() |
boolean |
isBroadcast()
Checks if the IPAddress is the global broadcast address
255.255.255.255 in case of IPv4
|
boolean |
isCidrMask()
Checks if this IPAddress represents a valid CIDR style netmask, i.e.,
it has a set of leading "1" bits followed by only "0" bits
|
boolean |
isLinkLocal()
Returns
true if the IPAddress is a link local address. |
boolean |
isLoopback()
Returns
true if the IPAddress is a loopback address. |
boolean |
isMulticast()
IPv4 multicast addresses are defined by the leading address bits of 1110
|
boolean |
isUnspecified()
Returns
true if the IPAddress is unspecified. |
IPv4Address |
not()
Returns a new IPAddress object with the bits inverted
|
static IPv4Address |
of(byte[] address)
Returns an
IPv4Address object that represents the given
IP address. |
static IPv4Address |
of(Inet4Address address)
Returns an
IPv4Address object that represents the given
IP address. |
static IPv4Address |
of(int raw)
Returns an
IPv4Address object that represents the given
IP address. |
static IPv4Address |
of(int octet1,
int octet2,
int octet3,
int octet4)
Returns an
IPv4Address object that represents the given
IP address. |
static IPv4Address |
of(String string)
Returns an
IPv4Address object that represents the given
IP address. |
static IPv4Address |
ofCidrMaskLength(int cidrMaskLength)
Returns an
IPv4Address object that represents the
CIDR subnet mask of the given prefix length. |
IPv4Address |
or(IPv4Address other)
Perform a low level OR operation on the bits of two IPAddress objects
|
void |
putTo(com.google.common.hash.PrimitiveSink sink) |
static IPv4Address |
read4Bytes(io.netty.buffer.ByteBuf c) |
Inet4Address |
toInetAddress()
Returns an
InetAddress object representing this IP address. |
String |
toString() |
IPv4AddressWithMask |
withMask(IPv4Address mask)
Returns an
IPv4AddressWithMask object that represents this
IP address masked by the given IP address mask. |
IPv4AddressWithMask |
withMaskOfLength(int cidrMaskLength)
Returns an
IPv4AddressWithMask object that represents this
IP address masked by the CIDR subnet mask of the given prefix length. |
void |
write4Bytes(io.netty.buffer.ByteBuf c) |
void |
writeTo(io.netty.buffer.ByteBuf bb) |
fromInetAddress, of
public static final IPv4Address NONE
public static final IPv4Address NO_MASK
public static final IPv4Address FULL_MASK
public static final org.projectfloodlight.openflow.types.IPv4Address.Reader READER
public IPVersion getIpVersion()
IPAddress
getIpVersion
in class IPAddress<IPv4Address>
public boolean isCidrMask()
IPAddress
isCidrMask
in class IPAddress<IPv4Address>
public int asCidrMaskLength()
IPAddress
asCidrMaskLength
in class IPAddress<IPv4Address>
public boolean isUnspecified()
IPAddress
true
if the IPAddress is unspecified.
The unspecified addresses, also known as the wildcard addresses, refer to:
IPv4Address
of 0.0.0.0
IPv6Address
of ::
isUnspecified
in class IPAddress<IPv4Address>
public boolean isLoopback()
IPAddress
true
if the IPAddress is a loopback address.
Loopback addresses refer to:
IPv4Address
within 127.0.0.0/8
IPv6Address
of ::1
isLoopback
in class IPAddress<IPv4Address>
public boolean isLinkLocal()
IPAddress
true
if the IPAddress is a link local address.
Link local addresses refer to:
IPv4Address
within 169.254.0.0/16
IPv6Address
within fe80::/10
isLinkLocal
in class IPAddress<IPv4Address>
public boolean isBroadcast()
IPAddress
isBroadcast
in class IPAddress<IPv4Address>
public boolean isMulticast()
isMulticast
in class IPAddress<IPv4Address>
public IPv4Address and(IPv4Address other)
IPAddress
and
in class IPAddress<IPv4Address>
other
- IPAddresspublic IPv4Address or(IPv4Address other)
IPAddress
or
in class IPAddress<IPv4Address>
other
- IPAddresspublic IPv4Address not()
IPAddress
not
in class IPAddress<IPv4Address>
@Nonnull public static IPv4Address of(@Nonnull byte[] address)
IPv4Address
object that represents the given
IP address. The argument is in network byte order: the highest
order byte of the address is in address[0]
.
The address byte array must be 4 bytes long (32 bits long).
Similar to InetAddress.getByAddress(byte[])
.
address
- the raw IP address in network byte orderIPv4Address
object that represents the given
raw IP addressNullPointerException
- if the given address was null
IllegalArgumentException
- if the given address was of an invalid
byte array lengthInetAddress.getByAddress(byte[])
@Nonnull public static IPv4Address of(int octet1, int octet2, int octet3, int octet4)
IPv4Address
object that represents the given
IP address. The arguments are in network byte order: the highest
order byte of the address is in octet1
.
For example, IPv4Address.of(192, 0, 2, 101)
yields
the IPv4 address of "192.0.2.101"
.
Use caution when providing byte-typed values as arguments.
"Byte-typed values" here refer to values that are of either the
primitive byte
type or the corresponding object wrapper
class Byte
. Byte-typed values greater than 127 are
essentially negative values and will be casted to negative
int
values, thus failing the numeric range checks
enforced by this method. Consider using of(byte[])
instead when handling byte-typed values.
IllegalArgumentException
- if any of the octets were
negative or greater than 255@Nonnull public static IPv4Address of(int raw)
IPv4Address
object that represents the given
IP address.raw
- the raw IP address represented as a 32-bit integerIPv4Address
object that represents the given
raw IP address@Nonnull public static IPv4Address of(@Nonnull String string) throws IllegalArgumentException
IPv4Address
object that represents the given
IP address. The argument is in the canonical quad-dotted notation.
For example, 1.2.3.4
.string
- the IP address in the canonical quad-dotted notationIPv4Address
object that represents the given
IP addressNullPointerException
- if the given string was null
IllegalArgumentException
- if the given string was not a valid
IPv4 address@Nonnull public static IPv4Address of(@Nonnull Inet4Address address)
IPv4Address
object that represents the given
IP address. The argument is given as an Inet4Address
object.address
- the IP address as an Inet4Address
objectIPv4Address
object that represents the
given IP addressNullPointerException
- if the given Inet4Address
was
null
@Nonnull public static IPv4Address ofCidrMaskLength(int cidrMaskLength)
IPv4Address
object that represents the
CIDR subnet mask of the given prefix length.cidrMaskLength
- the prefix length of the CIDR subnet mask
(i.e. the number of leading one-bits),
where 0 <= cidrMaskLength <= 32
IPv4Address
object that represents the
CIDR subnet mask of the given prefix lengthIllegalArgumentException
- if the given prefix length was invalid@Nonnull public IPv4AddressWithMask withMask(@Nonnull IPv4Address mask)
IPv4AddressWithMask
object that represents this
IP address masked by the given IP address mask.withMask
in class IPAddress<IPv4Address>
mask
- the IPv4Address
object that represents the maskIPv4AddressWithMask
object that represents this
IP address masked by the given maskNullPointerException
- if the given mask was null
@Nonnull public IPv4AddressWithMask withMaskOfLength(int cidrMaskLength)
IPv4AddressWithMask
object that represents this
IP address masked by the CIDR subnet mask of the given prefix length.withMaskOfLength
in class IPAddress<IPv4Address>
cidrMaskLength
- the prefix length of the CIDR subnet mask
(i.e. the number of leading one-bits),
where 0 <= cidrMaskLength <= 32
IPv4AddressWithMask
object that
represents this IP address masked by the CIDR
subnet mask of the given prefix lengthIllegalArgumentException
- if the given prefix length was invalidofCidrMaskLength(int)
public int getInt()
public byte[] getBytes()
IPAddress
IPAddress
object. The result
is in network byte order: the highest order byte of the address is in
getBytes()[0]
.
Similar to InetAddress.getAddress()
getBytes
in class IPAddress<IPv4Address>
InetAddress.getAddress()
public int getLength()
getLength
in interface OFValueType<IPv4Address>
@Nonnull public Inet4Address toInetAddress()
IPAddress
InetAddress
object representing this IP address.
The resulting InetAddress
object:
Inet6Address
toInetAddress
in class IPAddress<IPv4Address>
public String toString()
toString
in class IPAddress<IPv4Address>
public void write4Bytes(io.netty.buffer.ByteBuf c)
public static IPv4Address read4Bytes(io.netty.buffer.ByteBuf c)
public IPv4Address applyMask(IPv4Address mask)
applyMask
in interface OFValueType<IPv4Address>
public int hashCode()
hashCode
in class IPAddress<IPv4Address>
public boolean equals(Object obj)
equals
in class IPAddress<IPv4Address>
public int compareTo(IPv4Address o)
compareTo
in interface Comparable<IPv4Address>
public void putTo(com.google.common.hash.PrimitiveSink sink)
putTo
in interface PrimitiveSinkable
Copyright © 2015. All rights reserved.