26 #include "ndn-cxx-config.hpp" 27 #include "../util/logger.hpp" 29 #include "detail/network-monitor-impl-noop.hpp" 31 #if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS) 32 #include "detail/network-monitor-impl-osx.hpp" 33 #define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplOsx 34 #elif defined(NDN_CXX_HAVE_NETLINK) 35 #include "detail/network-monitor-impl-netlink.hpp" 36 #define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplNetlink 38 #define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplNoop 46 static unique_ptr<NetworkMonitorImpl>
50 return make_unique<NETWORK_MONITOR_IMPL_TYPE>(io);
52 catch (
const std::runtime_error& e) {
55 return make_unique<NetworkMonitorImplNoop>(io);
65 : m_impl(
std::move(impl))
76 return m_impl->getCapabilities();
79 shared_ptr<const NetworkInterface>
82 return m_impl->getNetworkInterface(ifname);
85 std::vector<shared_ptr<const NetworkInterface>>
88 return m_impl->listNetworkInterfaces();
91 shared_ptr<NetworkInterface>
Copyright (c) 2013-2017 Regents of the University of California.
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 when a new interface is added.
util::Signal< NetworkMonitorImpl > & onNetworkStateChanged
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_INIT(name)
Define a non-member log module.
#define NETWORK_MONITOR_IMPL_TYPE
static unique_ptr< NetworkMonitorImpl > makeNetworkMonitorImpl(boost::asio::io_service &io)
Network interface monitor.
uint32_t getCapabilities() const
Returns a bitwise OR'ed set of Capability flags supported on the current platform.
Represents one network interface attached to the host.
util::Signal< NetworkMonitorImpl, shared_ptr< const NetworkInterface > > & onInterfaceRemoved
Fires when an interface is removed.
std::vector< shared_ptr< const NetworkInterface > > listNetworkInterfaces() const
Lists all network interfaces currently available on the system.
#define NDN_LOG_WARN(expression)
Log at WARN level.
util::Signal< NetworkMonitorImpl > & onEnumerationCompleted
Fires when network interfaces enumeration is complete.