28 #include "ndn-cxx/detail/config.hpp" 29 #include "ndn-cxx/net/impl/network-monitor-impl-noop.hpp" 30 #if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS) 31 #include "ndn-cxx/net/impl/network-monitor-impl-osx.hpp" 32 #define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplOsx 33 #elif defined(NDN_CXX_HAVE_NETLINK) 34 #include "ndn-cxx/net/impl/network-monitor-impl-netlink.hpp" 35 #define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplNetlink 37 #define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplNoop 45 static unique_ptr<NetworkMonitorImpl>
49 return make_unique<NETWORK_MONITOR_IMPL_TYPE>(io);
51 catch (
const std::runtime_error& e) {
54 return make_unique<NetworkMonitorImplNoop>(io);
64 : m_impl(
std::move(impl))
75 return m_impl->getCapabilities();
78 shared_ptr<const NetworkInterface>
81 return m_impl->getNetworkInterface(ifname);
84 std::vector<shared_ptr<const NetworkInterface>>
87 return m_impl->listNetworkInterfaces();
90 shared_ptr<NetworkInterface>
NetworkMonitor(boost::asio::io_service &io)
Construct instance, request enumeration of all network interfaces, and start monitoring for network s...
static shared_ptr< NetworkInterface > makeNetworkInterface()
util::Signal< NetworkMonitorImpl, shared_ptr< const NetworkInterface > > & onInterfaceAdded
Fires whenever a new interface is detected on the system.
util::Signal< NetworkMonitorImpl > & onNetworkStateChanged
#define NDN_LOG_INIT(name)
Define a non-member log module.
uint32_t getCapabilities() const
Returns a bitwise OR'ed set of Capability flags supported on the current platform.
#define NETWORK_MONITOR_IMPL_TYPE
static unique_ptr< NetworkMonitorImpl > makeNetworkMonitorImpl(boost::asio::io_service &io)
Network interface monitor.
Represents one network interface attached to the host.
util::Signal< NetworkMonitorImpl, shared_ptr< const NetworkInterface > > & onInterfaceRemoved
Fires whenever an interface disappears from the system.
std::vector< shared_ptr< const NetworkInterface > > listNetworkInterfaces() const
Lists all network interfaces currently available on the system.
shared_ptr< const NetworkInterface > getNetworkInterface(const std::string &ifname) const
Returns the NetworkInterface with the given name, or nullptr if it does not exist.
#define NDN_LOG_WARN(expression)
Log at WARN level.
util::Signal< NetworkMonitorImpl > & onEnumerationCompleted
Fires when the enumeration of all network interfaces on the system is complete.