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>
46 makeNetworkMonitorImpl(boost::asio::io_service& io)
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))
65 , onEnumerationCompleted(m_impl->onEnumerationCompleted)
66 , onInterfaceAdded(m_impl->onInterfaceAdded)
67 , onInterfaceRemoved(m_impl->onInterfaceRemoved)
68 , onNetworkStateChanged(m_impl->onNetworkStateChanged)
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>
Represents one network interface attached to the host.
static shared_ptr< NetworkInterface > makeNetworkInterface()
Network interface monitor.
NetworkMonitor(boost::asio::io_service &io)
Construct instance, request enumeration of all network interfaces, and start monitoring for network s...
uint32_t getCapabilities() const
Returns a bitwise OR'ed set of Capability flags supported on the current platform.
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.
#define NDN_LOG_INIT(name)
Define a non-member log module.
#define NETWORK_MONITOR_IMPL_TYPE