blob: bd0a3c6a260bbe18897fb93bdc08cf8b10c0b985 [file] [log] [blame]
Davide Pesavento9a8bae52016-02-24 20:33:08 +01001/* -*- 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.
Davide Pesavento9a8bae52016-02-24 20:33:08 +01004 *
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.
20 */
21
22#ifndef NDN_UTIL_NETWORK_MONITOR_IMPL_OSX_HPP
23#define NDN_UTIL_NETWORK_MONITOR_IMPL_OSX_HPP
24
Davide Pesavento2bf35a62017-04-02 00:41:06 -040025#include "ndn-cxx-config.hpp"
Davide Pesavento9a8bae52016-02-24 20:33:08 +010026#include "../network-monitor.hpp"
27
Alexander Afanasyev0cf887d2017-03-26 16:58:59 -050028#ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
Davide Pesavento2bf35a62017-04-02 00:41:06 -040029#error "This file should not be compiled ..."
30#endif
31
Davide Pesavento9a8bae52016-02-24 20:33:08 +010032#include "../scheduler.hpp"
33#include "../scheduler-scoped-event-id.hpp"
34
35#include <CoreFoundation/CoreFoundation.h>
36#include <SystemConfiguration/SystemConfiguration.h>
37
38namespace ndn {
39namespace util {
40
41class NetworkMonitor::Impl
42{
43public:
44 Impl(NetworkMonitor& nm, boost::asio::io_service& io);
45
46 ~Impl();
47
Junxiao Shif4c1eb32017-05-30 17:05:10 +000048 uint32_t
49 getCapabilities() const
50 {
51 return NetworkMonitor::CAP_NONE;
52 /// \todo #3817 change to CAP_ENUM | CAP_IF_ADD_REMOVE | CAP_STATE_CHANGE | CAP_ADDR_ADD_REMOVE
53 }
54
Davide Pesavento2bf35a62017-04-02 00:41:06 -040055 shared_ptr<NetworkInterface>
56 getNetworkInterface(const std::string& ifname) const;
57
58 std::vector<shared_ptr<NetworkInterface>>
59 listNetworkInterfaces() const;
60
Davide Pesavento9a8bae52016-02-24 20:33:08 +010061 static void
62 afterNotificationCenterEvent(CFNotificationCenterRef center,
Davide Pesavento2bf35a62017-04-02 00:41:06 -040063 void* observer,
Davide Pesavento9a8bae52016-02-24 20:33:08 +010064 CFStringRef name,
Davide Pesavento2bf35a62017-04-02 00:41:06 -040065 const void* object,
Davide Pesavento9a8bae52016-02-24 20:33:08 +010066 CFDictionaryRef userInfo);
67
68private:
69 void
70 scheduleCfLoop();
71
72 void
73 pollCfLoop();
74
75private:
76 NetworkMonitor& m_nm;
77
78 Scheduler m_scheduler;
79 scheduler::ScopedEventId m_cfLoopEvent;
80};
81
82} // namespace util
83} // namespace ndn
84
85#endif // NDN_UTIL_NETWORK_MONITOR_IMPL_OSX_HPP