blob: 910685bb617df23e98a9190487adf170bf301d62 [file] [log] [blame]
Jeff Thompson25b4e612013-10-10 16:03:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -07002/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07003 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -07005 * See COPYING for copyright and distribution information.
6 */
7
Jeff Thompsonea141d72013-09-19 14:40:10 -07008#include <stdexcept>
Jeff Thompson9ae4d782013-10-17 10:25:54 -07009#include "c/util/time.h"
Alexander Afanasyev96d914f2014-01-02 22:24:29 -080010
Jeff Thompson25b4e612013-10-10 16:03:24 -070011#include <ndn-cpp/forwarding-entry.hpp>
Jeff Thompson25b4e612013-10-10 16:03:24 -070012#include <ndn-cpp/node.hpp>
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -070013
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080014#include "util/ndnd-id-fetcher.hpp"
Alexander Afanasyev79100492014-01-03 15:35:38 -080015#include "security/signature/signature-sha256-with-rsa.hpp"
Alexander Afanasyev96d914f2014-01-02 22:24:29 -080016
Alexander Afanasyev18371872014-01-05 23:00:26 -080017#include "status-response.hpp"
18
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -070019using namespace std;
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -070020
21namespace ndn {
22
Jeff Thompson62992e42013-10-07 18:50:51 -070023uint64_t Node::PendingInterest::lastPendingInterestId_ = 0;
24uint64_t Node::RegisteredPrefix::lastRegisteredPrefixId_ = 0;
Jeff Thompson11095142013-10-01 16:20:28 -070025
Alexander Afanasyev0b688dc2013-12-18 16:43:37 -080026Node::Node(const ptr_lib::shared_ptr<Transport>& transport)
Alexander Afanasyeve1b7a5d2013-12-29 16:23:52 -080027 : transport_(transport)
28 , ndndIdFetcherInterest_(Name("/%C1.M.S.localhost/%C1.M.SRV/ndnd/KEY"), 4000.0)
29{
30 ioService_ = ptr_lib::make_shared<boost::asio::io_service>();
31 pitTimeoutCheckTimer_ = ptr_lib::make_shared<boost::asio::deadline_timer>(boost::ref(*ioService_));
32 processEventsTimeoutTimer_ = ptr_lib::make_shared<boost::asio::deadline_timer>(boost::ref(*ioService_));
33
34 pitTimeoutCheckTimer_->expires_from_now(boost::posix_time::milliseconds(100));
35 pitTimeoutCheckTimer_->async_wait(func_lib::bind(&Node::checkPitExpire, this));
36}
37
38Node::Node(const ptr_lib::shared_ptr<Transport>& transport, const ptr_lib::shared_ptr<boost::asio::io_service> &ioService)
39 : ioService_(ioService)
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080040 , transport_(transport)
41 , ndndIdFetcherInterest_(Name("/%C1.M.S.localhost/%C1.M.SRV/ndnd/KEY"), 4000.0)
Jeff Thompson557b81e2013-08-21 15:13:51 -070042{
Alexander Afanasyeve1b7a5d2013-12-29 16:23:52 -080043 pitTimeoutCheckTimer_ = ptr_lib::make_shared<boost::asio::deadline_timer>(boost::ref(*ioService_));
44 processEventsTimeoutTimer_ = ptr_lib::make_shared<boost::asio::deadline_timer>(boost::ref(*ioService_));
45
46 pitTimeoutCheckTimer_->expires_from_now(boost::posix_time::milliseconds(100));
47 pitTimeoutCheckTimer_->async_wait(func_lib::bind(&Node::checkPitExpire, this));
Jeff Thompson557b81e2013-08-21 15:13:51 -070048}
49
Jeff Thompson62992e42013-10-07 18:50:51 -070050uint64_t
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080051Node::expressInterest(const Interest& interest, const OnData& onData, const OnTimeout& onTimeout)
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -070052{
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080053 if (!transport_->isConnected())
Alexander Afanasyeve1b7a5d2013-12-29 16:23:52 -080054 transport_->connect(*ioService_,
Alexander Afanasyev3ae2da22013-12-29 15:50:04 -080055 ptr_lib::bind(&Node::onReceiveElement, this, _1));
Jeff Thompson86507bc2013-08-23 20:51:38 -070056
Jeff Thompson62992e42013-10-07 18:50:51 -070057 uint64_t pendingInterestId = PendingInterest::getNextPendingInterestId();
Jeff Thompsonce115762013-12-18 14:59:56 -080058 pendingInterestTable_.push_back(ptr_lib::shared_ptr<PendingInterest>(new PendingInterest
59 (pendingInterestId, ptr_lib::shared_ptr<const Interest>(new Interest(interest)), onData, onTimeout)));
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080060
61 transport_->send(interest.wireEncode());
Jeff Thompson11095142013-10-01 16:20:28 -070062
63 return pendingInterestId;
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -070064}
65
Jeff Thompson11095142013-10-01 16:20:28 -070066void
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -080067Node::put(const Data &data)
68{
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -080069 if (!transport_->isConnected())
Alexander Afanasyeve1b7a5d2013-12-29 16:23:52 -080070 transport_->connect(*ioService_,
Alexander Afanasyev3ae2da22013-12-29 15:50:04 -080071 ptr_lib::bind(&Node::onReceiveElement, this, _1));
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -080072
73 transport_->send(data.wireEncode());
74}
75
76
77void
Jeff Thompson62992e42013-10-07 18:50:51 -070078Node::removePendingInterest(uint64_t pendingInterestId)
Jeff Thompson11095142013-10-01 16:20:28 -070079{
80 // Go backwards through the list so we can erase entries.
81 // Remove all entries even though pendingInterestId should be unique.
82 for (int i = (int)pendingInterestTable_.size() - 1; i >= 0; --i) {
83 if (pendingInterestTable_[i]->getPendingInterestId() == pendingInterestId)
84 pendingInterestTable_.erase(pendingInterestTable_.begin() + i);
85 }
86}
87
Jeff Thompson62992e42013-10-07 18:50:51 -070088uint64_t
Jeff Thompson590ec232013-09-18 15:55:56 -070089Node::registerPrefix
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080090 (const Name& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, const ForwardingFlags& flags)
Jeff Thompson86507bc2013-08-23 20:51:38 -070091{
Jeff Thompson11095142013-10-01 16:20:28 -070092 // Get the registeredPrefixId now so we can return it to the caller.
Jeff Thompson62992e42013-10-07 18:50:51 -070093 uint64_t registeredPrefixId = RegisteredPrefix::getNextRegisteredPrefixId();
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080094 ptr_lib::shared_ptr<const Name> prefixPtr = ptr_lib::make_shared<const Name>(prefix);
95
Jeff Thompson86507bc2013-08-23 20:51:38 -070096 if (ndndId_.size() == 0) {
97 // First fetch the ndndId of the connected hub.
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080098 NdndIdFetcher fetcher(ndndId_,
99 func_lib::bind(&Node::registerPrefixHelper, this,
100 registeredPrefixId, prefixPtr, onInterest, onRegisterFailed, flags),
101 func_lib::bind(onRegisterFailed, prefixPtr));
102
103 // @todo: Check if this crash
Jeff Thompsonce115762013-12-18 14:59:56 -0800104 // It is OK for func_lib::function make a copy of the function object because the Info is in a ptr_lib::shared_ptr.
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800105 expressInterest(ndndIdFetcherInterest_, fetcher, fetcher);
Jeff Thompson86507bc2013-08-23 20:51:38 -0700106 }
107 else
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800108 registerPrefixHelper(registeredPrefixId, prefixPtr, onInterest, onRegisterFailed, flags);
Jeff Thompson11095142013-10-01 16:20:28 -0700109
110 return registeredPrefixId;
111}
112
113void
Jeff Thompson62992e42013-10-07 18:50:51 -0700114Node::removeRegisteredPrefix(uint64_t registeredPrefixId)
Jeff Thompson11095142013-10-01 16:20:28 -0700115{
116 // Go backwards through the list so we can erase entries.
117 // Remove all entries even though pendingInterestId should be unique.
118 for (int i = (int)registeredPrefixTable_.size() - 1; i >= 0; --i) {
119 if (registeredPrefixTable_[i]->getRegisteredPrefixId() == registeredPrefixId)
120 registeredPrefixTable_.erase(registeredPrefixTable_.begin() + i);
121 }
Jeff Thompson86507bc2013-08-23 20:51:38 -0700122}
123
Jeff Thompson0050abe2013-09-17 12:50:25 -0700124void
Alexander Afanasyev79100492014-01-03 15:35:38 -0800125Node::registerPrefixHelper(uint64_t registeredPrefixId,
126 const ptr_lib::shared_ptr<const Name>& prefix,
127 const OnInterest& onInterest,
128 const OnRegisterFailed& onRegisterFailed,
129 const ForwardingFlags& flags)
Jeff Thompson86507bc2013-08-23 20:51:38 -0700130{
Jeff Thompson9cc4be42013-08-27 18:12:41 -0700131 // Create a ForwardingEntry.
Alexander Afanasyevfbdfa092013-12-28 20:44:49 -0800132
133 // AlexA: ndnd ignores any freshness that is larger than 3600 sec and sets 300 sec instead
134 // to register "forever" (=2000000000 sec), freshnessPeriod must be omitted
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800135 ForwardingEntry forwardingEntry("selfreg", *prefix, -1, flags, -1);
136 Block content = forwardingEntry.wireEncode();
Jeff Thompson9cc4be42013-08-27 18:12:41 -0700137
138 // Set the ForwardingEntry as the content of a Data packet and sign.
139 Data data;
Jeff Thompsonc2b7b142013-09-12 15:29:04 -0700140 data.setContent(content);
Jeff Thompson9cc4be42013-08-27 18:12:41 -0700141
Alexander Afanasyev79100492014-01-03 15:35:38 -0800142 // Create an empty signature, since nobody going to verify it for now
143 // @todo In the future, we may require real signatures to do the registration
144 SignatureSha256WithRsa signature;
145 signature.setValue(Block(Tlv::SignatureValue, ptr_lib::make_shared<Buffer>()));
146 data.setSignature(signature);
147
Jeff Thompson9cc4be42013-08-27 18:12:41 -0700148 // Create an interest where the name has the encoded Data packet.
149 Name interestName;
Alexander Afanasyev18371872014-01-05 23:00:26 -0800150 interestName.append("ndnx");
Jeff Thompson3a715632013-10-31 11:36:35 -0700151 interestName.append(ndndId_);
Alexander Afanasyev18371872014-01-05 23:00:26 -0800152 interestName.append("selfreg");
Alexander Afanasyev79100492014-01-03 15:35:38 -0800153 interestName.append(data.wireEncode());
Alexander Afanasyev18371872014-01-05 23:00:26 -0800154
Jeff Thompson9cc4be42013-08-27 18:12:41 -0700155 Interest interest(interestName);
156 interest.setScope(1);
Alexander Afanasyev18371872014-01-05 23:00:26 -0800157 interest.setInterestLifetime(1000);
158
159 expressInterest(interest,
160 func_lib::bind(&Node::registerPrefixFinal, this,
161 registeredPrefixId, prefix, onInterest, onRegisterFailed, _1, _2),
162 func_lib::bind(onRegisterFailed, prefix));
163}
164
165void
166Node::registerPrefixFinal(uint64_t registeredPrefixId,
167 const ptr_lib::shared_ptr<const Name>& prefix,
168 const OnInterest& onInterest,
169 const OnRegisterFailed& onRegisterFailed,
170 const ptr_lib::shared_ptr<const Interest>&, const ptr_lib::shared_ptr<Data>&data)
171{
172 Block content = data->getContent();
173 content.parse();
174
175 if (content.getAll().empty())
176 {
177 onRegisterFailed(prefix);
178 return;
179 }
180
Alexander Afanasyeve0c02f52013-12-28 20:44:25 -0800181 Block::element_iterator val = content.getAll().begin();
182
183 switch(val->type())
Alexander Afanasyev18371872014-01-05 23:00:26 -0800184 {
185 case Tlv::FaceManagement::ForwardingEntry:
186 {
Alexander Afanasyeve0c02f52013-12-28 20:44:25 -0800187 ForwardingEntry entry;
188 entry.wireDecode(*val);
189
190 // Save the onInterest callback and send the registration interest.
191 registeredPrefixTable_.push_back(ptr_lib::make_shared<RegisteredPrefix>(registeredPrefixId, prefix, onInterest));
192
193 /// @todo Notify user about successful registration
194
Alexander Afanasyev18371872014-01-05 23:00:26 -0800195 // succeeded
Alexander Afanasyeve0c02f52013-12-28 20:44:25 -0800196 return;
Alexander Afanasyev18371872014-01-05 23:00:26 -0800197 }
198 case Tlv::FaceManagement::StatusResponse:
199 {
200 // failed :(
201 StatusResponse resp;
Alexander Afanasyeve0c02f52013-12-28 20:44:25 -0800202 resp.wireDecode(*val);
Alexander Afanasyev18371872014-01-05 23:00:26 -0800203
204 std::cerr << "StatusReponse: " << resp << std::endl;
205
206 onRegisterFailed(prefix);
207 return;
Alexander Afanasyev18371872014-01-05 23:00:26 -0800208 }
209 default:
210 {
211 // failed :(
212
213 onRegisterFailed(prefix);
214 return;
Alexander Afanasyev18371872014-01-05 23:00:26 -0800215 }
216 }
Jeff Thompson86507bc2013-08-23 20:51:38 -0700217}
218
Jeff Thompson0050abe2013-09-17 12:50:25 -0700219void
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800220Node::processEvents(Milliseconds timeout/* = 0 */)
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -0700221{
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800222 if (timeout > 0)
223 {
Alexander Afanasyeve1b7a5d2013-12-29 16:23:52 -0800224 processEventsTimeoutTimer_->expires_from_now(boost::posix_time::milliseconds(timeout));
225 processEventsTimeoutTimer_->async_wait(fireProcessEventsTimeout);
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800226 }
227 try
228 {
Alexander Afanasyeve1b7a5d2013-12-29 16:23:52 -0800229 ioService_->run();
230 ioService_->reset();
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800231 }
Alexander Afanasyev3ae2da22013-12-29 15:50:04 -0800232 catch(Node::ProcessEventsTimeout &)
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800233 {
Alexander Afanasyev3ae2da22013-12-29 15:50:04 -0800234 // break
Alexander Afanasyeva557d5a2013-12-28 21:59:03 -0800235 }
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800236}
237
238void
Alexander Afanasyev3ae2da22013-12-29 15:50:04 -0800239Node::fireProcessEventsTimeout(const boost::system::error_code& error)
240{
241 if (!error) // can fire for some other reason, e.g., cancelled
242 throw Node::ProcessEventsTimeout();
243}
244
245void
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800246Node::checkPitExpire()
247{
Jeff Thompson48917f02013-08-21 17:12:45 -0700248 // Check for PIT entry timeouts. Go backwards through the list so we can erase entries.
Jeff Thompson9a8e82f2013-10-17 14:13:43 -0700249 MillisecondsSince1970 nowMilliseconds = ndn_getNowMilliseconds();
Jeff Thompson11095142013-10-01 16:20:28 -0700250 for (int i = (int)pendingInterestTable_.size() - 1; i >= 0; --i) {
Jeff Thompson3b0ed532013-11-05 13:43:40 -0800251 if (pendingInterestTable_[i]->isTimedOut(nowMilliseconds)) {
252 // Save the PendingInterest and remove it from the PIT. Then call the callback.
Jeff Thompsonce115762013-12-18 14:59:56 -0800253 ptr_lib::shared_ptr<PendingInterest> pendingInterest = pendingInterestTable_[i];
Jeff Thompson11095142013-10-01 16:20:28 -0700254 pendingInterestTable_.erase(pendingInterestTable_.begin() + i);
Jeff Thompson3b0ed532013-11-05 13:43:40 -0800255 pendingInterest->callTimeout();
Jeff Thompson48917f02013-08-21 17:12:45 -0700256
257 // Refresh now since the timeout callback might have delayed.
Jeff Thompson9ae4d782013-10-17 10:25:54 -0700258 nowMilliseconds = ndn_getNowMilliseconds();
Jeff Thompson48917f02013-08-21 17:12:45 -0700259 }
260 }
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800261
Alexander Afanasyeve1b7a5d2013-12-29 16:23:52 -0800262 pitTimeoutCheckTimer_->expires_from_now(boost::posix_time::milliseconds(100));
263 pitTimeoutCheckTimer_->async_wait(func_lib::bind(&Node::checkPitExpire, this));
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -0700264}
265
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800266
Jeff Thompson0050abe2013-09-17 12:50:25 -0700267void
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800268Node::onReceiveElement(const Block &block)
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -0700269{
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800270 if (block.type() == Tlv::Interest)
Alexander Afanasyev96d914f2014-01-02 22:24:29 -0800271 {
272 ptr_lib::shared_ptr<Interest> interest(new Interest());
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800273 interest->wireDecode(block);
Jeff Thompson9cc4be42013-08-27 18:12:41 -0700274
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800275 RegisteredPrefixTable::iterator entry = getEntryForRegisteredPrefix(interest->getName());
276 if (entry != registeredPrefixTable_.end()) {
277 (*entry)->getOnInterest()((*entry)->getPrefix(), interest, *transport_, (*entry)->getRegisteredPrefixId());
278 }
Jeff Thompson557b81e2013-08-21 15:13:51 -0700279 }
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800280 else if (block.type() == Tlv::Data)
Alexander Afanasyev96d914f2014-01-02 22:24:29 -0800281 {
282 ptr_lib::shared_ptr<Data> data(new Data());
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800283 data->wireDecode(block);
284
285 PendingInterestTable::iterator entry = getEntryIndexForExpressedInterest(data->getName());
286 if (entry != pendingInterestTable_.end()) {
Alexander Afanasyev96d914f2014-01-02 22:24:29 -0800287 // Copy pointers to the needed objects and remove the PIT entry before the calling the callback.
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800288 const OnData onData = (*entry)->getOnData();
289 const ptr_lib::shared_ptr<const Interest> interest = (*entry)->getInterest();
290 pendingInterestTable_.erase(entry);
Alexander Afanasyev96d914f2014-01-02 22:24:29 -0800291 onData(interest, data);
292 }
293 }
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -0700294}
295
Jeff Thompson0050abe2013-09-17 12:50:25 -0700296void
297Node::shutdown()
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -0700298{
299 transport_->close();
Alexander Afanasyeve1b7a5d2013-12-29 16:23:52 -0800300 ioService_->stop();
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -0700301}
302
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800303Node::PendingInterestTable::iterator
Jeff Thompson0050abe2013-09-17 12:50:25 -0700304Node::getEntryIndexForExpressedInterest(const Name& name)
Jeff Thompson557b81e2013-08-21 15:13:51 -0700305{
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800306 for (PendingInterestTable::iterator i = pendingInterestTable_.begin ();
307 i != pendingInterestTable_.end(); ++i)
308 {
309 if ((*i)->getInterest()->matchesName(name))
310 {
311 return i;
312 }
Jeff Thompson557b81e2013-08-21 15:13:51 -0700313 }
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800314
315 return pendingInterestTable_.end();
Jeff Thompson557b81e2013-08-21 15:13:51 -0700316}
Jeff Thompson86507bc2013-08-23 20:51:38 -0700317
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800318Node::RegisteredPrefixTable::iterator
Jeff Thompson0050abe2013-09-17 12:50:25 -0700319Node::getEntryForRegisteredPrefix(const Name& name)
Jeff Thompson9cc4be42013-08-27 18:12:41 -0700320{
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800321 RegisteredPrefixTable::iterator longestPrefix = registeredPrefixTable_.end();
322
323 for (RegisteredPrefixTable::iterator i = registeredPrefixTable_.begin();
324 i != registeredPrefixTable_.end();
325 ++i)
326 {
327 if (longestPrefix == registeredPrefixTable_.end() ||
328 (*i)->getPrefix()->size() > (*longestPrefix)->getPrefix()->size())
329 {
330 longestPrefix = i;
331 }
Jeff Thompson9cc4be42013-08-27 18:12:41 -0700332 }
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800333 return longestPrefix;
Jeff Thompson9cc4be42013-08-27 18:12:41 -0700334}
335
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800336Node::PendingInterest::PendingInterest(uint64_t pendingInterestId,
337 const ptr_lib::shared_ptr<const Interest>& interest,
338 const OnData& onData, const OnTimeout& onTimeout)
339: pendingInterestId_(pendingInterestId),
340 interest_(interest),
341 onData_(onData), onTimeout_(onTimeout)
Jeff Thompson86507bc2013-08-23 20:51:38 -0700342{
343 // Set up timeoutTime_.
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -0800344 if (interest_->getInterestLifetime() >= 0)
345 timeoutTimeMilliseconds_ = ndn_getNowMilliseconds() + interest_->getInterestLifetime();
Jeff Thompson86507bc2013-08-23 20:51:38 -0700346 else
347 // No timeout.
Alexander Afanasyevb24a68a2013-12-28 16:53:21 -0800348 /**
349 * @todo Set more meaningful default timeout. This timeout MUST exist.
350 */
351 timeoutTimeMilliseconds_ = ndn_getNowMilliseconds() + 4000;
Jeff Thompson86507bc2013-08-23 20:51:38 -0700352}
353
Jeff Thompson3b0ed532013-11-05 13:43:40 -0800354void
355Node::PendingInterest::callTimeout()
Jeff Thompson86507bc2013-08-23 20:51:38 -0700356{
Jeff Thompson3b0ed532013-11-05 13:43:40 -0800357 if (onTimeout_) {
358 // Ignore all exceptions.
359 try {
360 onTimeout_(interest_);
Jeff Thompson86507bc2013-08-23 20:51:38 -0700361 }
Jeff Thompson3b0ed532013-11-05 13:43:40 -0800362 catch (...) { }
Jeff Thompson86507bc2013-08-23 20:51:38 -0700363 }
Jeff Thompson86507bc2013-08-23 20:51:38 -0700364}
Jeff Thompson557b81e2013-08-21 15:13:51 -0700365
Jeff Thompsonbf50a1a2013-08-20 18:01:01 -0700366}