blob: 6689711387dd1350ff4984d677ae49f37e38dc3d [file] [log] [blame]
Alexander Afanasyeve6c65e22015-01-28 19:56:03 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Davide Pesavento2bf35a62017-04-02 00:41:06 -04003 * Copyright (c) 2013-2017 Regents of the University of California.
Alexander Afanasyeve6c65e22015-01-28 19:56:03 -08004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Davide Pesavento2bf35a62017-04-02 00:41:06 -040020 *
21 * @author Alexander Afanasyev <alexander.afanasyev@ucla.edu>
22 * @author Davide Pesavento <davide.pesavento@lip6.fr>
Alexander Afanasyeve6c65e22015-01-28 19:56:03 -080023 */
24
Davide Pesavento9a8bae52016-02-24 20:33:08 +010025#include "network-monitor.hpp"
Alexander Afanasyeve6c65e22015-01-28 19:56:03 -080026#include "ndn-cxx-config.hpp"
27
Alexander Afanasyeve6c65e22015-01-28 19:56:03 -080028#if defined(NDN_CXX_HAVE_COREFOUNDATION_COREFOUNDATION_H)
Davide Pesavento9a8bae52016-02-24 20:33:08 +010029#include "detail/network-monitor-impl-osx.hpp"
Alexander Afanasyev7b3080f2015-01-28 21:21:01 -080030#elif defined(NDN_CXX_HAVE_RTNETLINK)
Davide Pesavento9a8bae52016-02-24 20:33:08 +010031#include "detail/network-monitor-impl-rtnl.hpp"
32#else
Alexander Afanasyeve6c65e22015-01-28 19:56:03 -080033
34namespace ndn {
35namespace util {
36
Alexander Afanasyev7b3080f2015-01-28 21:21:01 -080037class NetworkMonitor::Impl
Alexander Afanasyeve6c65e22015-01-28 19:56:03 -080038{
Alexander Afanasyev7b3080f2015-01-28 21:21:01 -080039public:
Davide Pesaventoa468ff52017-05-20 00:06:50 -040040 Impl(NetworkMonitor&, boost::asio::io_service&)
Alexander Afanasyev7b3080f2015-01-28 21:21:01 -080041 {
Davide Pesavento9a8bae52016-02-24 20:33:08 +010042 BOOST_THROW_EXCEPTION(Error("Network monitoring is not supported on this platform"));
Alexander Afanasyev7b3080f2015-01-28 21:21:01 -080043 }
Davide Pesaventoa468ff52017-05-20 00:06:50 -040044
45 shared_ptr<NetworkInterface>
46 getNetworkInterface(const std::string&) const
47 {
48 return {};
49 }
50
51 std::vector<shared_ptr<NetworkInterface>>
52 listNetworkInterfaces() const
53 {
54 return {};
55 }
Alexander Afanasyev7b3080f2015-01-28 21:21:01 -080056};
57
Davide Pesavento9a8bae52016-02-24 20:33:08 +010058} // namespace util
59} // namespace ndn
Alexander Afanasyev7b3080f2015-01-28 21:21:01 -080060
Davide Pesavento9a8bae52016-02-24 20:33:08 +010061#endif
62
63namespace ndn {
64namespace util {
Alexander Afanasyev7b3080f2015-01-28 21:21:01 -080065
66NetworkMonitor::NetworkMonitor(boost::asio::io_service& io)
Davide Pesavento2bf35a62017-04-02 00:41:06 -040067 : m_impl(make_unique<Impl>(*this, io))
Alexander Afanasyev7b3080f2015-01-28 21:21:01 -080068{
Alexander Afanasyeve6c65e22015-01-28 19:56:03 -080069}
70
Davide Pesavento9a8bae52016-02-24 20:33:08 +010071NetworkMonitor::~NetworkMonitor() = default;
Alexander Afanasyeve6c65e22015-01-28 19:56:03 -080072
Davide Pesavento2bf35a62017-04-02 00:41:06 -040073shared_ptr<NetworkInterface>
74NetworkMonitor::getNetworkInterface(const std::string& ifname) const
75{
76 return m_impl->getNetworkInterface(ifname);
77}
78
79std::vector<shared_ptr<NetworkInterface>>
80NetworkMonitor::listNetworkInterfaces() const
81{
82 return m_impl->listNetworkInterfaces();
83}
84
Alexander Afanasyeve6c65e22015-01-28 19:56:03 -080085} // namespace util
86} // namespace ndn