25 NS_LOG_COMPONENT_DEFINE(
"ndn-cxx.Face");
36 #include "ns3/ndnSIM/helper/ndn-stack-helper.hpp" 41 : m_impl(new Impl(*this))
47 : m_impl(new Impl(*this))
55 static ::ndn::KeyChain keyChain(
"pib-dummy",
"tpm-dummy");
62 const PendingInterestId*
65 NS_LOG_INFO (
">> Interest: " << interest.
getName());
67 shared_ptr<Interest> interestToExpress = make_shared<Interest>(interest);
68 m_impl->m_scheduler.scheduleEvent(time::seconds(0), [=] {
69 m_impl->asyncExpressInterest(interestToExpress, onData, onTimeout);
72 return reinterpret_cast<const PendingInterestId*
>(interestToExpress.get());
75 const PendingInterestId*
89 NS_LOG_INFO (
">> Data: " << data.
getName());
91 shared_ptr<const Data> dataPtr;
93 dataPtr = data.shared_from_this();
95 catch (
const bad_weak_ptr& e) {
96 NS_LOG_INFO(
"Face::put WARNING: the supplied Data should be created using make_shared<Data>()");
97 dataPtr = make_shared<Data>(data);
100 m_impl->m_scheduler.scheduleEvent(time::seconds(0), [=] {
101 m_impl->asyncPutData(dataPtr);
108 m_impl->m_scheduler.scheduleEvent(time::seconds(0),
110 m_impl->asyncRemovePendingInterest(pendingInterestId);
117 return m_impl->m_pendingInterestTable.size();
120 const RegisteredPrefixId*
135 const RegisteredPrefixId*
143 shared_ptr<InterestFilterRecord> filter =
144 make_shared<InterestFilterRecord>(interestFilter, onInterest);
149 return m_impl->registerPrefix(interestFilter.getPrefix(), filter,
150 onSuccess, onFailure,
154 const InterestFilterId*
158 NS_LOG_INFO(
"Set Interest Filter << " << interestFilter);
160 shared_ptr<InterestFilterRecord> filter =
161 make_shared<InterestFilterRecord>(interestFilter, onInterest);
163 m_impl->m_scheduler.scheduleEvent(time::seconds(0),
164 [=] { m_impl->asyncSetInterestFilter(filter); });
166 return reinterpret_cast<const InterestFilterId*
>(filter.get());
169 #ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING 171 const RegisteredPrefixId*
184 onSuccess, onFailure,
188 const RegisteredPrefixId*
200 onFailure, signingInfo, flags);
203 const RegisteredPrefixId*
208 const Name& identity,
214 onSuccess, onFailure,
218 const RegisteredPrefixId*
222 const Name& identity,
228 onFailure, signingInfo, flags);
231 #endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING 233 const RegisteredPrefixId*
244 return m_impl->registerPrefix(prefix, shared_ptr<InterestFilterRecord>(),
245 onSuccess, onFailure,
249 #ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING 251 const RegisteredPrefixId*
263 onFailure, signingInfo, flags);
266 const RegisteredPrefixId*
270 const Name& identity,
275 onFailure, signingInfo, flags);
277 #endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING 282 m_impl->m_scheduler.scheduleEvent(time::seconds(0), [=] {
283 m_impl->asyncUnregisterPrefix(registeredPrefixId,
291 m_impl->m_scheduler.scheduleEvent(time::seconds(0), [=] {
292 m_impl->asyncUnsetInterestFilter(interestFilterId);
301 m_impl->m_scheduler.scheduleEvent(time::seconds(0), [=] {
302 m_impl->asyncUnregisterPrefix(registeredPrefixId,onSuccess, onFailure);
315 m_impl->m_scheduler.scheduleEvent(time::seconds(0), [=] {
316 m_impl->m_pendingInterestTable.clear();
317 m_impl->m_registeredPrefixTable.clear();
319 m_impl->m_nfdFace->close();
const Name & getName() const
Copyright (c) 2011-2015 Regents of the University of California.
function< void(const std::string &)> UnregisterPrefixFailureCallback
Callback called when unregisterPrefix or unsetInterestFilter command fails.
represents an Interest packet
function< void(const Interest &)> OnTimeout
Callback called when expressed Interest times out.
function< void(const InterestFilter &, const Interest &)> OnInterest
Callback called when incoming Interest matches the specified InterestFilter.
Signing parameters passed to KeyChain.
SigningInfo signingByCertificate(const Name &certName)
void unregisterPrefix(const RegisteredPrefixId *registeredPrefixId, const UnregisterPrefixSuccessCallback &onSuccess, const UnregisterPrefixFailureCallback &onFailure)
Unregister prefix from RIB.
const Name & getName() const
Get name of the Data packet.
Face()
Create a new Face using the default transport (UnixTransport)
contains options for ControlCommand execution
const RegisteredPrefixId * setInterestFilter(const InterestFilter &interestFilter, const OnInterest &onInterest, const RegisterPrefixFailureCallback &onFailure, const security::SigningInfo &signingInfo=security::SigningInfo(), uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT)
Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the fil...
void shutdown()
Shutdown face operations.
SigningInfo signingByIdentity(const Name &identity)
NFD Management protocol - ControlCommand client.
function< void(const Name &, const std::string &)> RegisterPrefixFailureCallback
Callback called when registerPrefix or setInterestFilter command fails.
function< void(const Name &)> RegisterPrefixSuccessCallback
Callback called when registerPrefix or setInterestFilter command succeeds.
Name abstraction to represent an absolute name.
const PendingInterestId * expressInterest(const Interest &interest, const OnData &onData, const OnTimeout &onTimeout=OnTimeout())
Express Interest.
void unsetInterestFilter(const RegisteredPrefixId *registeredPrefixId)
Remove the registered prefix entry with the registeredPrefixId.
CommandOptions & setSigningInfo(const security::SigningInfo &signingInfo)
sets signing parameters
function< void(const Interest &, Data &)> OnData
Callback called when expressed Interest gets satisfied with Data packet.
size_t getNPendingInterests() const
Get number of pending Interests.
bool empty() const
Check if name is emtpy.
function< void()> UnregisterPrefixSuccessCallback
Callback called when unregisterPrefix or unsetInterestFilter command succeeds.
static KeyChain & getKeyChain()
void processEvents(const time::milliseconds &timeout=time::milliseconds::zero(), bool keepThread=false)
Noop (kept for compatibility)
const RegisteredPrefixId * registerPrefix(const Name &prefix, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, const security::SigningInfo &signingInfo=security::SigningInfo(), uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT)
Register prefix with the connected NDN forwarder.
void removePendingInterest(const PendingInterestId *pendingInterestId)
Cancel previously expressed Interest.
void put(const Data &data)
Publish data packet.