blob: 51a5270a99031c52950acd526704a46ece33eb85 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -07002/**
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -07003 * Copyright (c) 2013-2016 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * 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.
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070020 */
21
Jeff Thompsonb9e3c8e2013-08-02 11:42:51 -070022#ifndef NDN_FACE_HPP
Jeff Thompsona0d18c92013-08-06 13:55:32 -070023#define NDN_FACE_HPP
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070024
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080025#include "common.hpp"
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070026
27#include "name.hpp"
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080028#include "interest.hpp"
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070029#include "interest-filter.hpp"
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080030#include "data.hpp"
Junxiao Shi4b469982015-12-03 18:20:19 +000031#include "encoding/nfd-constants.hpp"
Eric Newberry83872fd2015-08-06 17:01:24 -070032#include "lp/nack.hpp"
Junxiao Shi4b469982015-12-03 18:20:19 +000033#include "security/signing-info.hpp"
Joao Pereira0b3cac52015-07-02 14:49:49 -040034
35#define NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
36
37#ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
Alexander Afanasyev984ad192014-05-02 19:11:15 -070038#include "security/identity-certificate.hpp"
Joao Pereira0b3cac52015-07-02 14:49:49 -040039#endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080040
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070041namespace boost {
42namespace asio {
43class io_service;
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -070044} // namespace asio
45} // namespace boost
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080046
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070047namespace ndn {
48
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070049class Transport;
50
51class PendingInterestId;
52class RegisteredPrefixId;
53class InterestFilterId;
54
Yingdi Yu1b0311c2015-06-10 14:58:47 -070055namespace security {
56class KeyChain;
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -070057} // namespace security
Yingdi Yu1b0311c2015-06-10 14:58:47 -070058using security::KeyChain;
59
Alexander Afanasyevee8bb1e2014-05-02 17:39:54 -070060namespace nfd {
61class Controller;
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -070062} // namespace nfd
Alexander Afanasyevee8bb1e2014-05-02 17:39:54 -070063
Jeff Thompsonfe08e5a2013-08-13 11:15:59 -070064/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +000065 * @brief Callback invoked when expressed Interest gets satisfied with a Data packet
Eric Newberry83872fd2015-08-06 17:01:24 -070066 */
67typedef function<void(const Interest&, const Data&)> DataCallback;
68
69/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +000070 * @brief Callback invoked when Nack is sent in response to expressed Interest
Eric Newberry83872fd2015-08-06 17:01:24 -070071 */
72typedef function<void(const Interest&, const lp::Nack&)> NackCallback;
73
74/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +000075 * @brief Callback invoked when expressed Interest times out
Eric Newberry83872fd2015-08-06 17:01:24 -070076 */
77typedef function<void(const Interest&)> TimeoutCallback;
78
79/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +000080 * @brief Callback invoked when expressed Interest gets satisfied with Data packet
Eric Newberry83872fd2015-08-06 17:01:24 -070081 * @deprecated use DataCallback
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080082 */
83typedef function<void(const Interest&, Data&)> OnData;
84
85/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +000086 * @brief Callback invoked when expressed Interest times out
Eric Newberry83872fd2015-08-06 17:01:24 -070087 * @deprecated use TimeoutCallback
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080088 */
89typedef function<void(const Interest&)> OnTimeout;
90
91/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +000092 * @brief Callback invoked when incoming Interest matches the specified InterestFilter
93 */
94typedef function<void(const InterestFilter&, const Interest&)> InterestCallback;
95
96/**
97 * @brief Callback invoked when incoming Interest matches the specified InterestFilter
98 * @deprecated use InterestCallback
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080099 */
Alexander Afanasyev90164962014-03-06 08:29:59 +0000100typedef function<void (const InterestFilter&, const Interest&)> OnInterest;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800101
102/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000103 * @brief Callback invoked when registerPrefix or setInterestFilter command succeeds
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800104 */
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700105typedef function<void(const Name&)> RegisterPrefixSuccessCallback;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800106
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700107/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000108 * @brief Callback invoked when registerPrefix or setInterestFilter command fails
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700109 */
110typedef function<void(const Name&, const std::string&)> RegisterPrefixFailureCallback;
111
112/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000113 * @brief Callback invoked when unregisterPrefix or unsetInterestFilter command succeeds
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700114 */
115typedef function<void()> UnregisterPrefixSuccessCallback;
116
117/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000118 * @brief Callback invoked when unregisterPrefix or unsetInterestFilter command fails
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700119 */
120typedef function<void(const std::string&)> UnregisterPrefixFailureCallback;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800121
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800122/**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000123 * @brief Provide a communication channel with local or remote NDN forwarder
Jeff Thompsonfe08e5a2013-08-13 11:15:59 -0700124 */
Alexander Afanasyev8460afb2014-02-15 20:31:42 -0800125class Face : noncopyable
126{
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -0700127public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700128 class Error : public std::runtime_error
129 {
130 public:
131 explicit
132 Error(const std::string& what)
133 : std::runtime_error(what)
134 {
135 }
136 };
Alexander Afanasyevb790d952014-01-24 12:07:53 -0800137
Junxiao Shiedd834e2014-10-28 20:28:58 -0700138public: // constructors
Alexander Afanasyevb790d952014-01-24 12:07:53 -0800139 /**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000140 * @brief Create Face using given transport (or default transport if omitted)
141 * @param transport the transport for lower layer communication. If nullptr,
142 * a default transport will be used. The default transport is
143 * determined from a FaceUri in NDN_CLIENT_TRANSPORT environ,
144 * a FaceUri in configuration file 'transport' key, or UnixTransport.
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700145 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000146 * @throw ConfigFile::Error if @p transport is nullptr, and the configuration file cannot be
147 * parsed or specifies an unsupported protocol
148 * @note shared_ptr is passed by value because ownership is shared with this class
Alexander Afanasyevb790d952014-01-24 12:07:53 -0800149 */
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000150 explicit
151 Face(shared_ptr<Transport> transport = nullptr);
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800152
153 /**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000154 * @brief Create Face using default transport and given io_service
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700155 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000156 * Usage examples:
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700157 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000158 * @code
159 * Face face1;
160 * Face face2(face1.getIoService());
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700161 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000162 * // Now the following ensures that events on both faces are processed
163 * face1.processEvents();
164 * // or face1.getIoService().run();
165 * @endcode
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700166 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000167 * or
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700168 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000169 * @code
170 * boost::asio::io_service ioService;
171 * Face face1(ioService);
172 * Face face2(ioService);
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700173 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000174 * ioService.run();
175 * @endcode
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700176 *
177 * @param ioService A reference to boost::io_service object that should control all
178 * IO operations.
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000179 * @throw ConfigFile::Error the configuration file cannot be parsed or specifies an unsupported protocol
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700180 */
181 explicit
182 Face(boost::asio::io_service& ioService);
183
184 /**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000185 * @brief Create Face using TcpTransport
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700186 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000187 * @param host IP address or hostname of the NDN forwarder
188 * @param port port number or service name of the NDN forwarder (**default**: "6363")
Jeff Thompsonfe08e5a2013-08-13 11:15:59 -0700189 */
Junxiao Shiae0b4182016-08-08 22:53:17 +0000190 explicit
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800191 Face(const std::string& host, const std::string& port = "6363");
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800192
193 /**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000194 * @brief Create Face using given transport and KeyChain
195 * @param transport the transport for lower layer communication. If nullptr,
196 * a default transport will be used.
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -0700197 * @param keyChain the KeyChain to sign commands
198 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000199 * @sa Face(shared_ptr<Transport>)
200 *
201 * @throw ConfigFile::Error if @p transport is nullptr, and the configuration file cannot be
202 * parsed or specifies an unsupported protocol
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -0700203 * @note shared_ptr is passed by value because ownership is shared with this class
204 */
205 Face(shared_ptr<Transport> transport, KeyChain& keyChain);
206
207 /**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000208 * @brief Create Face using given transport and IO service
209 * @param transport the transport for lower layer communication. If nullptr,
210 * a default transport will be used.
Alexander Afanasyevbb64c172015-12-29 20:32:45 -0800211 * @param ioService the io_service that controls all IO operations
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800212 *
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700213 * @sa Face(boost::asio::io_service&)
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000214 * @sa Face(shared_ptr<Transport>)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800215 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000216 * @throw ConfigFile::Error if @p transport is nullptr, and the configuration file cannot be
217 * parsed or specifies an unsupported protocol
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -0700218 * @note shared_ptr is passed by value because ownership is shared with this class
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800219 */
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -0700220 Face(shared_ptr<Transport> transport, boost::asio::io_service& ioService);
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800221
Jeff Thompson4fe45512013-08-23 14:06:38 -0700222 /**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000223 * @brief Create a new Face using given Transport and IO service
224 * @param transport the transport for lower layer communication. If nullptr,
225 * a default transport will be used.
Junxiao Shiedd834e2014-10-28 20:28:58 -0700226 * @param ioService the io_service that controls all IO operations
227 * @param keyChain the KeyChain to sign commands
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -0700228 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000229 * @sa Face(boost::asio::io_service&)
230 * @sa Face(shared_ptr<Transport>, KeyChain&)
231 *
232 * @throw ConfigFile::Error if @p transport is nullptr, and the configuration file cannot be
233 * parsed or specifies an unsupported protocol
Junxiao Shiedd834e2014-10-28 20:28:58 -0700234 * @note shared_ptr is passed by value because ownership is shared with this class
235 */
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -0700236 Face(shared_ptr<Transport> transport, boost::asio::io_service& ioService, KeyChain& keyChain);
Junxiao Shiedd834e2014-10-28 20:28:58 -0700237
238 ~Face();
239
240public: // consumer
241 /**
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800242 * @brief Express Interest
Eric Newberry83872fd2015-08-06 17:01:24 -0700243 * @param interest the Interest; a copy will be made, so that the caller is not
244 * required to maintain the argument unchanged
245 * @param afterSatisfied function to be invoked if Data is returned
246 * @param afterNacked function to be invoked if Network NACK is returned
247 * @param afterTimeout function to be invoked if neither Data nor Network NACK
248 * is returned within InterestLifetime
249 */
250 const PendingInterestId*
251 expressInterest(const Interest& interest,
252 const DataCallback& afterSatisfied,
253 const NackCallback& afterNacked,
254 const TimeoutCallback& afterTimeout);
255
256 /**
257 * @brief Express Interest
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800258 *
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700259 * @param interest An Interest to be expressed
260 * @param onData Callback to be called when a matching data packet is received
Eric Newberry83872fd2015-08-06 17:01:24 -0700261 * @param onTimeout (optional) A function object to call if the interest times out or is Nacked
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800262 *
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700263 * @return The pending interest ID which can be used with removePendingInterest
Alexander Afanasyev49bb1fb2014-07-21 12:54:01 -0700264 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000265 * @throw Error when Interest size exceeds maximum limit (MAX_NDN_PACKET_SIZE)
Eric Newberry83872fd2015-08-06 17:01:24 -0700266 *
267 * @deprecated use expressInterest(Interest, DataCallback, NackCallback, TimeoutCallback)
Jeff Thompson4fe45512013-08-23 14:06:38 -0700268 */
Alexander Afanasyevb790d952014-01-24 12:07:53 -0800269 const PendingInterestId*
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800270 expressInterest(const Interest& interest,
Eric Newberry83872fd2015-08-06 17:01:24 -0700271 const OnData& onData,
272 const OnTimeout& onTimeout = nullptr);
Jeff Thompson4fe45512013-08-23 14:06:38 -0700273
274 /**
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800275 * @brief Express Interest using name and Interest template
276 *
277 * @param name Name of the Interest
278 * @param tmpl Interest template to fill parameters
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700279 * @param onData Callback to be called when a matching data packet is received
Eric Newberry83872fd2015-08-06 17:01:24 -0700280 * @param onTimeout (optional) A function object to call if the interest times out or is Nacked
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800281 *
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700282 * @return Opaque pending interest ID which can be used with removePendingInterest
Alexander Afanasyev49bb1fb2014-07-21 12:54:01 -0700283 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000284 * @throw Error when Interest size exceeds maximum limit (MAX_NDN_PACKET_SIZE)
Eric Newberry83872fd2015-08-06 17:01:24 -0700285 *
286 * @deprecated use expressInterest(Interest, DataCallback, NackCallback, TimeoutCallback)
Jeff Thompson7aec0252013-08-22 17:29:57 -0700287 */
Alexander Afanasyevb790d952014-01-24 12:07:53 -0800288 const PendingInterestId*
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800289 expressInterest(const Name& name,
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800290 const Interest& tmpl,
Eric Newberry83872fd2015-08-06 17:01:24 -0700291 const OnData& onData,
292 const OnTimeout& onTimeout = nullptr);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700293
Jeff Thompson11095142013-10-01 16:20:28 -0700294 /**
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700295 * @brief Cancel previously expressed Interest
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700296 *
Jeff Thompson11095142013-10-01 16:20:28 -0700297 * @param pendingInterestId The ID returned from expressInterest.
298 */
299 void
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800300 removePendingInterest(const PendingInterestId* pendingInterestId);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700301
Jeff Thompson432c8be2013-08-09 16:16:08 -0700302 /**
Ilya Moiseenko56b0bf82015-11-08 11:14:28 -0500303 * @brief Cancel all previously expressed Interests
304 */
305 void
306 removeAllPendingInterests();
307
308 /**
Alexander Afanasyev6fcdde22014-08-22 19:03:36 -0700309 * @brief Get number of pending Interests
310 */
311 size_t
312 getNPendingInterests() const;
313
Junxiao Shiedd834e2014-10-28 20:28:58 -0700314public: // producer
Alexander Afanasyev6fcdde22014-08-22 19:03:36 -0700315 /**
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700316 * @brief Set InterestFilter to dispatch incoming matching interest to onInterest
317 * callback and register the filtered prefix with the connected NDN forwarder
318 *
319 * This version of setInterestFilter combines setInterestFilter and registerPrefix
320 * operations and is intended to be used when only one filter for the same prefix needed
321 * to be set. When multiple names sharing the same prefix should be dispatched to
322 * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by
323 * a series of setInterestFilter calls.
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700324 *
Alexander Afanasyev90164962014-03-06 08:29:59 +0000325 * @param interestFilter Interest filter (prefix part will be registered with the forwarder)
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700326 * @param onInterest A callback to be called when a matching interest is received
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700327 * @param onFailure A callback to be called when prefixRegister command fails
Joao Pereiraba1e3b92015-06-01 17:50:37 -0400328 * @param flags (optional) RIB flags
Joao Pereira0b3cac52015-07-02 14:49:49 -0400329 * @param signingInfo (optional) Signing parameters. When omitted, a default parameters
330 * used in the signature will be used.
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700331 *
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700332 * @return Opaque registered prefix ID which can be used with unsetInterestFilter or
333 * removeRegisteredPrefix
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700334 */
335 const RegisteredPrefixId*
Alexander Afanasyev90164962014-03-06 08:29:59 +0000336 setInterestFilter(const InterestFilter& interestFilter,
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000337 const InterestCallback& onInterest,
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700338 const RegisterPrefixFailureCallback& onFailure,
Joao Pereira0b3cac52015-07-02 14:49:49 -0400339 const security::SigningInfo& signingInfo = security::SigningInfo(),
Alexander Afanasyev0866f512014-08-11 13:25:09 -0700340 uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT);
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700341
342 /**
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700343 * @brief Set InterestFilter to dispatch incoming matching interest to onInterest
344 * callback and register the filtered prefix with the connected NDN forwarder
345 *
346 * This version of setInterestFilter combines setInterestFilter and registerPrefix
347 * operations and is intended to be used when only one filter for the same prefix needed
348 * to be set. When multiple names sharing the same prefix should be dispatched to
349 * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by
350 * a series of setInterestFilter calls.
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700351 *
Alexander Afanasyev90164962014-03-06 08:29:59 +0000352 * @param interestFilter Interest filter (prefix part will be registered with the forwarder)
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700353 * @param onInterest A callback to be called when a matching interest is received
354 * @param onSuccess A callback to be called when prefixRegister command succeeds
355 * @param onFailure A callback to be called when prefixRegister command fails
Joao Pereiraba1e3b92015-06-01 17:50:37 -0400356 * @param flags (optional) RIB flags
Joao Pereira0b3cac52015-07-02 14:49:49 -0400357 * @param signingInfo (optional) Signing parameters. When omitted, a default parameters
358 * used in the signature will be used.
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700359 *
Joao Pereira0b3cac52015-07-02 14:49:49 -0400360 * @return Opaque registered prefix ID which can be used with unsetInterestFilter or
361 * removeRegisteredPrefix
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700362 */
363 const RegisteredPrefixId*
Alexander Afanasyev90164962014-03-06 08:29:59 +0000364 setInterestFilter(const InterestFilter& interestFilter,
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000365 const InterestCallback& onInterest,
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700366 const RegisterPrefixSuccessCallback& onSuccess,
367 const RegisterPrefixFailureCallback& onFailure,
Joao Pereira0b3cac52015-07-02 14:49:49 -0400368 const security::SigningInfo& signingInfo = security::SigningInfo(),
Alexander Afanasyev0866f512014-08-11 13:25:09 -0700369 uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT);
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700370
371 /**
372 * @brief Set InterestFilter to dispatch incoming matching interest to onInterest callback
373 *
374 * @param interestFilter Interest
375 * @param onInterest A callback to be called when a matching interest is received
376 *
377 * This method modifies library's FIB only, and does not register the prefix with the
378 * forwarder. It will always succeed. To register prefix with the forwarder, use
379 * registerPrefix, or use the setInterestFilter overload taking two callbacks.
380 *
381 * @return Opaque interest filter ID which can be used with unsetInterestFilter
382 */
383 const InterestFilterId*
384 setInterestFilter(const InterestFilter& interestFilter,
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000385 const InterestCallback& onInterest);
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700386
Joao Pereira0b3cac52015-07-02 14:49:49 -0400387#ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
388 /**
389 * @deprecated Use override with SigningInfo instead of this function
390 * @brief Set InterestFilter to dispatch incoming matching interest to onInterest
391 * callback and register the filtered prefix with the connected NDN forwarder
392 *
393 * This version of setInterestFilter combines setInterestFilter and registerPrefix
394 * operations and is intended to be used when only one filter for the same prefix needed
395 * to be set. When multiple names sharing the same prefix should be dispatched to
396 * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by
397 * a series of setInterestFilter calls.
398 *
399 * @param interestFilter Interest filter (prefix part will be registered with the forwarder)
400 * @param onInterest A callback to be called when a matching interest is received
401 * @param onSuccess A callback to be called when prefixRegister command succeeds
402 * @param onFailure A callback to be called when prefixRegister command fails
403 * @param flags (optional) RIB flags
404 * @param certificate (optional) A certificate under which the prefix registration
405 * command is signed. When omitted, a default certificate of
406 * the default identity is used to sign the registration command
407 *
408 * @return Opaque registered prefix ID which can be used with unsetInterestFilter or
409 * removeRegisteredPrefix
410 */
philobb778e72015-08-25 14:49:19 -0700411 DEPRECATED(
Joao Pereira0b3cac52015-07-02 14:49:49 -0400412 const RegisteredPrefixId*
413 setInterestFilter(const InterestFilter& interestFilter,
414 const OnInterest& onInterest,
415 const RegisterPrefixSuccessCallback& onSuccess,
416 const RegisterPrefixFailureCallback& onFailure,
417 const IdentityCertificate& certificate,
philobb778e72015-08-25 14:49:19 -0700418 uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT));
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700419
420 /**
Joao Pereira0b3cac52015-07-02 14:49:49 -0400421 * @deprecated Use override with SigningInfo instead of this function
422 * @brief Set InterestFilter to dispatch incoming matching interest to onInterest
423 * callback and register the filtered prefix with the connected NDN forwarder
424 *
425 * This version of setInterestFilter combines setInterestFilter and registerPrefix
426 * operations and is intended to be used when only one filter for the same prefix needed
427 * to be set. When multiple names sharing the same prefix should be dispatched to
428 * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by
429 * a series of setInterestFilter calls.
430 *
431 * @param interestFilter Interest filter (prefix part will be registered with the forwarder)
432 * @param onInterest A callback to be called when a matching interest is received
433 * @param onFailure A callback to be called when prefixRegister command fails
434 * @param flags (optional) RIB flags
435 * @param certificate (optional) A certificate under which the prefix registration
436 * command is signed. When omitted, a default certificate of
437 * the default identity is used to sign the registration command
438 *
439 * @return Opaque registered prefix ID which can be used with unsetInterestFilter or
440 * removeRegisteredPrefix
441 */
philobb778e72015-08-25 14:49:19 -0700442 DEPRECATED(
Joao Pereira0b3cac52015-07-02 14:49:49 -0400443 const RegisteredPrefixId*
444 setInterestFilter(const InterestFilter& interestFilter,
445 const OnInterest& onInterest,
446 const RegisterPrefixFailureCallback& onFailure,
447 const IdentityCertificate& certificate,
philobb778e72015-08-25 14:49:19 -0700448 uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT));
Joao Pereira0b3cac52015-07-02 14:49:49 -0400449
450 /**
451 * @deprecated Use override with SigningInfo instead of this function
452 * @brief Set InterestFilter to dispatch incoming matching interest to onInterest
453 * callback and register the filtered prefix with the connected NDN forwarder
454 *
455 * This version of setInterestFilter combines setInterestFilter and registerPrefix
456 * operations and is intended to be used when only one filter for the same prefix needed
457 * to be set. When multiple names sharing the same prefix should be dispatched to
458 * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by
459 * a series of setInterestFilter calls.
460 *
461 * @param interestFilter Interest filter (prefix part will be registered with the forwarder)
462 * @param onInterest A callback to be called when a matching interest is received
463 * @param onSuccess A callback to be called when prefixRegister command succeeds
464 * @param onFailure A callback to be called when prefixRegister command fails
465 * @param identity A signing identity. A prefix registration command is signed
466 * under the default certificate of this identity
467 * @param flags (optional) RIB flags
468 *
469 * @return Opaque registered prefix ID which can be used with removeRegisteredPrefix
470 */
philobb778e72015-08-25 14:49:19 -0700471 DEPRECATED(
Joao Pereira0b3cac52015-07-02 14:49:49 -0400472 const RegisteredPrefixId*
473 setInterestFilter(const InterestFilter& interestFilter,
474 const OnInterest& onInterest,
475 const RegisterPrefixSuccessCallback& onSuccess,
476 const RegisterPrefixFailureCallback& onFailure,
477 const Name& identity,
philobb778e72015-08-25 14:49:19 -0700478 uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT));
Joao Pereira0b3cac52015-07-02 14:49:49 -0400479
480 /**
481 * @deprecated Use override with SigningInfo instead of this function
482 * @brief Set InterestFilter to dispatch incoming matching interest to onInterest
483 * callback and register the filtered prefix with the connected NDN forwarder
484 *
485 * This version of setInterestFilter combines setInterestFilter and registerPrefix
486 * operations and is intended to be used when only one filter for the same prefix needed
487 * to be set. When multiple names sharing the same prefix should be dispatched to
488 * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by
489 * a series of setInterestFilter calls.
490 *
491 * @param interestFilter Interest filter (prefix part will be registered with the forwarder)
492 * @param onInterest A callback to be called when a matching interest is received
493 * @param onFailure A callback to be called when prefixRegister command fails
494 * @param identity A signing identity. A prefix registration command is signed
495 * under the default certificate of this identity
496 * @param flags (optional) RIB flags
497 *
498 * @return Opaque registered prefix ID which can be used with removeRegisteredPrefix
499 */
philobb778e72015-08-25 14:49:19 -0700500 DEPRECATED(
Joao Pereira0b3cac52015-07-02 14:49:49 -0400501 const RegisteredPrefixId*
502 setInterestFilter(const InterestFilter& interestFilter,
503 const OnInterest& onInterest,
504 const RegisterPrefixFailureCallback& onFailure,
505 const Name& identity,
philobb778e72015-08-25 14:49:19 -0700506 uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT));
Joao Pereira0b3cac52015-07-02 14:49:49 -0400507#endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
508
509 /**
510 * @brief Register prefix with the connected NDN forwarder
511 *
512 * This method only modifies forwarder's RIB and does not associate any
513 * onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to
514 * the right callbacks.
515 *
516 * @param prefix A prefix to register with the connected NDN forwarder
517 * @param onSuccess A callback to be called when prefixRegister command succeeds
518 * @param onFailure A callback to be called when prefixRegister command fails
519 * @param signingInfo (optional) Signing parameters. When omitted, a default parameters
520 * used in the signature will be used.
Alexander Afanasyevf2a46222015-09-17 18:01:30 -0700521 * @param flags Prefix registration flags
Joao Pereira0b3cac52015-07-02 14:49:49 -0400522 *
523 * @return The registered prefix ID which can be used with unregisterPrefix
Alexander Afanasyevf2a46222015-09-17 18:01:30 -0700524 * @see nfd::RouteFlags
Joao Pereira0b3cac52015-07-02 14:49:49 -0400525 */
526 const RegisteredPrefixId*
527 registerPrefix(const Name& prefix,
528 const RegisterPrefixSuccessCallback& onSuccess,
529 const RegisterPrefixFailureCallback& onFailure,
530 const security::SigningInfo& signingInfo = security::SigningInfo(),
531 uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT);
532
533#ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
534 /**
535 * @deprecated Use override with SigningInfo instead of this function
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700536 * @brief Register prefix with the connected NDN forwarder
537 *
Joao Pereiraba1e3b92015-06-01 17:50:37 -0400538 * This method only modifies forwarder's RIB and does not associate any
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700539 * onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to
540 * the right callbacks.
541 *
542 * @param prefix A prefix to register with the connected NDN forwarder
543 * @param onSuccess A callback to be called when prefixRegister command succeeds
544 * @param onFailure A callback to be called when prefixRegister command fails
545 * @param certificate (optional) A certificate under which the prefix registration
Junxiao Shi6a90f372014-10-13 20:29:30 -0700546 * command is signed. When omitted, a default certificate of
547 * the default identity is used to sign the registration command
Joao Pereiraba1e3b92015-06-01 17:50:37 -0400548 * @param flags (optional) RIB flags
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700549 *
550 * @return The registered prefix ID which can be used with unregisterPrefix
551 */
philobb778e72015-08-25 14:49:19 -0700552 DEPRECATED(
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700553 const RegisteredPrefixId*
554 registerPrefix(const Name& prefix,
555 const RegisterPrefixSuccessCallback& onSuccess,
556 const RegisterPrefixFailureCallback& onFailure,
Joao Pereira0b3cac52015-07-02 14:49:49 -0400557 const IdentityCertificate& certificate,
philobb778e72015-08-25 14:49:19 -0700558 uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT));
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700559
560 /**
Joao Pereira0b3cac52015-07-02 14:49:49 -0400561 * @deprecated Use override with SigningInfo instead of this function
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700562 * @brief Register prefix with the connected NDN forwarder and call onInterest when a matching
563 * interest is received.
564 *
Joao Pereiraba1e3b92015-06-01 17:50:37 -0400565 * This method only modifies forwarder's RIB and does not associate any
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700566 * onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to
567 * the right callbacks.
568 *
569 * @param prefix A prefix to register with the connected NDN forwarder
570 * @param onSuccess A callback to be called when prefixRegister command succeeds
571 * @param onFailure A callback to be called when prefixRegister command fails
Junxiao Shi6a90f372014-10-13 20:29:30 -0700572 * @param identity A signing identity. A prefix registration command is signed
573 * under the default certificate of this identity
Joao Pereiraba1e3b92015-06-01 17:50:37 -0400574 * @param flags (optional) RIB flags
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700575 *
576 * @return The registered prefix ID which can be used with unregisterPrefix
577 */
philobb778e72015-08-25 14:49:19 -0700578 DEPRECATED(
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700579 const RegisteredPrefixId*
580 registerPrefix(const Name& prefix,
581 const RegisterPrefixSuccessCallback& onSuccess,
582 const RegisterPrefixFailureCallback& onFailure,
Alexander Afanasyev0866f512014-08-11 13:25:09 -0700583 const Name& identity,
philobb778e72015-08-25 14:49:19 -0700584 uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT));
Joao Pereira0b3cac52015-07-02 14:49:49 -0400585#endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700586
587 /**
Alexander Afanasyev1b01c312014-05-26 16:58:10 +0300588 * @brief Remove the registered prefix entry with the registeredPrefixId
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700589 *
590 * This does not affect another registered prefix with a different registeredPrefixId,
591 * even it if has the same prefix name. If there is no entry with the
592 * registeredPrefixId, do nothing.
593 *
Alexander Afanasyevee8bb1e2014-05-02 17:39:54 -0700594 * unsetInterestFilter will use the same credentials as original
595 * setInterestFilter/registerPrefix command
596 *
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700597 * @param registeredPrefixId The ID returned from registerPrefix
Jeff Thompson11095142013-10-01 16:20:28 -0700598 */
599 void
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800600 unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId);
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800601
Alexander Afanasyevee8bb1e2014-05-02 17:39:54 -0700602 /**
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700603 * @brief Remove previously set InterestFilter from library's FIB
604 *
605 * This method always succeeds and will **NOT** send any request to the connected
606 * forwarder.
607 *
608 * @param interestFilterId The ID returned from setInterestFilter.
609 */
610 void
611 unsetInterestFilter(const InterestFilterId* interestFilterId);
612
613 /**
Joao Pereiraba1e3b92015-06-01 17:50:37 -0400614 * @brief Unregister prefix from RIB
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700615 *
616 * unregisterPrefix will use the same credentials as original
617 * setInterestFilter/registerPrefix command
618 *
619 * If registeredPrefixId was obtained using setInterestFilter, the corresponding
620 * InterestFilter will be unset too.
621 *
Alexander Afanasyev770827c2014-05-13 17:42:55 -0700622 * @param registeredPrefixId The ID returned from registerPrefix
623 * @param onSuccess Callback to be called when operation succeeds
624 * @param onFailure Callback to be called when operation fails
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700625 */
626 void
627 unregisterPrefix(const RegisteredPrefixId* registeredPrefixId,
628 const UnregisterPrefixSuccessCallback& onSuccess,
629 const UnregisterPrefixFailureCallback& onFailure);
630
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800631 /**
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800632 * @brief Publish data packet
633 *
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700634 * This method can be called to satisfy the incoming Interest or to put Data packet into
Alexander Afanasyev6a05b4b2014-07-18 17:23:00 -0700635 * the cache of the local NDN forwarder.
636 *
637 * @param data Data packet to publish. It is highly recommended to use Data packet that
638 * was created using make_shared<Data>(...). Otherwise, put() will make an
639 * extra copy of the Data packet to ensure validity of published Data until
640 * asynchronous put() operation finishes.
Alexander Afanasyev49bb1fb2014-07-21 12:54:01 -0700641 *
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000642 * @throw Error when Data size exceeds maximum limit (MAX_NDN_PACKET_SIZE)
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800643 */
644 void
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800645 put(const Data& data);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700646
Eric Newberry83872fd2015-08-06 17:01:24 -0700647 /**
648 * @brief sends a Network NACK
649 * @param nack the Nack; a copy will be made, so that the caller is not required to
650 * maintain the argument unchanged
651 */
652 void
653 put(const lp::Nack& nack);
654
Junxiao Shiedd834e2014-10-28 20:28:58 -0700655public: // IO routine
Jeff Thompson86507bc2013-08-23 20:51:38 -0700656 /**
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700657 * @brief Process any data to receive or call timeout callbacks.
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800658 *
659 * This call will block forever (default timeout == 0) to process IO on the face.
660 * To exit, one expected to call face.shutdown() from one of the callback methods.
661 *
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700662 * If positive timeout is specified, then processEvents will exit after this timeout, if
663 * not stopped earlier with face.shutdown() or when all active events finish. The call
664 * can be called repeatedly, if desired.
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800665 *
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700666 * If negative timeout is specified, then processEvents will not block and process only
667 * pending events.
Alexander Afanasyevf75a0aa2014-01-09 14:29:22 -0800668 *
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700669 * @param timeout maximum time to block the thread
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700670 * @param keepThread Keep thread in a blocked state (in event processing), even when
671 * there are no outstanding events (e.g., no Interest/Data is expected)
672 *
673 * @throw This may throw an exception for reading data or in the callback for processing
674 * the data. If you call this from an main event loop, you may want to catch and
675 * log/disregard all exceptions.
Jeff Thompson432c8be2013-08-09 16:16:08 -0700676 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700677 void
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -0700678 processEvents(const time::milliseconds& timeout = time::milliseconds::zero(),
679 bool keepThread = false);
Jeff Thompson432c8be2013-08-09 16:16:08 -0700680
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700681 /**
682 * @brief Shutdown face operations
683 *
684 * This method cancels all pending operations and closes connection to NDN Forwarder.
685 *
686 * Note that this method does not stop IO service and if the same IO service is shared
687 * between multiple Faces or with other IO objects (e.g., Scheduler).
688 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700689 void
Jeff Thompson0050abe2013-09-17 12:50:25 -0700690 shutdown();
Yingdi Yu0d920812014-01-30 14:50:57 -0800691
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700692 /**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000693 * @return reference to IO service object
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700694 */
695 boost::asio::io_service&
696 getIoService()
697 {
Junxiao Shi2cced062014-11-02 21:27:38 -0700698 return m_ioService;
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700699 }
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800700
Alexander Afanasyev3a6da362015-12-29 20:31:03 -0800701NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED:
702 /**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000703 * @return underlying transport
Alexander Afanasyev3a6da362015-12-29 20:31:03 -0800704 */
705 shared_ptr<Transport>
706 getTransport();
707
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800708private:
Steve DiBenedettoa8659ff2014-12-04 14:50:28 -0700709 /**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000710 * @throw ConfigFile::Error on parse error and unsupported protocols
Steve DiBenedettoa8659ff2014-12-04 14:50:28 -0700711 */
Alexander Afanasyevbb64c172015-12-29 20:32:45 -0800712 shared_ptr<Transport>
713 makeDefaultTransport();
Steve DiBenedettoa8659ff2014-12-04 14:50:28 -0700714
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -0600715 /**
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000716 * @throw Face::Error on unsupported protocol
Junxiao Shi2cced062014-11-02 21:27:38 -0700717 * @note shared_ptr is passed by value because ownership is transferred to this function
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -0600718 */
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800719 void
Joao Pereira68c0d882015-05-19 14:27:55 -0400720 construct(shared_ptr<Transport> transport, KeyChain& keyChain);
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -0600721
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700722 void
Eric Newberry83872fd2015-08-06 17:01:24 -0700723 onReceiveElement(const Block& blockFromDaemon);
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800724
Alexander Afanasyev7dced462014-03-19 15:12:32 -0700725 void
726 asyncShutdown();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700727
Jeff Thompsonb982b6d2013-07-15 18:15:45 -0700728private:
Junxiao Shi2cced062014-11-02 21:27:38 -0700729 /// the IO service owned by this Face, could be null
730 unique_ptr<boost::asio::io_service> m_internalIoService;
731 /// the IO service used by this Face
732 boost::asio::io_service& m_ioService;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700733
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800734 shared_ptr<Transport> m_transport;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800735
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000736 /**
737 * @brief if not null, a pointer to an internal KeyChain owned by Face
738 * @note if a KeyChain is supplied to constructor, this pointer will be null,
739 * and the passed KeyChain is given to nfdController;
740 * currently Face does not keep the KeyChain passed in constructor
741 * because it's not needed, but this may change in the future
Junxiao Shiedd834e2014-10-28 20:28:58 -0700742 */
Joao Pereira68c0d882015-05-19 14:27:55 -0400743 unique_ptr<KeyChain> m_internalKeyChain;
Junxiao Shiedd834e2014-10-28 20:28:58 -0700744
Joao Pereira68c0d882015-05-19 14:27:55 -0400745 unique_ptr<nfd::Controller> m_nfdController;
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -0600746
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -0700747 class Impl;
Junxiao Shiae0b4182016-08-08 22:53:17 +0000748 shared_ptr<Impl> m_impl;
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -0700749};
750
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800751} // namespace ndn
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -0700752
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800753#endif // NDN_FACE_HPP