28 #include "ndn-cxx/detail/config.hpp" 30 #if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS) 32 #define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplOsx 33 #elif defined(NDN_CXX_HAVE_NETLINK) 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))
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>
Copyright (c) 2011-2015 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()
#define NDN_LOG_WARN(expression)
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.
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_INIT(name)
declare a log module