Class IpResolver
java.lang.Object
org.eclipse.mosaic.lib.objects.addressing.IpResolver
- All Implemented Interfaces:
Serializable
Class providing a singleton for global IP address management.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionIpResolver
(CIpResolver configuration) Gets a configuration and performs basic plausibility checks apaches commons-net could be helpful here. -
Method Summary
Modifier and TypeMethodDescriptionint
returns the maximum number of units that can be assigned IPs.Returns the netmask for subnets.static IpResolver
Returns theIpResolver
singleton.ipToName
(Inet4Address address) Converts an IPv4 address to a hostname.Method to look up anInet4Address
for a given MOSAIC-style host name.gets an id and calculates the corresponding IP address.registerHost
(String hostname) Adds a new entry to the map.reverseLookup
(Inet4Address address) Method to look up a MOSAIC-style host name for a givenInet4Address
.static void
setSingleton
(IpResolver ipResolver) Sets the IPResolver singleton.
-
Constructor Details
-
IpResolver
Gets a configuration and performs basic plausibility checks apaches commons-net could be helpful here.- Parameters:
configuration
- configuration taken from json
-
-
Method Details
-
setSingleton
Sets the IPResolver singleton. This can only be done once.- Parameters:
ipResolver
- the new instance of IPResolver
-
getSingleton
Returns theIpResolver
singleton. -
getMaxRange
public int getMaxRange()returns the maximum number of units that can be assigned IPs.- Returns:
- the maximum range as an int
-
getNetMask
Returns the netmask for subnets.- Returns:
- the netmask as a Inet4Address
-
lookup
Method to look up anInet4Address
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
Method to look up a MOSAIC-style host name for a givenInet4Address
.- Parameters:
address
- the Inet4Address to lookup- Returns:
- name of the host belonging to the given address or null if none found
-
registerHost
Adds a new entry to the map.- Parameters:
hostname
- hostname to register- Returns:
- returns the assigned IPv4 address
-
ipToName
Converts an IPv4 address to a hostname.- Parameters:
address
- address that shall be converted to a hostname- Returns:
- hostname
-
nameToIp
gets an id and calculates the corresponding IP address.- Parameters:
name
- the name which should be converted to an address- Returns:
- the corresponding address
-