Class NetworkService
java.lang.Object
com.tccc.kos.commons.util.ready.ReadyBean
com.tccc.kos.commons.core.service.AbstractService
com.tccc.kos.core.service.network.NetworkService
- All Implemented Interfaces:
CtxEventListener,BinaryMsgIfaceFactory,ContextHandleAware,HandleAware,Ready,ReadyAndReadyListener,ReadyListener
Service that configures network interfaces on nodes within the device. This
typically operates on a networkMgr from the local node, but in some device
configurations, may provide access to network configuration of multiple nodes.
- Version:
- 2024-05-23
-
Method Summary
Modifier and TypeMethodDescriptionvoidenableInterface(NodeId nodeId, String name, boolean enable) Set the specified interface enabled or not.voidenableInterface(String name, boolean enable) Set the specified interface enabled or not on the current node.voidenableRadio(boolean enable) Enable / disable the radio on this node.voidenableRadio(NodeId nodeId, boolean enable) Enable / disable the radio on this node.getAccessPoints(NodeId nodeId, String name) Return the list of previously detected access points on the specified interface on the specified node.getAccessPoints(String name) Return the list of previously detected access points on the specified interface on this node.Return the details for all available interfaces.getAllInterfaceDetails(NodeId nodeId) Return details for all available network interfaces.getIface(String name, BinaryMsgSession session) Given the name of an interface from a BinaryMsgSession, return an instance of BinaryMsgIface or null.Return interface names be category association for the current node.getInterfaceAssociations(NodeId nodeId) Return interface names be category association.getInterfaceDetails(NodeId nodeId, String name) Return the details for the specified network interface.getInterfaceDetails(String name) Return the details for the specified network interface on the current node.Return the list of available network interfaces on the current node.getInterfaces(NodeId nodeId) Return the list of available network interfaces.booleanReturn true if the radio is enabled on this node, false if it is not.booleanisRadioEnabled(NodeId nodeId) Return true if the radio is enabled on the specified node, false if it is not.ping(NodeId nodeId, PingRequest request) Perform a ping from the specified node using the specified ping settings.Ping the specified hostname from the specified node.ping(PingRequest request) Perform a ping from this node using the specified ping settings.Ping the specified hostname from this node.voidscanAccessPoints(NodeId nodeId, String name) Perform a scan of available wifi access points visible from the specified network interface on the specified node.voidscanAccessPoints(String name) Perform a scan of available wifi access points visible from the specified network interface on this node.voidsetConnection(NodeId nodeId, NetworkConnection networkConnection) Set a netowrk connection on a specified nodevoidUnregister an existing interface watch so it will receive no more events.watchInterface(NodeId nodeId, String name, NetworkInterfaceWatch.Callback callback) Register for state changes on an interface.watchInterface(String name, NetworkInterfaceWatch.Callback callback) Register for state changes on an interface on the current node.Methods inherited from class com.tccc.kos.commons.core.service.AbstractService
getHandle, getHandlePrefixMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tccc.kos.commons.core.context.CtxEventListener
onCtxAutowiringCompleted, onCtxDestroyed, onCtxPhaseCompletedMethods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPathMethods inherited from interface com.tccc.kos.commons.util.ready.ReadyAndReadyListener
onBeanReady, onDependenciesReadyMethods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
Method Details
-
getInterfaces
Return the list of available network interfaces on the current node.- Throws:
IOException
-
getInterfaceDetails
Return the details for the specified network interface on the current node.- Parameters:
name- the interface name- Throws:
IOException
-
getAllInterfaceDetails
Return the details for all available interfaces.- Throws:
IOException
-
watchInterface
public NetworkInterfaceWatch watchInterface(String name, NetworkInterfaceWatch.Callback callback) throws IOException Register for state changes on an interface on the current node. Returns watch object that will receive events and can be used to unwatch.- Parameters:
name- name of the interface to monitorcallback- callback to process network interface events- Returns:
- watch object that will receive events
- Throws:
IOException
-
getInterfaceAssociations
Return interface names be category association for the current node.- Throws:
IOException
-
enableInterface
Set the specified interface enabled or not on the current node. This does not change the configuration of the interface, it merely brings it up or down.- Parameters:
name- the interface nameenable- true to enable, false to disable- Throws:
IOException
-
isRadioEnabled
Return true if the radio is enabled on this node, false if it is not. This is a global setting and not per-interface. Querying immediately after changing the value may return an incorrect value.- Throws:
IOException
-
enableRadio
Enable / disable the radio on this node. This is a global setting and not per-interface.- Parameters:
enable- true to enable, false to disable- Throws:
IOException
-
getAccessPoints
Return the list of previously detected access points on the specified interface on this node.- Parameters:
name- the name of the interface- Throws:
IOException
-
scanAccessPoints
Perform a scan of available wifi access points visible from the specified network interface on this node. Network manager will periodically scan for access points, but this triggers a new scan. This is asynchronous and an interface watcher can be used to detect "access-point-added" events to identify new access points.- Parameters:
name- the name of the interface- Throws:
IOException
-
ping
Ping the specified hostname from this node. This will perform three pings and return the results.- Parameters:
hostname- the hostname or address to ping- Returns:
- Statistics for the ping
- Throws:
IOException
-
ping
Perform a ping from this node using the specified ping settings.- Parameters:
request- the settings for the ping operation- Returns:
- Statistics for the ping
- Throws:
IOException
-
getInterfaces
Return the list of available network interfaces.- Parameters:
nodeId- the node to operate on- Throws:
IOException
-
setConnection
Set a netowrk connection on a specified node- Parameters:
nodeId- node to set the connection on, send null for this nodenetworkConnection- information about the prospective connneciton, ie. ssid, passkey...- Throws:
IOException
-
getInterfaceDetails
Return the details for the specified network interface.- Parameters:
nodeId- the node to operate onname- the interface name- Throws:
IOException
-
getAllInterfaceDetails
Return details for all available network interfaces.- Parameters:
nodeId- the node to operate on- Throws:
IOException
-
watchInterface
public NetworkInterfaceWatch watchInterface(NodeId nodeId, String name, NetworkInterfaceWatch.Callback callback) throws IOException Register for state changes on an interface. Returns watch object that will receive events and can be used to unwatch. A watch on a remote node will survive across reboots of that node and will be re-watched when the node reconnects.- Parameters:
nodeId- the node to operate onname- name of the interface to monitorcallback- callback to process network interface events- Returns:
- watch object that will receive events
- Throws:
IOException
-
unwatchInterface
Unregister an existing interface watch so it will receive no more events.- Parameters:
watch- the watch returned when it was registered- Throws:
IOException
-
getInterfaceAssociations
Return interface names be category association.- Parameters:
nodeId- the node to operate on- Throws:
IOException
-
enableInterface
Set the specified interface enabled or not. This does not change the configuration of the interface, it merely brings it up or down.- Parameters:
nodeId- the node to operate onname- the interface nameenable- true to enable, false to disable- Throws:
IOException
-
isRadioEnabled
Return true if the radio is enabled on the specified node, false if it is not. This is a global setting and not per-interface. Querying immediately after changing the value may return an incorrect value.- Parameters:
nodeId- the node to operate on- Throws:
IOException
-
enableRadio
Enable / disable the radio on this node. This is a global setting and not per-interface.- Parameters:
nodeId- the node to operate onenable- true to enable, false to disable- Throws:
IOException
-
getAccessPoints
Return the list of previously detected access points on the specified interface on the specified node.- Parameters:
nodeId- the node to operate onname- the name of the interface- Throws:
IOException
-
scanAccessPoints
Perform a scan of available wifi access points visible from the specified network interface on the specified node. Network manager will periodically scan for access points, but this triggers a new scan. This is asynchronous and an interface watcher can be used to detect "access-point-added" events to identify new access points.- Parameters:
nodeId- the node to operate onname- the name of the interface- Throws:
IOException
-
ping
Ping the specified hostname from the specified node. This will perform three pings and return the results.- Parameters:
nodeId- the node to operate onhostname- the hostname or address to ping- Returns:
- Statistics for the ping
- Throws:
IOException
-
ping
Perform a ping from the specified node using the specified ping settings.- Parameters:
nodeId- the node to operate onrequest- the settings for the ping operation- Returns:
- Statistics for the ping
- Throws:
IOException
-
getIface
Description copied from interface:BinaryMsgIfaceFactoryGiven the name of an interface from a BinaryMsgSession, return an instance of BinaryMsgIface or null.- Specified by:
getIfacein interfaceBinaryMsgIfaceFactory- Parameters:
name- the name of the interfacesession- the session to back the interface- Returns:
- the iface or null
-