Package org.onosproject.net.host
Class InterfaceIpAddress
- java.lang.Object
-
- org.onosproject.net.host.InterfaceIpAddress
-
public class InterfaceIpAddress extends Object
Represents a single IP address information on an interface. TODO: - Add computation for the default broadcast address if it is not specified - Add explicit checks that each IP address or prefix belong to the same IP version: IPv4/IPv6. - Inside the copy constructor we should use copy constructors for each field
-
-
Constructor Summary
Constructors Constructor Description InterfaceIpAddress(IpAddress ipAddress, IpPrefix subnetAddress)
Constructor for a given IP address and a subnet address.InterfaceIpAddress(IpAddress ipAddress, IpPrefix subnetAddress, IpAddress broadcastAddress)
Constructor for a given IP address and a subnet address.InterfaceIpAddress(IpAddress ipAddress, IpPrefix subnetAddress, IpAddress broadcastAddress, IpAddress peerAddress)
Constructor for a given IP address and a subnet address.InterfaceIpAddress(InterfaceIpAddress other)
Copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IpAddress
broadcastAddress()
Gets the subnet IP broadcast address.static IpAddress
computeBroadcastAddress(IpAddress ipAddress, IpPrefix subnetAddress)
Compute the IP broadcast address.boolean
equals(Object other)
int
hashCode()
IpAddress
ipAddress()
Gets the IP address.IpAddress
peerAddress()
Gets the IP point-to-point interface peer address.IpPrefix
subnetAddress()
Gets the IP subnet address.String
toString()
static InterfaceIpAddress
valueOf(String value)
Converts a CIDR string literal to an interface IP address.
-
-
-
Constructor Detail
-
InterfaceIpAddress
public InterfaceIpAddress(InterfaceIpAddress other)
Copy constructor.- Parameters:
other
- the object to copy from
-
InterfaceIpAddress
public InterfaceIpAddress(IpAddress ipAddress, IpPrefix subnetAddress)
Constructor for a given IP address and a subnet address.- Parameters:
ipAddress
- the IP addresssubnetAddress
- the IP subnet address
-
InterfaceIpAddress
public InterfaceIpAddress(IpAddress ipAddress, IpPrefix subnetAddress, IpAddress broadcastAddress)
Constructor for a given IP address and a subnet address.- Parameters:
ipAddress
- the IP addresssubnetAddress
- the IP subnet addressbroadcastAddress
- the IP broadcast address. It can be used to specify non-default broadcast address
-
InterfaceIpAddress
public InterfaceIpAddress(IpAddress ipAddress, IpPrefix subnetAddress, IpAddress broadcastAddress, IpAddress peerAddress)
Constructor for a given IP address and a subnet address.- Parameters:
ipAddress
- the IP addresssubnetAddress
- the IP subnet addressbroadcastAddress
- the IP broadcast address. It can be used to specify non-default broadcast address. It should be null for point-to-point interfaces with a peer addresspeerAddress
- the peer IP address for point-to-point interfaces
-
-
Method Detail
-
ipAddress
public IpAddress ipAddress()
Gets the IP address.- Returns:
- the IP address
-
subnetAddress
public IpPrefix subnetAddress()
Gets the IP subnet address.- Returns:
- the IP subnet address
-
broadcastAddress
public IpAddress broadcastAddress()
Gets the subnet IP broadcast address.- Returns:
- the subnet IP broadcast address
-
peerAddress
public IpAddress peerAddress()
Gets the IP point-to-point interface peer address.- Returns:
- the IP point-to-point interface peer address
-
valueOf
public static InterfaceIpAddress valueOf(String value)
Converts a CIDR string literal to an interface IP address. E.g. 10.0.0.1/24- Parameters:
value
- an IP address value in string form- Returns:
- an interface IP address
- Throws:
IllegalArgumentException
- if the argument is invalid
-
computeBroadcastAddress
public static IpAddress computeBroadcastAddress(IpAddress ipAddress, IpPrefix subnetAddress)
Compute the IP broadcast address.- Parameters:
ipAddress
- base IP addresssubnetAddress
- subnet specification- Returns:
- the IP broadcast address
-
-