public final class Ip4Network extends IpNetwork
Ip4Network
describes an IPv4 network.
IPv4 network is specified by an IPv4 address and prefix length.Modifier and Type | Field and Description |
---|---|
static int |
SIZE
The number of octets in an IPv4 address.
|
CIDR_SEPARATOR
Constructor and Description |
---|
Ip4Network(byte[] bytes)
Construct a new instance.
|
Ip4Network(byte[] bytes,
int prefix)
Construct a new instance.
|
Ip4Network(InetAddress iaddr)
Construct a new instance.
|
Ip4Network(InetAddress iaddr,
int prefix)
Construct a new instance.
|
Ip4Network(int addr)
Construct a new instance.
|
Ip4Network(int addr,
int prefix)
Construct a new instance.
|
Ip4Network(String cidr)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(IpNetwork inw)
Determine whether this network contains the given IP host.
|
static Ip4Network |
create(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address ipv4)
Create a new
Ip4Network instance from the given MD-SAL
ipv4-address. |
boolean |
equals(Object o)
Determine whether the given object is identical to this object.
|
int |
getAddress()
Return an integer value which represents the host address.
|
byte[] |
getBytes()
Return a byte array which represents the raw network address.
|
String |
getCidrText()
Return a string representation of this network in CIDR notation.
|
String |
getHostAddress()
Return a string representation of this network address without
CIDR prefix.
|
static InetAddress |
getInetAddress(int addr)
Create an
InetAddress instance which represents the IPv4 address
specified by the given integer value. |
static InetAddress |
getInetMask(int length)
Return an
InetAddress instance which represents the IPv4 netmask
specified by the given prefix length. |
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress |
getIpAddress()
Return an
IpAddress instance which represents this instance. |
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix |
getIpPrefix()
Return an
IpPrefix instance which represents this instance. |
int |
getMaxPrefix()
Return the maximum length of the network prefix.
|
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 |
getMdAddress()
Return a MD-SAL IP address which represents this network address.
|
int |
getNetMask()
Return an integer value which represents the network mask.
|
static int |
getNetMask(int length)
Return an integer value which represents the IPv4 netmask specified by
the given prefix length.
|
static InetAddress |
getNetworkAddress(InetAddress iaddr,
int length)
Create an IPv4 network address from the given IPv4 address and
prefix length.
|
static int |
getPrefixLength(byte[] bytes)
Return an IPv4 prefix length represented by the given byte array.
|
int |
hashCode()
Return the hash code of this object.
|
static Ip4Network |
toIp4Address(IpNetwork ipn)
Ensure that the given
IpNetwork instance represents an
IPv4 address. |
create, create, create, create, create, create, getCidrValue, getInetAddress, getInetAddress, getInetAddress, getPrefixLength, getText, isAddress, toString
public static final int SIZE
public Ip4Network(int addr)
This constructor specifies 32 as CIDR prefix length.
addr
- An integer value which represents an IPv4 address.public Ip4Network(int addr, int prefix)
addr
- An integer value which represents an IPv4 address.prefix
- Prefix length that specifies network range.
Note that zero means "no mask". So zero is treated as if
the maximum prefix length is specified.IllegalArgumentException
- The given prefix length is invalid.public Ip4Network(byte[] bytes)
This constructor specifies 32 as CIDR prefix length.
bytes
- A byte array which represents an IPv4 address.NullPointerException
- bytes
is null
.IllegalArgumentException
- The given byte address does not represent an IPv4 address.public Ip4Network(byte[] bytes, int prefix)
bytes
- A byte array which represents an IPv4 address.prefix
- Prefix length that specifies network range.
Note that zero means "no mask". So zero is treated as if
the maximum prefix length is specified.NullPointerException
- bytes
is null
.IllegalArgumentException
- The given prefix length is invalid.IllegalArgumentException
- The given byte address does not represent an IPv4 address.public Ip4Network(InetAddress iaddr)
This constructor specifies 32 as CIDR prefix length.
iaddr
- An InetAddress
instance which represents an IPv4
address.NullPointerException
- iaddr
is null
.IllegalArgumentException
- The given InetAddress
instance does not represent an IPv4
address.public Ip4Network(InetAddress iaddr, int prefix)
iaddr
- An InetAddress
instance which represents an IPv4
address.prefix
- Prefix length that specifies network range.
Note that zero means "no mask". So zero is treated as if
the maximum prefix length is specified.NullPointerException
- iaddr
is null
.IllegalArgumentException
- The given prefix length is invalid.IllegalArgumentException
- The given InetAddress
instance does not represent an IPv4
address.public Ip4Network(String cidr)
cidr
- A string representation of the IP network in CIDR notation.
Note that zero prefix means "no mask". So zero prefix is
treated as if the maximum prefix length is specified.NullPointerException
- cidr
is null
.IllegalArgumentException
- The given network address is invalid.public static int getPrefixLength(byte[] bytes)
Note that this method returns 32 if all the bits in the given array are not set.
bytes
- A byte array which represents IPv4 network mask.NullPointerException
- bytes
is null
.IllegalArgumentException
- The given byte array does not represent an IPv4 network mask.public static int getNetMask(int length)
length
- The IPv4 prefix length.
Note that zero means "no mask". So zero is treated as if
the maximum prefix length is specified.IllegalArgumentException
- The given prefix length is invalid.public static InetAddress getInetMask(int length)
InetAddress
instance which represents the IPv4 netmask
specified by the given prefix length.length
- The IPv4 prefix length.
Note that zero means "no mask". So zero is treated as if
the maximum prefix length is specified.InetAddress
instance.IllegalArgumentException
- The given prefix length is invalid.public static InetAddress getNetworkAddress(InetAddress iaddr, int length)
iaddr
- An InetAddress
instance.length
- The IPv4 prefix length.
Note that zero means "no mask". So zero is treated as if
the maximum prefix length is specified.InetAddress
instance which represents the IPv4
network address specified by the given pair of IPv4 address and
prefix length.NullPointerException
- iaddr
is null
.IllegalArgumentException
- The given IPv4 address or prefix length is invalid.public static InetAddress getInetAddress(int addr)
InetAddress
instance which represents the IPv4 address
specified by the given integer value.addr
- An integer value which represents the IPv4 address.InetAddress
instance.public static Ip4Network toIp4Address(IpNetwork ipn)
IpNetwork
instance represents an
IPv4 address.ipn
- An IpNetwork
instance.ipn
casted as Ip4Network
if ipn
represents an IPv4 address. Otherwise null
.public static Ip4Network create(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address ipv4)
Ip4Network
instance from the given MD-SAL
ipv4-address.ipv4
- An Ipv4Address
instance.Ip4Network
instance on success.
null
if ipv4
is null
.IllegalArgumentException
- The given instance contains an invalid value.public int getAddress()
public int getNetMask()
public int getMaxPrefix()
getMaxPrefix
in class IpNetwork
public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix getIpPrefix()
IpPrefix
instance which represents this instance.getIpPrefix
in class IpNetwork
IpPrefix
instance.public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress getIpAddress()
IpAddress
instance which represents this instance.
This method returns an IP address which represents a string representation of this network address without CIDR prefix.
getIpAddress
in class IpNetwork
IpAddress
instance.public org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 getMdAddress()
getMdAddress
in class IpNetwork
Ipv4
instance.public String getCidrText()
getCidrText
in class IpNetwork
public String getHostAddress()
getHostAddress
in class IpNetwork
public byte[] getBytes()
public boolean contains(IpNetwork inw)
contains
in class IpNetwork
inw
- An IpNetwork
instance to be tested.
Note that this method assumes that this argument specifies
the IP host, not IP network. So the CIDR prefix length
configured in this argument is always ignored.true
only if the IP network corresponding to this
instance contains the IP network specified by inw
.public boolean equals(Object o)
Copyright © 2018 OpenDaylight. All rights reserved.