Class InterfaceIpAddress


  • public class InterfaceIpAddress
    extends java.lang.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 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 address
        subnetAddress - 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 address
        subnetAddress - the IP subnet address
        broadcastAddress - 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 address
        subnetAddress - the IP subnet address
        broadcastAddress - 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 address
        peerAddress - 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​(java.lang.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:
        java.lang.IllegalArgumentException - if the argument is invalid
      • computeBroadcastAddress

        public static IpAddress computeBroadcastAddress​(IpAddress ipAddress,
                                                        IpPrefix subnetAddress)
        Compute the IP broadcast address.
        Parameters:
        ipAddress - base IP address
        subnetAddress - subnet specification
        Returns:
        the IP broadcast address
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object