face.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #include "face.hpp"
23 #include "detail/face-impl.hpp"
24 
25 #include "encoding/tlv.hpp"
27 #include "util/time.hpp"
28 #include "util/random.hpp"
29 #include "util/face-uri.hpp"
30 
31 // A callback scheduled through io.post and io.dispatch may be invoked after the face
32 // is destructed. To prevent this situation, these macros captures Face::m_impl as weak_ptr,
33 // and skips callback execution if the face has been destructed.
34 #define IO_CAPTURE_WEAK_IMPL(OP) \
35  { \
36  weak_ptr<Impl> implWeak(m_impl); \
37  m_ioService.OP([=] { \
38  auto impl = implWeak.lock(); \
39  if (impl != nullptr) {
40 #define IO_CAPTURE_WEAK_IMPL_END \
41  } \
42  }); \
43  }
44 
45 namespace ndn {
46 
47 Face::Face(shared_ptr<Transport> transport)
48  : m_internalIoService(new boost::asio::io_service())
49  , m_ioService(*m_internalIoService)
50  , m_internalKeyChain(new KeyChain())
51  , m_impl(make_shared<Impl>(*this))
52 {
53  construct(transport, *m_internalKeyChain);
54 }
55 
56 Face::Face(boost::asio::io_service& ioService)
57  : m_ioService(ioService)
58  , m_internalKeyChain(new KeyChain())
59  , m_impl(make_shared<Impl>(*this))
60 {
61  construct(nullptr, *m_internalKeyChain);
62 }
63 
64 Face::Face(const std::string& host, const std::string& port)
65  : m_internalIoService(new boost::asio::io_service())
66  , m_ioService(*m_internalIoService)
67  , m_internalKeyChain(new KeyChain())
68  , m_impl(make_shared<Impl>(*this))
69 {
70  construct(make_shared<TcpTransport>(host, port), *m_internalKeyChain);
71 }
72 
73 Face::Face(shared_ptr<Transport> transport, KeyChain& keyChain)
74  : m_internalIoService(new boost::asio::io_service())
75  , m_ioService(*m_internalIoService)
76  , m_impl(make_shared<Impl>(*this))
77 {
78  construct(transport, keyChain);
79 }
80 
81 Face::Face(shared_ptr<Transport> transport, boost::asio::io_service& ioService)
82  : m_ioService(ioService)
83  , m_internalKeyChain(new KeyChain())
84  , m_impl(make_shared<Impl>(*this))
85 {
86  construct(transport, *m_internalKeyChain);
87 }
88 
89 Face::Face(shared_ptr<Transport> transport, boost::asio::io_service& ioService, KeyChain& keyChain)
90  : m_ioService(ioService)
91  , m_impl(make_shared<Impl>(*this))
92 {
93  construct(transport, keyChain);
94 }
95 
96 shared_ptr<Transport>
97 Face::makeDefaultTransport()
98 {
99  // transport=unix:///var/run/nfd.sock
100  // transport=tcp://localhost:6363
101 
102  std::string transportUri;
103 
104  const char* transportEnviron = getenv("NDN_CLIENT_TRANSPORT");
105  if (transportEnviron != nullptr) {
106  transportUri = transportEnviron;
107  }
108  else {
109  ConfigFile config;
110  transportUri = config.getParsedConfiguration().get<std::string>("transport", "");
111  }
112 
113  if (transportUri.empty()) {
114  // transport not specified, use default Unix transport.
115  return UnixTransport::create("");
116  }
117 
118  std::string protocol;
119  try {
120  util::FaceUri uri(transportUri);
121  protocol = uri.getScheme();
122 
123  if (protocol == "unix") {
124  return UnixTransport::create(transportUri);
125  }
126  else if (protocol == "tcp" || protocol == "tcp4" || protocol == "tcp6") {
127  return TcpTransport::create(transportUri);
128  }
129  else {
130  BOOST_THROW_EXCEPTION(ConfigFile::Error("Unsupported transport protocol \"" + protocol + "\""));
131  }
132  }
133  catch (const Transport::Error& error) {
134  BOOST_THROW_EXCEPTION(ConfigFile::Error(error.what()));
135  }
136  catch (const util::FaceUri::Error& error) {
137  BOOST_THROW_EXCEPTION(ConfigFile::Error(error.what()));
138  }
139 }
140 
141 void
142 Face::construct(shared_ptr<Transport> transport, KeyChain& keyChain)
143 {
144  if (transport == nullptr) {
145  transport = makeDefaultTransport();
146  }
147  BOOST_ASSERT(transport != nullptr);
148  m_transport = transport;
149 
150  m_nfdController.reset(new nfd::Controller(*this, keyChain));
151 
152  IO_CAPTURE_WEAK_IMPL(post) {
153  impl->ensureConnected(false);
155 }
156 
157 Face::~Face() = default;
158 
159 shared_ptr<Transport>
161 {
162  return m_transport;
163 }
164 
165 const PendingInterestId*
167  const DataCallback& afterSatisfied,
168  const NackCallback& afterNacked,
169  const TimeoutCallback& afterTimeout)
170 {
171  shared_ptr<Interest> interestToExpress = make_shared<Interest>(interest);
172 
173  // Use `interestToExpress` to avoid wire format creation for the original Interest
174  if (interestToExpress->wireEncode().size() > MAX_NDN_PACKET_SIZE) {
175  BOOST_THROW_EXCEPTION(Error("Interest size exceeds maximum limit"));
176  }
177 
178  // If the same ioService thread, dispatch directly calls the method
179  IO_CAPTURE_WEAK_IMPL(dispatch) {
180  impl->asyncExpressInterest(interestToExpress, afterSatisfied, afterNacked, afterTimeout);
182 
183  return reinterpret_cast<const PendingInterestId*>(interestToExpress.get());
184 }
185 
186 const PendingInterestId*
188  const OnData& onData,
189  const OnTimeout& onTimeout)
190 {
191  return this->expressInterest(
192  interest,
193  [onData] (const Interest& interest, const Data& data) {
194  if (onData != nullptr) {
195  onData(interest, const_cast<Data&>(data));
196  }
197  },
198  [onTimeout] (const Interest& interest, const lp::Nack& nack) {
199  if (onTimeout != nullptr) {
200  onTimeout(interest);
201  }
202  },
203  onTimeout
204  );
205 }
206 
207 const PendingInterestId*
208 Face::expressInterest(const Name& name, const Interest& tmpl,
209  const OnData& onData, const OnTimeout& onTimeout)
210 {
211  return expressInterest(Interest(tmpl).setName(name).setNonce(0),
212  onData, onTimeout);
213 }
214 
215 void
216 Face::removePendingInterest(const PendingInterestId* pendingInterestId)
217 {
218  IO_CAPTURE_WEAK_IMPL(post) {
219  impl->asyncRemovePendingInterest(pendingInterestId);
221 }
222 
223 void
225 {
226  IO_CAPTURE_WEAK_IMPL(post) {
227  impl->asyncRemoveAllPendingInterests();
229 }
230 
231 size_t
233 {
234  return m_impl->m_pendingInterestTable.size();
235 }
236 
237 void
238 Face::put(const Data& data)
239 {
240  Block wire = data.wireEncode();
241 
242  lp::Packet packet;
243  bool hasLpFields = false;
244 
245  shared_ptr<lp::CachePolicyTag> cachePolicyTag = data.getTag<lp::CachePolicyTag>();
246  if (cachePolicyTag != nullptr) {
247  packet.add<lp::CachePolicyField>(*cachePolicyTag);
248  hasLpFields = true;
249  }
250 
251  shared_ptr<lp::CongestionMarkTag> congestionMarkTag = data.getTag<lp::CongestionMarkTag>();
252  if (congestionMarkTag != nullptr) {
253  packet.add<lp::CongestionMarkField>(*congestionMarkTag);
254  hasLpFields = true;
255  }
256 
257  if (hasLpFields) {
258  packet.add<lp::FragmentField>(std::make_pair(wire.begin(), wire.end()));
259  wire = packet.wireEncode();
260  }
261 
262  if (wire.size() > MAX_NDN_PACKET_SIZE)
263  BOOST_THROW_EXCEPTION(Error("Data size exceeds maximum limit"));
264 
265  IO_CAPTURE_WEAK_IMPL(dispatch) {
266  impl->asyncSend(wire);
268 }
269 
270 void
271 Face::put(const lp::Nack& nack)
272 {
273  lp::Packet packet;
274  packet.add<lp::NackField>(nack.getHeader());
275  const Block& interestWire = nack.getInterest().wireEncode();
276  packet.add<lp::FragmentField>(std::make_pair(interestWire.begin(), interestWire.end()));
277 
278  shared_ptr<lp::CongestionMarkTag> congestionMarkTag = nack.getTag<lp::CongestionMarkTag>();
279  if (congestionMarkTag != nullptr) {
280  packet.add<lp::CongestionMarkField>(*congestionMarkTag);
281  }
282 
283  Block wire = packet.wireEncode();
284 
285  if (wire.size() > MAX_NDN_PACKET_SIZE)
286  BOOST_THROW_EXCEPTION(Error("Nack size exceeds maximum limit"));
287 
288  IO_CAPTURE_WEAK_IMPL(dispatch) {
289  impl->asyncSend(wire);
291 }
292 
293 const RegisteredPrefixId*
295  const InterestCallback& onInterest,
296  const RegisterPrefixFailureCallback& onFailure,
297  const security::SigningInfo& signingInfo,
298  uint64_t flags)
299 {
300  return setInterestFilter(interestFilter, onInterest, nullptr, onFailure, signingInfo, flags);
301 }
302 
303 const RegisteredPrefixId*
305  const InterestCallback& onInterest,
306  const RegisterPrefixSuccessCallback& onSuccess,
307  const RegisterPrefixFailureCallback& onFailure,
308  const security::SigningInfo& signingInfo,
309  uint64_t flags)
310 {
311  auto filter = make_shared<InterestFilterRecord>(interestFilter, onInterest);
312 
313  nfd::CommandOptions options;
314  options.setSigningInfo(signingInfo);
315 
316  return m_impl->registerPrefix(interestFilter.getPrefix(), filter,
317  onSuccess, onFailure, flags, options);
318 }
319 
320 const InterestFilterId*
322  const InterestCallback& onInterest)
323 {
324  auto filter = make_shared<InterestFilterRecord>(interestFilter, onInterest);
325 
326  IO_CAPTURE_WEAK_IMPL(post) {
327  impl->asyncSetInterestFilter(filter);
329 
330  return reinterpret_cast<const InterestFilterId*>(filter.get());
331 }
332 
333 #ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
334 
335 const RegisteredPrefixId*
337  const OnInterest& onInterest,
338  const RegisterPrefixSuccessCallback& onSuccess,
339  const RegisterPrefixFailureCallback& onFailure,
340  const security::v1::IdentityCertificate& certificate,
341  uint64_t flags)
342 {
343  security::SigningInfo signingInfo;
344  if (!certificate.getName().empty()) {
345  signingInfo = signingByCertificate(certificate.getName());
346  }
347  return setInterestFilter(interestFilter, onInterest, onSuccess, onFailure, signingInfo, flags);
348 }
349 
350 const RegisteredPrefixId*
352  const OnInterest& onInterest,
353  const RegisterPrefixFailureCallback& onFailure,
354  const security::v1::IdentityCertificate& certificate,
355  uint64_t flags)
356 {
357  security::SigningInfo signingInfo;
358  if (!certificate.getName().empty()) {
359  signingInfo = signingByCertificate(certificate.getName());
360  }
361  return setInterestFilter(interestFilter, onInterest, onFailure, signingInfo, flags);
362 }
363 
364 const RegisteredPrefixId*
366  const OnInterest& onInterest,
367  const RegisterPrefixSuccessCallback& onSuccess,
368  const RegisterPrefixFailureCallback& onFailure,
369  const Name& identity,
370  uint64_t flags)
371 {
372  security::SigningInfo signingInfo = signingByIdentity(identity);
373  return setInterestFilter(interestFilter, onInterest,
374  onSuccess, onFailure,
375  signingInfo, flags);
376 }
377 
378 const RegisteredPrefixId*
380  const OnInterest& onInterest,
381  const RegisterPrefixFailureCallback& onFailure,
382  const Name& identity,
383  uint64_t flags)
384 {
385  security::SigningInfo signingInfo = signingByIdentity(identity);
386  return setInterestFilter(interestFilter, onInterest, onFailure, signingInfo, flags);
387 }
388 
389 #endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
390 
391 const RegisteredPrefixId*
393  const RegisterPrefixSuccessCallback& onSuccess,
394  const RegisterPrefixFailureCallback& onFailure,
395  const security::SigningInfo& signingInfo,
396  uint64_t flags)
397 {
398  nfd::CommandOptions options;
399  options.setSigningInfo(signingInfo);
400 
401  return m_impl->registerPrefix(prefix, nullptr, onSuccess, onFailure, flags, options);
402 }
403 
404 #ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
405 const RegisteredPrefixId*
407  const RegisterPrefixSuccessCallback& onSuccess,
408  const RegisterPrefixFailureCallback& onFailure,
409  const security::v1::IdentityCertificate& certificate,
410  uint64_t flags)
411 {
412  security::SigningInfo signingInfo;
413  if (!certificate.getName().empty()) {
414  signingInfo = signingByCertificate(certificate.getName());
415  }
416  return registerPrefix(prefix, onSuccess, onFailure, signingInfo, flags);
417 }
418 
419 const RegisteredPrefixId*
421  const RegisterPrefixSuccessCallback& onSuccess,
422  const RegisterPrefixFailureCallback& onFailure,
423  const Name& identity,
424  uint64_t flags)
425 {
426  security::SigningInfo signingInfo = signingByIdentity(identity);
427  return registerPrefix(prefix, onSuccess, onFailure, signingInfo, flags);
428 }
429 #endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
430 
431 void
432 Face::unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId)
433 {
434  IO_CAPTURE_WEAK_IMPL(post) {
435  impl->asyncUnregisterPrefix(registeredPrefixId, nullptr, nullptr);
437 }
438 
439 void
440 Face::unsetInterestFilter(const InterestFilterId* interestFilterId)
441 {
442  IO_CAPTURE_WEAK_IMPL(post) {
443  impl->asyncUnsetInterestFilter(interestFilterId);
445 }
446 
447 void
448 Face::unregisterPrefix(const RegisteredPrefixId* registeredPrefixId,
449  const UnregisterPrefixSuccessCallback& onSuccess,
450  const UnregisterPrefixFailureCallback& onFailure)
451 {
452  IO_CAPTURE_WEAK_IMPL(post) {
453  impl->asyncUnregisterPrefix(registeredPrefixId, onSuccess, onFailure);
455 }
456 
457 void
458 Face::doProcessEvents(const time::milliseconds& timeout, bool keepThread)
459 {
460  if (m_ioService.stopped()) {
461  m_ioService.reset(); // ensure that run()/poll() will do some work
462  }
463 
464  try {
465  if (timeout < time::milliseconds::zero()) {
466  // do not block if timeout is negative, but process pending events
467  m_ioService.poll();
468  return;
469  }
470 
471  if (timeout > time::milliseconds::zero()) {
472  boost::asio::io_service& ioService = m_ioService;
473  unique_ptr<boost::asio::io_service::work>& work = m_impl->m_ioServiceWork;
474  m_impl->m_processEventsTimeoutEvent = m_impl->m_scheduler.scheduleEvent(timeout,
475  [&ioService, &work] {
476  ioService.stop();
477  work.reset();
478  });
479  }
480 
481  if (keepThread) {
482  // work will ensure that m_ioService is running until work object exists
483  m_impl->m_ioServiceWork.reset(new boost::asio::io_service::work(m_ioService));
484  }
485 
486  m_ioService.run();
487  }
488  catch (...) {
489  m_impl->m_ioServiceWork.reset();
490  m_impl->m_pendingInterestTable.clear();
491  m_impl->m_registeredPrefixTable.clear();
492  throw;
493  }
494 }
495 
496 void
498 {
499  IO_CAPTURE_WEAK_IMPL(post) {
500  this->asyncShutdown();
502 }
503 
504 void
505 Face::asyncShutdown()
506 {
507  m_impl->m_pendingInterestTable.clear();
508  m_impl->m_registeredPrefixTable.clear();
509 
510  if (m_transport->isConnected())
511  m_transport->close();
512 
513  m_impl->m_ioServiceWork.reset();
514 }
515 
519 template<typename NetPkt>
520 static void
521 extractLpLocalFields(NetPkt& netPacket, const lp::Packet& lpPacket)
522 {
523  if (lpPacket.has<lp::IncomingFaceIdField>()) {
524  netPacket.setTag(make_shared<lp::IncomingFaceIdTag>(lpPacket.get<lp::IncomingFaceIdField>()));
525  }
526 
527  if (lpPacket.has<lp::CongestionMarkField>()) {
528  netPacket.setTag(make_shared<lp::CongestionMarkTag>(lpPacket.get<lp::CongestionMarkField>()));
529  }
530 }
531 
532 void
533 Face::onReceiveElement(const Block& blockFromDaemon)
534 {
535  lp::Packet lpPacket(blockFromDaemon); // bare Interest/Data is a valid lp::Packet,
536  // no need to distinguish
537 
538  Buffer::const_iterator begin, end;
539  std::tie(begin, end) = lpPacket.get<lp::FragmentField>();
540  Block netPacket(&*begin, std::distance(begin, end));
541  switch (netPacket.type()) {
542  case tlv::Interest: {
543  auto interest = make_shared<Interest>(netPacket);
544  if (lpPacket.has<lp::NackField>()) {
545  auto nack = make_shared<lp::Nack>(std::move(*interest));
546  nack->setHeader(lpPacket.get<lp::NackField>());
547  extractLpLocalFields(*nack, lpPacket);
548  m_impl->nackPendingInterests(*nack);
549  }
550  else {
551  extractLpLocalFields(*interest, lpPacket);
552  m_impl->processInterestFilters(*interest);
553  }
554  break;
555  }
556  case tlv::Data: {
557  auto data = make_shared<Data>(netPacket);
558  extractLpLocalFields(*data, lpPacket);
559  m_impl->satisfyPendingInterests(*data);
560  break;
561  }
562  }
563 }
564 
565 } // namespace ndn
size_t wireEncode(EncodingImpl< TAG > &encoder) const
append packet to encoder
Definition: packet.cpp:42
Copyright (c) 2013-2016 Regents of the University of California.
Definition: common.hpp:74
const NackHeader & getHeader() const
Definition: nack.hpp:65
function< void(const std::string &)> UnregisterPrefixFailureCallback
Callback invoked when unregisterPrefix or unsetInterestFilter command fails.
Definition: face.hpp:116
virtual ~Face()
Copyright (c) 2013-2016 Regents of the University of California.
Definition: common.hpp:98
implementation detail of Face
Definition: face-impl.hpp:51
Buffer::const_iterator end() const
Definition: block.cpp:486
const RegisteredPrefixId * setInterestFilter(const InterestFilter &interestFilter, const InterestCallback &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...
Definition: face.cpp:294
Packet & add(const typename FIELD::ValueType &value)
add a FIELD with value
Definition: packet.hpp:156
declares the set of Interests a producer can serve, which starts with a name prefix, plus an optional regular expression
const Interest & getInterest() const
Definition: nack.hpp:53
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
represents an Interest packet
Definition: interest.hpp:42
function< void(const Interest &)> OnTimeout
Callback invoked when expressed Interest times out.
Definition: face.hpp:85
bool has() const
Definition: packet.hpp:75
static void extractLpLocalFields(NetPkt &netPacket, const lp::Packet &lpPacket)
extract local fields from NDNLPv2 packet and tag onto a network layer packet
Definition: face.cpp:521
function< void(const InterestFilter &, const Interest &)> OnInterest
Callback invoked when incoming Interest matches the specified InterestFilter.
Definition: face.hpp:96
virtual void doProcessEvents(const time::milliseconds &timeout, bool keepThread)
Definition: face.cpp:458
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.
Definition: face.cpp:448
static shared_ptr< UnixTransport > create(const std::string &uri)
Create transport with parameters defined in URI.
represents a Network Nack
Definition: nack.hpp:40
const Name & getName() const
Get name of the Data packet.
Definition: data.hpp:318
provides a tag type for simple types
Definition: tag.hpp:58
size_t size() const
Definition: block.cpp:504
#define IO_CAPTURE_WEAK_IMPL(OP)
Copyright (c) 2013-2017 Regents of the University of California.
Definition: face.cpp:34
void removeAllPendingInterests()
Cancel all previously expressed Interests.
Definition: face.cpp:224
size_t wireEncode(EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const
Fast encoding or block size estimation.
Definition: data.cpp:52
detail::FieldDecl< field_location_tags::Fragment, std::pair< Buffer::const_iterator, Buffer::const_iterator >, tlv::Fragment > FragmentField
The value of the wire encoded field is the data between the provided iterators.
Definition: fields.hpp:88
FIELD::ValueType get(size_t index=0) const
Definition: packet.hpp:100
contains options for ControlCommand execution
shared_ptr< Transport > getTransport()
Definition: face.cpp:160
static shared_ptr< TcpTransport > create(const std::string &uri)
Create transport with parameters defined in URI.
void shutdown()
Shutdown face operations.
Definition: face.cpp:497
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Definition: interest.cpp:225
function< void(const Name &, const std::string &)> RegisterPrefixFailureCallback
Callback invoked when registerPrefix or setInterestFilter command fails.
Definition: face.hpp:106
function< void(const Name &)> RegisterPrefixSuccessCallback
Callback invoked when registerPrefix or setInterestFilter command succeeds.
Definition: face.hpp:101
Name abstraction to represent an absolute name.
Definition: name.hpp:46
void unsetInterestFilter(const RegisteredPrefixId *registeredPrefixId)
Remove the registered prefix entry with the registeredPrefixId.
Definition: face.cpp:432
detail::FieldDecl< field_location_tags::Header, NackHeader, tlv::Nack > NackField
Definition: fields.hpp:53
CommandOptions & setSigningInfo(const security::SigningInfo &signingInfo)
sets signing parameters
function< void(const InterestFilter &, const Interest &)> InterestCallback
Callback invoked when incoming Interest matches the specified InterestFilter.
Definition: face.hpp:90
#define IO_CAPTURE_WEAK_IMPL_END
Definition: face.cpp:40
SigningInfo signingByIdentity(const Name &identityName)
function< void(const Interest &, Data &)> OnData
Callback invoked when expressed Interest gets satisfied with Data packet.
Definition: face.hpp:79
size_t getNPendingInterests() const
Get number of pending Interests.
Definition: face.cpp:232
bool empty() const
Check if name is emtpy.
Definition: name.hpp:390
function< void()> UnregisterPrefixSuccessCallback
Callback invoked when unregisterPrefix or unsetInterestFilter command succeeds.
Definition: face.hpp:111
shared_ptr< T > getTag() const
get a tag item
Definition: tag-host.hpp:67
const PendingInterestId * expressInterest(const Interest &interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout)
Express Interest.
Definition: face.cpp:166
function< void(const Interest &)> TimeoutCallback
Callback invoked when expressed Interest times out.
Definition: face.hpp:73
function< void(const Interest &, const lp::Nack &)> NackCallback
Callback invoked when Nack is sent in response to expressed Interest.
Definition: face.hpp:68
represents a Data packet
Definition: data.hpp:37
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.
Definition: face.cpp:392
Face(shared_ptr< Transport > transport=nullptr)
Create Face using given transport (or default transport if omitted)
Definition: face.cpp:47
ndn security v2 KeyChain
function< void(const Interest &, const Data &)> DataCallback
Callback invoked when expressed Interest gets satisfied with a Data packet.
Definition: face.hpp:63
void removePendingInterest(const PendingInterestId *pendingInterestId)
Cancel previously expressed Interest.
Definition: face.cpp:216
Buffer::const_iterator begin() const
Definition: block.cpp:477
void put(const Data &data)
Publish data packet.
Definition: face.cpp:238
const size_t MAX_NDN_PACKET_SIZE
practical limit of network layer packet size