Class IpResolver

java.lang.Object
org.eclipse.mosaic.lib.objects.addressing.IpResolver
All Implemented Interfaces:
Serializable

public final class IpResolver extends Object implements Serializable
Class providing a singleton for global IP address management.
See Also:
  • Constructor Details

    • IpResolver

      public IpResolver(CIpResolver configuration)
      Gets a configuration and performs basic plausibility checks apaches commons-net could be helpful here.
      Parameters:
      configuration - configuration taken from json
  • Method Details

    • setSingleton

      public static void setSingleton(IpResolver ipResolver)
      Sets the IPResolver singleton. This can only be done once.
      Parameters:
      ipResolver - the new instance of IPResolver
    • getSingleton

      public static IpResolver getSingleton()
      Returns the IpResolver singleton.
    • getMaxRange

      public int getMaxRange()
      returns the maximum number of units that can be assigned IPs.
      Returns:
      the maximum range as an int
    • getNetMask

      public Inet4Address getNetMask()
      Returns the netmask for subnets.
      Returns:
      the netmask as a Inet4Address
    • lookup

      public Inet4Address lookup(String hostname)
      Method to look up an Inet4Address for a given MOSAIC-style host name.
      Parameters:
      hostname - the units ID veh_0; rsu_1; tl_2; cs_3 etc.
      Returns:
      the hosts Inet4Address if it is registered or null if not
    • reverseLookup

      public String reverseLookup(Inet4Address address)
      Method to look up a MOSAIC-style host name for a given Inet4Address.
      Parameters:
      address - the Inet4Address to lookup
      Returns:
      name of the host belonging to the given address or null if none found
    • registerHost

      public Inet4Address registerHost(String hostname)
      Adds a new entry to the map.
      Parameters:
      hostname - hostname to register
      Returns:
      returns the assigned IPv4 address
    • ipToName

      public String ipToName(@Nonnull Inet4Address address)
      Converts an IPv4 address to a hostname.
      Parameters:
      address - address that shall be converted to a hostname
      Returns:
      hostname
    • nameToIp

      public Inet4Address nameToIp(String name)
      gets an id and calculates the corresponding IP address.
      Parameters:
      name - the name which should be converted to an address
      Returns:
      the corresponding address