NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
network-monitor-impl-osx.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
53
#include "ndn-cxx-config.hpp"
54
55
#ifdef NDN_CXX_HAVE_COREFOUNDATION_COREFOUNDATION_H
56
57
#include "
network-monitor-impl-osx.hpp
"
58
59
namespace
ndn
{
60
namespace
util {
61
62
NetworkMonitor::Impl::Impl
(NetworkMonitor& nm, boost::asio::io_service& io)
63
: m_nm(nm)
64
, m_scheduler(io)
65
, m_cfLoopEvent(m_scheduler)
66
{
67
scheduleCfLoop();
68
69
// Potentially useful System Configuration regex patterns:
70
//
71
// State:/Network/Interface/.*/Link
72
// State:/Network/Interface/.*/IPv4
73
// State:/Network/Interface/.*/IPv6
74
//
75
// State:/Network/Global/DNS
76
// State:/Network/Global/IPv4
77
//
78
// Potentially useful notifications from Darwin Notify Center:
79
//
80
// com.apple.system.config.network_change
81
//
82
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
83
static_cast<void*>(
this
),
84
&Impl::afterNotificationCenterEvent,
85
CFSTR(
"com.apple.system.config.network_change"
),
86
nullptr
,
// object to observe
87
CFNotificationSuspensionBehaviorDeliverImmediately);
88
}
89
90
NetworkMonitor::Impl::~Impl()
91
{
92
CFNotificationCenterRemoveEveryObserver(CFNotificationCenterGetDarwinNotifyCenter(),
93
static_cast<void*>(
this
));
94
}
95
96
void
97
NetworkMonitor::Impl::afterNotificationCenterEvent(CFNotificationCenterRef center,
98
void
*observer,
99
CFStringRef
name
,
100
const
void
*
object
,
101
CFDictionaryRef userInfo)
102
{
103
static_cast<
Impl*
>
(observer)->m_nm.onNetworkStateChanged();
104
}
105
106
void
107
NetworkMonitor::Impl::scheduleCfLoop()
108
{
109
// poll each second for new events
110
m_cfLoopEvent = m_scheduler.scheduleEvent(time::seconds(1), bind(&Impl::pollCfLoop,
this
));
111
}
112
113
void
114
NetworkMonitor::Impl::pollCfLoop()
115
{
116
// this should dispatch ready events and exit
117
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0,
true
);
118
119
scheduleCfLoop();
120
}
121
122
}
// namespace util
123
}
// namespace ndn
124
125
#endif // NDN_CXX_HAVE_COREFOUNDATION_COREFOUNDATION_H
ndn::util::NetworkMonitor::Impl::Impl
Impl(NetworkMonitor &nm, boost::asio::io_service &io)
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
network-monitor-impl-osx.hpp
ndn::name
Definition:
name-component.cpp:36
ndnSIM
ndn-cxx
src
util
detail
network-monitor-impl-osx.cpp
Generated on Wed Jan 11 2017 18:17:14 for ndnSIM by
1.8.13