blob: 1758e27f6b29e8bb8d96bf666d87d2a50bf4ed96 [file] [log] [blame]
Jeff Thompson25b4e612013-10-10 16:03:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -07002/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
11 *
12 * Based on code originally written by Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070013 */
14
Jeff Thompsonb9e3c8e2013-08-02 11:42:51 -070015#ifndef NDN_FACE_HPP
Jeff Thompsona0d18c92013-08-06 13:55:32 -070016#define NDN_FACE_HPP
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070017
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080018#include "common.hpp"
19#include "interest.hpp"
20#include "data.hpp"
21
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080022#include "transport/transport.hpp"
23#include "transport/unix-transport.hpp"
Alexander Afanasyev20d2c582014-01-26 15:32:51 -080024#include "transport/tcp-transport.hpp"
Jeff Thompsonbeb8b7d2013-07-16 15:49:21 -070025
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080026#include "management/controller.hpp"
27
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070028#include "util/scheduler.hpp"
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080029#include "detail/registered-prefix.hpp"
30#include "detail/pending-interest.hpp"
31
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070032namespace ndn {
33
Jeff Thompsonfe08e5a2013-08-13 11:15:59 -070034/**
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080035 * An OnData function object is used to pass a callback to expressInterest.
36 */
37typedef function<void(const Interest&, Data&)> OnData;
38
39/**
40 * An OnTimeout function object is used to pass a callback to expressInterest.
41 */
42typedef function<void(const Interest&)> OnTimeout;
43
44/**
45 * An OnInterest function object is used to pass a callback to registerPrefix.
46 */
Alexander Afanasyev90164962014-03-06 08:29:59 +000047typedef function<void (const InterestFilter&, const Interest&)> OnInterest;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080048
49/**
50 * An OnRegisterFailed function object is used to report when registerPrefix fails.
51 */
Alexander Afanasyev90164962014-03-06 08:29:59 +000052typedef function<void(const InterestFilter&, const std::string&)> OnSetInterestFilterFailed;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080053
54
55
56/**
57 * @brief Abstraction to communicate with local or remote NDN forwarder
Jeff Thompsonfe08e5a2013-08-13 11:15:59 -070058 */
Alexander Afanasyev8460afb2014-02-15 20:31:42 -080059class Face : noncopyable
60{
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070061public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070062 class Error : public std::runtime_error
63 {
64 public:
65 explicit
66 Error(const std::string& what)
67 : std::runtime_error(what)
68 {
69 }
70 };
Alexander Afanasyevb790d952014-01-24 12:07:53 -080071
72 /**
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -070073 * @brief Create a new Face using the default transport (UnixTransport)
74 *
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -060075 * @throws ConfigFile::Error on configuration file parse failure
76 * @throws Face::Error on unsupported protocol
Alexander Afanasyevb790d952014-01-24 12:07:53 -080077 */
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080078 Face();
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080079
80 /**
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -070081 * @brief Create a new Face using the default transport (UnixTransport)
82 *
83 * @deprecated This constructor is deprecated. Use `Face(boost::asio::io_service&)`
84 * instead.
85 *
86 * @param ioService A shared pointer to boost::io_service object that should control all
87 * IO operations
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -060088 * @throws ConfigFile::Error on configuration file parse failure
89 * @throws Face::Error on unsupported protocol
Jeff Thompsonfe08e5a2013-08-13 11:15:59 -070090 */
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080091 explicit
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -080092 Face(const shared_ptr<boost::asio::io_service>& ioService);
93
Jeff Thompsonfe08e5a2013-08-13 11:15:59 -070094 /**
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -070095 * @brief Create a new Face using the default transport (UnixTransport)
96 *
97 * @par Usage examples:
98 *
99 * Face face1;
100 * Face face2(face1.getIoService());
101 *
102 * // Now the following ensures that events on both faces are processed
103 * face1.processEvents();
104 * // or face1.getIoService().run();
105 *
106 * @par or
107 *
108 * boost::asio::io_service ioService;
109 * Face face1(ioService);
110 * Face face2(ioService);
111 * ...
112 *
113 * ioService.run();
114 *
115 * @param ioService A reference to boost::io_service object that should control all
116 * IO operations.
117 * @throws ConfigFile::Error on configuration file parse failure
118 * @throws Face::Error on unsupported protocol
119 */
120 explicit
121 Face(boost::asio::io_service& ioService);
122
123 /**
124 * @brief Create a new Face using TcpTransport
125 *
Jeff Thompsonfe08e5a2013-08-13 11:15:59 -0700126 * @param host The host of the NDN hub.
Alexander Afanasyev20d2c582014-01-26 15:32:51 -0800127 * @param port The port or service name of the NDN hub. If omitted. use 6363.
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -0600128 * @throws Face::Error on unsupported protocol
Jeff Thompsonfe08e5a2013-08-13 11:15:59 -0700129 */
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800130 Face(const std::string& host, const std::string& port = "6363");
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800131
132 /**
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700133 * @brief Create a new Face using the given Transport
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800134 * @param transport A shared_ptr to a Transport object used for communication.
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -0600135 * @throws Face::Error on unsupported protocol
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800136 */
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -0800137 explicit
138 Face(const shared_ptr<Transport>& transport);
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800139
140 /**
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700141 * @brief Create a new Face using the given Transport and IO service object
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800142 *
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700143 * @sa Face(boost::asio::io_service&)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800144 *
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -0600145 * @throws Face::Error on unsupported protocol
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800146 */
147 Face(const shared_ptr<Transport>& transport,
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700148 boost::asio::io_service& ioService);
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800149
150 /**
Alexander Afanasyev505646e2014-02-24 20:13:37 -0800151 * @brief Set controller used for prefix registration
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800152 */
Alexander Afanasyev505646e2014-02-24 20:13:37 -0800153 void
154 setController(const shared_ptr<Controller>& controller);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700155
Jeff Thompson4fe45512013-08-23 14:06:38 -0700156 /**
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800157 * @brief Express Interest
158 *
159 * @param interest A reference to the Interest. This copies the Interest.
160 * @param onData A function object to call when a matching data packet is received.
161 * @param onTimeout A function object to call if the interest times out.
162 * If onTimeout is an empty OnTimeout(), this does not use it.
163 *
Jeff Thompson11095142013-10-01 16:20:28 -0700164 * @return The pending interest ID which can be used with removePendingInterest.
Jeff Thompson4fe45512013-08-23 14:06:38 -0700165 */
Alexander Afanasyevb790d952014-01-24 12:07:53 -0800166 const PendingInterestId*
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800167 expressInterest(const Interest& interest,
168 const OnData& onData, const OnTimeout& onTimeout = OnTimeout());
Jeff Thompson4fe45512013-08-23 14:06:38 -0700169
170 /**
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800171 * @brief Express Interest using name and Interest template
172 *
173 * @param name Name of the Interest
174 * @param tmpl Interest template to fill parameters
175 * @param onData A callback to call when a matching data packet is received.
176 * @param onTimeout A callback to call if the interest times out.
177 * If onTimeout is an empty OnTimeout(), this does not use it.
178 *
Jeff Thompson11095142013-10-01 16:20:28 -0700179 * @return The pending interest ID which can be used with removePendingInterest.
Jeff Thompson7aec0252013-08-22 17:29:57 -0700180 */
Alexander Afanasyevb790d952014-01-24 12:07:53 -0800181 const PendingInterestId*
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800182 expressInterest(const Name& name,
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800183 const Interest& tmpl,
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800184 const OnData& onData, const OnTimeout& onTimeout = OnTimeout());
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700185
Jeff Thompson11095142013-10-01 16:20:28 -0700186 /**
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700187 * @brief Remove the pending interest entry with the pendingInterestId from the pending
188 * interest table.
189 *
190 * This does not affect another pending interest with a different pendingInterestId,
191 * even it if has the same interest name. If there is no entry with the
192 * pendingInterestId, do nothing.
193 *
Jeff Thompson11095142013-10-01 16:20:28 -0700194 * @param pendingInterestId The ID returned from expressInterest.
195 */
196 void
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800197 removePendingInterest(const PendingInterestId* pendingInterestId);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700198
Jeff Thompson432c8be2013-08-09 16:16:08 -0700199 /**
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700200 * @brief Register prefix with the connected NDN hub and call onInterest when a matching
201 * interest is received.
202 *
Alexander Afanasyev90164962014-03-06 08:29:59 +0000203 * @param interestFilter Interest filter (prefix part will be registered with the forwarder)
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700204 * @param onInterest A function object to call when a matching interest is received
205 *
206 * @param onRegisterFailed A function object to call if failed to retrieve the connected
207 * hub’s ID or failed to register the prefix. This calls
208 * onRegisterFailed(prefix) where prefix is the prefix given to
209 * registerPrefix.
210 *
Jeff Thompson11095142013-10-01 16:20:28 -0700211 * @return The registered prefix ID which can be used with removeRegisteredPrefix.
Jeff Thompson86507bc2013-08-23 20:51:38 -0700212 */
Alexander Afanasyevb790d952014-01-24 12:07:53 -0800213 const RegisteredPrefixId*
Alexander Afanasyev90164962014-03-06 08:29:59 +0000214 setInterestFilter(const InterestFilter& interestFilter,
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800215 const OnInterest& onInterest,
216 const OnSetInterestFilterFailed& onSetInterestFilterFailed);
Jeff Thompson11095142013-10-01 16:20:28 -0700217
218 /**
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700219 * @brief Register prefix with the connected NDN hub and call onInterest when a matching
220 * interest is received.
221 *
Alexander Afanasyev90164962014-03-06 08:29:59 +0000222 * @param interestFilter Interest filter (prefix part will be registered with the forwarder)
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700223 * @param onInterest A function object to call when a matching interest is received
224 *
225 * @param onRegisterFailed A function object to call if failed to retrieve the connected
226 * hub’s ID or failed to register the prefix. This calls
227 * onRegisterFailed(prefix) where prefix is the prefix given to
228 * registerPrefix.
229 *
230 * @param certificate A certificate under which the prefix registration command interest
231 * is signed.
232 *
233 * @return The registered prefix ID which can be used with removeRegisteredPrefix.
234 */
235 const RegisteredPrefixId*
Alexander Afanasyev90164962014-03-06 08:29:59 +0000236 setInterestFilter(const InterestFilter& interestFilter,
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700237 const OnInterest& onInterest,
238 const OnSetInterestFilterFailed& onSetInterestFilterFailed,
239 const IdentityCertificate& certificate);
240
241 /**
242 * @brief Register prefix with the connected NDN hub and call onInterest when a matching
243 * interest is received.
244 *
Alexander Afanasyev90164962014-03-06 08:29:59 +0000245 * @param interestFilter Interest filter (prefix part will be registered with the forwarder)
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700246 * @param onInterest A function object to call when a matching interest is received
247 *
248 * @param onRegisterFailed A function object to call if failed to retrieve the connected
249 * hub’s ID or failed to register the prefix. This calls
250 * onRegisterFailed(prefix) where prefix is the prefix given to
251 * registerPrefix.
252 *
253 * @param identity A signing identity. A command interest is signed under the default
254 * certificate of this identity.
255 *
256 * @return The registered prefix ID which can be used with removeRegisteredPrefix.
257 */
258 const RegisteredPrefixId*
Alexander Afanasyev90164962014-03-06 08:29:59 +0000259 setInterestFilter(const InterestFilter& interestFilter,
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700260 const OnInterest& onInterest,
261 const OnSetInterestFilterFailed& onSetInterestFilterFailed,
262 const Name& identity);
263
264 /**
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700265 * @brief Remove the registered prefix entry with the registeredPrefixId from the
266 * pending interest table.
267 *
268 * This does not affect another registered prefix with a different registeredPrefixId,
269 * even it if has the same prefix name. If there is no entry with the
270 * registeredPrefixId, do nothing.
271 *
Jeff Thompson11095142013-10-01 16:20:28 -0700272 * @param registeredPrefixId The ID returned from registerPrefix.
273 */
274 void
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800275 unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId);
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800276
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700277 void
278 unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId,
279 const IdentityCertificate& certificate);
280
281 void
282 unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId,
283 const Name& identity);
284
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800285 /**
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800286 * @brief Publish data packet
287 *
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700288 * This method can be called to satisfy the incoming Interest or to put Data packet into
289 * the cache of the local NDN forwarder
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800290 */
291 void
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800292 put(const Data& data);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700293
Jeff Thompson86507bc2013-08-23 20:51:38 -0700294 /**
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700295 * @brief Process any data to receive or call timeout callbacks.
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800296 *
297 * This call will block forever (default timeout == 0) to process IO on the face.
298 * To exit, one expected to call face.shutdown() from one of the callback methods.
299 *
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700300 * If positive timeout is specified, then processEvents will exit after this timeout, if
301 * not stopped earlier with face.shutdown() or when all active events finish. The call
302 * can be called repeatedly, if desired.
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800303 *
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700304 * If negative timeout is specified, then processEvents will not block and process only
305 * pending events.
Alexander Afanasyevf75a0aa2014-01-09 14:29:22 -0800306 *
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700307 * @param timeout maximum time to block the thread.
308 * @param keepThread Keep thread in a blocked state (in event processing), even when
309 * there are no outstanding events (e.g., no Interest/Data is expected)
310 *
311 * @throw This may throw an exception for reading data or in the callback for processing
312 * the data. If you call this from an main event loop, you may want to catch and
313 * log/disregard all exceptions.
Jeff Thompson432c8be2013-08-09 16:16:08 -0700314 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700315 void
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -0700316 processEvents(const time::milliseconds& timeout = time::milliseconds::zero(),
317 bool keepThread = false);
Jeff Thompson432c8be2013-08-09 16:16:08 -0700318
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700319 /**
320 * @brief Shutdown face operations
321 *
322 * This method cancels all pending operations and closes connection to NDN Forwarder.
323 *
324 * Note that this method does not stop IO service and if the same IO service is shared
325 * between multiple Faces or with other IO objects (e.g., Scheduler).
326 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700327 void
Jeff Thompson0050abe2013-09-17 12:50:25 -0700328 shutdown();
Yingdi Yu0d920812014-01-30 14:50:57 -0800329
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700330 /**
331 * @brief Get shared_ptr of the IO service object
332 *
333 * @deprecated Use getIoService instead
334 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700335 shared_ptr<boost::asio::io_service>
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700336 ioService()
337 {
338 return m_ioService;
339 }
340
341 /**
342 * @brief Get reference to IO service object
343 */
344 boost::asio::io_service&
345 getIoService()
346 {
347 return *m_ioService;
348 }
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800349
350private:
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -0600351
352 /**
353 * @throws Face::Error on unsupported protocol
354 */
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800355 void
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800356 construct(const shared_ptr<Transport>& transport,
Alexander Afanasyev505646e2014-02-24 20:13:37 -0800357 const shared_ptr<boost::asio::io_service>& ioService);
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -0600358
359 bool
360 isSupportedNfdProtocol(const std::string& protocol);
361
362 bool
363 isSupportedNrdProtocol(const std::string& protocol);
364
365 bool
366 isSupportedNdndProtocol(const std::string& protocol);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700367
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700368 class ProcessEventsTimeout
369 {
370 };
371
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800372 typedef std::list<shared_ptr<PendingInterest> > PendingInterestTable;
Alexander Afanasyev90164962014-03-06 08:29:59 +0000373 typedef std::list<shared_ptr<InterestFilterRecord> > InterestFilterTable;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800374 typedef std::list<shared_ptr<RegisteredPrefix> > RegisteredPrefixTable;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700375
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800376 void
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800377 asyncExpressInterest(const shared_ptr<const Interest>& interest,
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800378 const OnData& onData, const OnTimeout& onTimeout);
379
380 void
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800381 asyncRemovePendingInterest(const PendingInterestId* pendingInterestId);
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800382
383 void
Alexander Afanasyev90164962014-03-06 08:29:59 +0000384 afterPrefixRegistered(const shared_ptr<RegisteredPrefix>& registeredPrefix);
385
386 void
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800387 asyncUnsetInterestFilter(const RegisteredPrefixId* registeredPrefixId);
Alexander Afanasyev12dfbad2014-02-11 14:42:46 -0800388
389 void
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700390 asyncUnsetInterestFilterWithCertificate(const RegisteredPrefixId* registeredPrefixId,
391 const IdentityCertificate& certificate);
392
393 void
394 asyncUnsetInterestFilterWithIdentity(const RegisteredPrefixId* registeredPrefixId,
395 const Name& identity);
396
397 void
Alexander Afanasyev90164962014-03-06 08:29:59 +0000398 finalizeUnregisterPrefix(RegisteredPrefixTable::iterator item);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700399
400 void
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800401 onReceiveElement(const Block& wire);
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800402
Alexander Afanasyev7dced462014-03-19 15:12:32 -0700403 void
404 asyncShutdown();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700405
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800406 static void
407 fireProcessEventsTimeout(const boost::system::error_code& error);
408
Alexander Afanasyev42c81852014-02-25 21:37:26 -0800409 void
410 satisfyPendingInterests(Data& data);
411
412 void
413 processInterestFilters(Interest& interest);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700414
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800415 void
416 checkPitExpire();
Yingdi Yuf9fa52f2014-02-06 12:27:32 -0800417
Jeff Thompsonb982b6d2013-07-15 18:15:45 -0700418private:
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800419 shared_ptr<boost::asio::io_service> m_ioService;
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -0700420 shared_ptr<boost::asio::io_service::work> m_ioServiceWork; // if thread needs to be preserved
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -0700421 shared_ptr<monotonic_deadline_timer> m_pitTimeoutCheckTimer;
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800422 bool m_pitTimeoutCheckTimerActive;
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -0700423 shared_ptr<monotonic_deadline_timer> m_processEventsTimeoutTimer;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700424
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800425 shared_ptr<Transport> m_transport;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800426
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800427 PendingInterestTable m_pendingInterestTable;
Alexander Afanasyev90164962014-03-06 08:29:59 +0000428 InterestFilterTable m_interestFilterTable;
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800429 RegisteredPrefixTable m_registeredPrefixTable;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800430
431 shared_ptr<Controller> m_fwController;
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -0600432
433 ConfigFile m_config;
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -0700434};
435
Steve DiBenedettoc07b3a22014-03-19 12:32:52 -0600436inline bool
437Face::isSupportedNfdProtocol(const std::string& protocol)
438{
439 return protocol == "nfd-0.1";
440}
441
442inline bool
443Face::isSupportedNrdProtocol(const std::string& protocol)
444{
445 return protocol == "nrd-0.1";
446}
447
448inline bool
449Face::isSupportedNdndProtocol(const std::string& protocol)
450{
451 return protocol == "ndnd-tlv-0.7";
452}
453
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800454} // namespace ndn
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -0700455
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800456#endif // NDN_FACE_HPP