Package io.openems.edge.core.host
Class NetworkInterface<A>
java.lang.Object
io.openems.edge.core.host.NetworkInterface<A>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Inet4AddressWithSubnetmask
This default address is always added to eth0. -
Constructor Summary
ConstructorsConstructorDescriptionNetworkInterface
(String name, ConfigurationProperty<Boolean> dhcp, ConfigurationProperty<Boolean> linkLocalAddressing, ConfigurationProperty<Inet4Address> gateway, ConfigurationProperty<Inet4Address> dns, ConfigurationProperty<Set<Inet4AddressWithSubnetmask>> addresses, A attachment) -
Method Summary
Modifier and TypeMethodDescriptionstatic NetworkInterface<?>
Parses a JsonObject to aNetworkInterface
object.Gets the addresses configured in the network.Gets the configured addresses including the default addresses if any.Gets the network interface attachment.getDhcp()
Gets the network interface DHCP option.getDns()
Gets the network interface DNS server.Gets the network interface Gateway.Gets the network interface LinkLocalAddressing option.getName()
Gets the network interface name.com.google.gson.JsonObject
toJson()
Exports this NetworkInterface configuration as JSON.boolean
updateFrom
(NetworkInterface<?> change) Updates the interface from a NetworkInterfaceChange object.
-
Field Details
-
DEFAULT_ETH0_ADDRESS
This default address is always added to eth0.
-
-
Constructor Details
-
NetworkInterface
public NetworkInterface(String name, ConfigurationProperty<Boolean> dhcp, ConfigurationProperty<Boolean> linkLocalAddressing, ConfigurationProperty<Inet4Address> gateway, ConfigurationProperty<Inet4Address> dns, ConfigurationProperty<Set<Inet4AddressWithSubnetmask>> addresses, A attachment) throws OpenemsException - Throws:
OpenemsException
-
-
Method Details
-
from
public static NetworkInterface<?> from(String name, com.google.gson.JsonObject j) throws OpenemsError.OpenemsNamedException Parses a JsonObject to aNetworkInterface
object.- Parameters:
name
- the name of the network interface, e.g. "eth0"j
- the JsonObject- Returns:
- the new
NetworkInterface
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getName
Gets the network interface name.- Returns:
- the name
-
getDhcp
Gets the network interface DHCP option.- Returns:
- the DHCP option; true for enabled; false for disabled
-
getLinkLocalAddressing
Gets the network interface LinkLocalAddressing option.- Returns:
- the LinkLocalAddressing option; true for enabled; false for disabled
-
getGateway
Gets the network interface Gateway.- Returns:
- the Gateway
-
getAddresses
Gets the addresses configured in the network.- Returns:
- the addresses mapped with label.
-
getDns
Gets the network interface DNS server.- Returns:
- the DNS server
-
getAttachment
Gets the network interface attachment.An arbitrary attachment to this NetworkInterface. Can be used to store e.g. a configuration file path.
- Returns:
- the attachment
-
getAddressesIncludingDefaults
Gets the configured addresses including the default addresses if any.- Returns:
- all addresses
-
toJson
public com.google.gson.JsonObject toJson()Exports this NetworkInterface configuration as JSON.{ "dhcp": boolean, "linkLocalAddressing": boolean, "gateway": string, "dns": string, "addresses": [{ "label": string, "address": string, "subnetmask": string }] }
- Returns:
- configuration as JSON
- Throws:
OpenemsError.OpenemsNamedException
- on error.
-
updateFrom
Updates the interface from a NetworkInterfaceChange object.- Parameters:
change
- the object containing the changes- Returns:
- true if values changed
-