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
44 static unique_ptr<NetworkMonitorImpl>
45 makeNetworkMonitorImpl(boost::asio::io_context& io)
48 return make_unique<NETWORK_MONITOR_IMPL_TYPE>(io);
50 catch (
const std::runtime_error& e) {
53 return make_unique<NetworkMonitorImplNoop>(io);
63 : m_impl(std::move(impl))
64 , onEnumerationCompleted(m_impl->onEnumerationCompleted)
65 , onInterfaceAdded(m_impl->onInterfaceAdded)
66 , onInterfaceRemoved(m_impl->onInterfaceRemoved)
67 , onNetworkStateChanged(m_impl->onNetworkStateChanged)
74 return m_impl->getCapabilities();
77 shared_ptr<const NetworkInterface>
80 return m_impl->getNetworkInterface(ifname);
83 std::vector<shared_ptr<const NetworkInterface>>
86 return m_impl->listNetworkInterfaces();
89 shared_ptr<NetworkInterface>
Represents one network interface attached to the host.
static shared_ptr< NetworkInterface > makeNetworkInterface()
Network interface monitor.
NetworkMonitor(boost::asio::io_context &ioCtx)
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