A dummy NetworkMonitor for unit testing. More...
#include <ndn-cxx/net/network-monitor-stub.hpp>
Public Types | |
enum | Capability : uint32_t { CAP_NONE = 0 , CAP_ENUM = 1 << 0 , CAP_IF_ADD_REMOVE = 1 << 1 , CAP_STATE_CHANGE = 1 << 2 , CAP_MTU_CHANGE = 1 << 3 , CAP_ADDR_ADD_REMOVE = 1 << 4 } |
Public Member Functions | |
NetworkMonitorStub (uint32_t capabilities) | |
Constructor. More... | |
void | addInterface (shared_ptr< NetworkInterface > netif) |
Emit the onInterfaceAdded signal and add netif internally. More... | |
void | emitEnumerationCompleted () |
Emit the onEnumerationCompleted signal. More... | |
uint32_t | getCapabilities () const |
Returns a bitwise OR'ed set of Capability flags supported on the current platform. More... | |
shared_ptr< const NetworkInterface > | getNetworkInterface (const std::string &ifname) const |
Returns the NetworkInterface with the given name, or nullptr if it does not exist. More... | |
std::vector< shared_ptr< const NetworkInterface > > | listNetworkInterfaces () const |
Lists all network interfaces currently available on the system. More... | |
void | removeInterface (const std::string &ifname) |
Emit the onInterfaceRemoved signal and remove netif internally. More... | |
Static Public Member Functions | |
static shared_ptr< NetworkInterface > | makeNetworkInterface () |
Create a NetworkInterface instance. More... | |
Public Attributes | |
signal::Signal< NetworkMonitorImpl > & | onEnumerationCompleted |
Fires when the enumeration of all network interfaces on the system is complete. More... | |
signal::Signal< NetworkMonitorImpl, shared_ptr< const NetworkInterface > > & | onInterfaceAdded |
Fires whenever a new interface is detected on the system. More... | |
signal::Signal< NetworkMonitorImpl, shared_ptr< const NetworkInterface > > & | onInterfaceRemoved |
Fires whenever an interface disappears from the system. More... | |
signal::Signal< NetworkMonitorImpl > & | onNetworkStateChanged |
A dummy NetworkMonitor for unit testing.
Definition at line 34 of file network-monitor-stub.hpp.
|
inherited |
Enumerator | |
---|---|
CAP_NONE | NetworkMonitor is not supported and is a no-op. |
CAP_ENUM | listNetworkInterfaces() and getNetworkInterface() are supported |
CAP_IF_ADD_REMOVE | NetworkMonitor onInterfaceAdded and onInterfaceRemoved signals are supported. |
CAP_STATE_CHANGE | NetworkInterface onStateChanged signal is supported. |
CAP_MTU_CHANGE | NetworkInterface onMtuChanged signal is supported. |
CAP_ADDR_ADD_REMOVE | NetworkInterface onAddressAdded and onAddressRemoved signals are supported. |
Definition at line 68 of file network-monitor.hpp.
|
explicit |
Constructor.
capabilities | The capabilities reported by getCapabilities() |
Definition at line 101 of file network-monitor-stub.cpp.
void ndn::net::NetworkMonitorStub::addInterface | ( | shared_ptr< NetworkInterface > | netif | ) |
Emit the onInterfaceAdded signal and add netif
internally.
netif | new network interface |
std::invalid_argument | a network interface with the same name already exists |
Definition at line 119 of file network-monitor-stub.cpp.
void ndn::net::NetworkMonitorStub::emitEnumerationCompleted | ( | ) |
Emit the onEnumerationCompleted signal.
A real NetworkMonitor starts with an "enumerating" state, during which the initial information about network interfaces is collected from the OS. Upon discovering a network interface, it emits the onInterfaceAdded signal. When the initial enumerating completes, it emits the onEnumerationCompleted signal.
To simulate this procedure on a newly constructed MockNetworkMonitor, the caller should invoke addInterface() once for each network interface that already exists, and then invoke emitEnumerationCompleted().
Definition at line 131 of file network-monitor-stub.cpp.
|
inherited |
Returns a bitwise OR'ed set of Capability flags supported on the current platform.
Definition at line 72 of file network-monitor.cpp.
|
inherited |
Returns the NetworkInterface with the given name, or nullptr
if it does not exist.
Definition at line 78 of file network-monitor.cpp.
|
inherited |
Lists all network interfaces currently available on the system.
Definition at line 84 of file network-monitor.cpp.
|
static |
Create a NetworkInterface instance.
Definition at line 113 of file network-monitor-stub.cpp.
void ndn::net::NetworkMonitorStub::removeInterface | ( | const std::string & | ifname | ) |
Emit the onInterfaceRemoved signal and remove netif
internally.
ifname | network interface name |
Definition at line 125 of file network-monitor-stub.cpp.
|
inherited |
Fires when the enumeration of all network interfaces on the system is complete.
Definition at line 116 of file network-monitor.hpp.
|
inherited |
Fires whenever a new interface is detected on the system.
Definition at line 119 of file network-monitor.hpp.
|
inherited |
Fires whenever an interface disappears from the system.
Definition at line 126 of file network-monitor.hpp.
|
inherited |
Definition at line 129 of file network-monitor.hpp.