blob: 3f95cf901ba3eb2f92960bb804d66ad9045350c6 [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/**
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 Thompsonaa4e6db2013-07-15 17:25:23 -07005 * See COPYING for copyright and distribution information.
6 */
7
Alexander Afanasyev0222fba2014-02-09 23:16:02 -08008#include "common.hpp"
9
Alexander Afanasyev09c613f2014-01-29 00:23:58 -080010#include "face.hpp"
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070011
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080012#include "security/signature-sha256-with-rsa.hpp"
13
14#include "util/time.hpp"
15#include "util/random.hpp"
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080016#include <cstdlib>
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080017
18#include "management/ndnd-controller.hpp"
19#include "management/nfd-controller.hpp"
Jeff Thompsonb982b6d2013-07-15 18:15:45 -070020
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070021namespace ndn {
Alexander Afanasyevb790d952014-01-24 12:07:53 -080022
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080023Face::Face()
Jeff Thompsonfb29cda2013-08-24 10:26:54 -070024{
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080025 construct(shared_ptr<Transport>(new UnixTransport()),
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080026 make_shared<boost::asio::io_service>());
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080027}
28
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080029Face::Face(const shared_ptr<boost::asio::io_service> &ioService)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080030{
31 construct(shared_ptr<Transport>(new UnixTransport()),
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080032 ioService);
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080033}
34
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080035Face::Face(const std::string &host, const std::string &port/* = "6363"*/)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080036{
37 construct(shared_ptr<Transport>(new TcpTransport(host, port)),
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080038 make_shared<boost::asio::io_service>());
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080039}
40
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080041Face::Face(const shared_ptr<Transport>& transport)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080042{
43 construct(transport,
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080044 make_shared<boost::asio::io_service>());
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080045}
46
47Face::Face(const shared_ptr<Transport>& transport,
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080048 const shared_ptr<boost::asio::io_service> &ioService)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080049{
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080050 construct(transport, ioService);
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080051}
52
53void
54Face::construct(const shared_ptr<Transport>& transport,
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080055 const shared_ptr<boost::asio::io_service> &ioService)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080056{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -080057 m_pitTimeoutCheckTimerActive = false;
58 m_transport = transport;
59 m_ioService = ioService;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080060
Alexander Afanasyevf39c5372014-02-17 19:42:56 -080061 m_pitTimeoutCheckTimer = make_shared<boost::asio::deadline_timer>(boost::ref(*m_ioService));
62 m_processEventsTimeoutTimer = make_shared<boost::asio::deadline_timer>(boost::ref(*m_ioService));
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -080063
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080064 if (std::getenv("NFD") != 0)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080065 m_fwController = make_shared<nfd::Controller>(boost::ref(*this));
Jeff Thompsonfb29cda2013-08-24 10:26:54 -070066 else
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080067 m_fwController = make_shared<ndnd::Controller>(boost::ref(*this));
68}
69
70
71const PendingInterestId*
72Face::expressInterest(const Interest& interest, const OnData& onData, const OnTimeout& onTimeout)
73{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -080074 if (!m_transport->isConnected())
75 m_transport->connect(*m_ioService,
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080076 bind(&Face::onReceiveElement, this, _1));
77
78 shared_ptr<const Interest> interestToExpress(new Interest(interest));
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -080079
Alexander Afanasyevf39c5372014-02-17 19:42:56 -080080 m_ioService->post(bind(&Face::asyncExpressInterest, this, interestToExpress, onData, onTimeout));
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -080081
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080082 return reinterpret_cast<const PendingInterestId*>(interestToExpress.get());
83}
84
85const PendingInterestId*
86Face::expressInterest(const Name& name,
87 const Interest &tmpl,
88 const OnData& onData, const OnTimeout& onTimeout/* = OnTimeout()*/)
89{
90 return expressInterest(Interest(name,
91 tmpl.getMinSuffixComponents(),
92 tmpl.getMaxSuffixComponents(),
93 tmpl.getExclude(),
94 tmpl.getChildSelector(),
95 tmpl.getMustBeFresh(),
96 tmpl.getScope(),
97 tmpl.getInterestLifetime()),
98 onData, onTimeout);
99}
100
101void
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800102Face::asyncExpressInterest(const shared_ptr<const Interest>& interest,
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800103 const OnData& onData, const OnTimeout& onTimeout)
104{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800105 m_pendingInterestTable.push_back(shared_ptr<PendingInterest>(new PendingInterest
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800106 (interest, onData, onTimeout)));
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800107
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800108 m_transport->send(interest->getLocalControlHeader().wireEncode(*interest));
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800109
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800110 if (!m_pitTimeoutCheckTimerActive) {
111 m_pitTimeoutCheckTimerActive = true;
112 m_pitTimeoutCheckTimer->expires_from_now(boost::posix_time::milliseconds(100));
113 m_pitTimeoutCheckTimer->async_wait(bind(&Face::checkPitExpire, this));
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800114 }
115}
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800116
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800117void
118Face::put(const Data &data)
119{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800120 if (!m_transport->isConnected())
121 m_transport->connect(*m_ioService,
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800122 bind(&Face::onReceiveElement, this, _1));
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800123
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800124 m_transport->send(data.getLocalControlHeader().wireEncode(data));
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800125}
126
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800127void
128Face::removePendingInterest(const PendingInterestId *pendingInterestId)
129{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800130 m_ioService->post(bind(&Face::asyncRemovePendingInterest, this, pendingInterestId));
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800131}
132
133
134void
135Face::asyncRemovePendingInterest(const PendingInterestId *pendingInterestId)
136{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800137 m_pendingInterestTable.remove_if(MatchPendingInterestId(pendingInterestId));
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800138}
139
140const RegisteredPrefixId*
141Face::setInterestFilter(const Name& prefix,
142 const OnInterest& onInterest,
143 const OnSetInterestFilterFailed& onSetInterestFilterFailed)
144{
145 shared_ptr<RegisteredPrefix> prefixToRegister(new RegisteredPrefix(prefix, onInterest));
146
147 m_fwController->selfRegisterPrefix(prefixToRegister->getPrefix(),
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800148 bind(&RegisteredPrefixTable::push_back, &m_registeredPrefixTable, prefixToRegister),
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800149 bind(onSetInterestFilterFailed, prefixToRegister->getPrefix(), _1));
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800150
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800151 return reinterpret_cast<const RegisteredPrefixId*>(prefixToRegister.get());
152}
153
154void
155Face::unsetInterestFilter(const RegisteredPrefixId *registeredPrefixId)
156{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800157 m_ioService->post(bind(&Face::asyncUnsetInterestFilter, this, registeredPrefixId));
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800158}
159
160void
161Face::asyncUnsetInterestFilter(const RegisteredPrefixId *registeredPrefixId)
162{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800163 RegisteredPrefixTable::iterator i = std::find_if(m_registeredPrefixTable.begin(), m_registeredPrefixTable.end(),
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800164 MatchRegisteredPrefixId(registeredPrefixId));
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800165 if (i != m_registeredPrefixTable.end())
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800166 {
167 m_fwController->selfDeregisterPrefix((*i)->getPrefix(),
Alexander Afanasyev12dfbad2014-02-11 14:42:46 -0800168 bind(&Face::finalizeUnsertInterestFilter, this, i),
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800169 Controller::FailCallback());
170 }
171
172 // there cannot be two registered prefixes with the same id. if there are, then something is broken
173}
174
Alexander Afanasyev12dfbad2014-02-11 14:42:46 -0800175void
176Face::finalizeUnsertInterestFilter(RegisteredPrefixTable::iterator item)
177{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800178 m_registeredPrefixTable.erase(item);
Alexander Afanasyev12dfbad2014-02-11 14:42:46 -0800179
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800180 if (!m_pitTimeoutCheckTimerActive && m_registeredPrefixTable.empty())
Alexander Afanasyev12dfbad2014-02-11 14:42:46 -0800181 {
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800182 m_transport->close();
183 if (!m_ioServiceWork) {
184 m_processEventsTimeoutTimer->cancel();
Alexander Afanasyev12dfbad2014-02-11 14:42:46 -0800185 }
186 }
187}
188
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800189void
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800190Face::processEvents(Milliseconds timeout/* = 0 */, bool keepThread/* = false*/)
191{
192 try
193 {
194 if (timeout < 0)
195 {
196 // do not block if timeout is negative, but process pending events
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800197 m_ioService->poll();
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800198 return;
199 }
200
201 if (timeout > 0)
202 {
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800203 m_processEventsTimeoutTimer->expires_from_now(boost::posix_time::milliseconds(timeout));
204 m_processEventsTimeoutTimer->async_wait(&fireProcessEventsTimeout);
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800205 }
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800206
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800207 if (keepThread) {
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800208 // work will ensure that m_ioService is running until work object exists
209 m_ioServiceWork = make_shared<boost::asio::io_service::work>(boost::ref(*m_ioService));
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800210 }
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800211
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800212 m_ioService->run();
213 m_ioService->reset(); // so it is possible to run processEvents again (if necessary)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800214 }
215 catch(Face::ProcessEventsTimeout &)
216 {
217 // break
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800218 m_ioService->reset();
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800219 }
220 catch(const std::exception &)
221 {
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800222 m_ioService->reset();
223 m_pendingInterestTable.clear();
224 m_registeredPrefixTable.clear();
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800225 throw;
226 }
Jeff Thompsonfb29cda2013-08-24 10:26:54 -0700227}
228
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800229void
Jeff Thompson0050abe2013-09-17 12:50:25 -0700230Face::shutdown()
Jeff Thompson517ffa82013-08-05 16:04:34 -0700231{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800232 m_pendingInterestTable.clear();
233 m_registeredPrefixTable.clear();
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800234
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800235 m_transport->close();
236 m_pitTimeoutCheckTimer->cancel();
237 m_processEventsTimeoutTimer->cancel();
238 m_pitTimeoutCheckTimerActive = false;
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -0700239}
240
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800241void
242Face::fireProcessEventsTimeout(const boost::system::error_code& error)
243{
244 if (!error) // can fire for some other reason, e.g., cancelled
245 throw Face::ProcessEventsTimeout();
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -0700246}
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800247
248void
249Face::checkPitExpire()
250{
251 // Check for PIT entry timeouts. Go backwards through the list so we can erase entries.
252 MillisecondsSince1970 nowMilliseconds = getNowMilliseconds();
253
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800254 PendingInterestTable::iterator i = m_pendingInterestTable.begin();
255 while (i != m_pendingInterestTable.end())
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800256 {
257 if ((*i)->isTimedOut(nowMilliseconds))
258 {
259 // Save the PendingInterest and remove it from the PIT. Then call the callback.
260 shared_ptr<PendingInterest> pendingInterest = *i;
261
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800262 i = m_pendingInterestTable.erase(i);
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800263
264 pendingInterest->callTimeout();
265 }
266 else
267 ++i;
268 }
269
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800270 if (!m_pendingInterestTable.empty()) {
271 m_pitTimeoutCheckTimerActive = true;
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800272
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800273 m_pitTimeoutCheckTimer->expires_from_now(boost::posix_time::milliseconds(100));
274 m_pitTimeoutCheckTimer->async_wait(bind(&Face::checkPitExpire, this));
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800275 }
276 else {
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800277 m_pitTimeoutCheckTimerActive = false;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800278
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800279 if (m_registeredPrefixTable.empty()) {
280 m_transport->close();
281 if (!m_ioServiceWork) {
282 m_processEventsTimeoutTimer->cancel();
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800283 }
284 }
285 }
286}
287
288
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800289void
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800290Face::onReceiveElement(const Block& blockFromDaemon)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800291{
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800292 const Block& block = nfd::LocalControlHeader::getPayload(blockFromDaemon);
293
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800294 if (block.type() == Tlv::Interest)
295 {
296 shared_ptr<Interest> interest(new Interest());
297 interest->wireDecode(block);
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800298 if (&block != &blockFromDaemon)
299 interest->getLocalControlHeader().wireDecode(blockFromDaemon);
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800300
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800301 RegisteredPrefixTable::iterator entry = getEntryForRegisteredPrefix(interest->getName());
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800302 if (entry != m_registeredPrefixTable.end()) {
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800303 (*entry)->getOnInterest()((*entry)->getPrefix(), *interest);
304 }
305 }
306 else if (block.type() == Tlv::Data)
307 {
308 shared_ptr<Data> data(new Data());
309 data->wireDecode(block);
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800310 if (&block != &blockFromDaemon)
311 data->getLocalControlHeader().wireDecode(blockFromDaemon);
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800312
313 PendingInterestTable::iterator entry = getEntryIndexForExpressedInterest(data->getName());
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800314 if (entry != m_pendingInterestTable.end()) {
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800315 // Copy pointers to the needed objects and remove the PIT entry before the calling the callback.
316 const OnData onData = (*entry)->getOnData();
317 const shared_ptr<const Interest> interest = (*entry)->getInterest();
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800318 m_pendingInterestTable.erase(entry);
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800319
320 if (onData) {
321 onData(*interest, *data);
322 }
323
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800324 if (m_pendingInterestTable.empty()) {
325 m_pitTimeoutCheckTimer->cancel(); // this will cause checkPitExpire invocation
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800326 }
327 }
328 }
Yingdi Yuf9fa52f2014-02-06 12:27:32 -0800329 // ignore any other type
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800330}
331
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800332Face::PendingInterestTable::iterator
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800333Face::getEntryIndexForExpressedInterest(const Name& name)
334{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800335 for (PendingInterestTable::iterator i = m_pendingInterestTable.begin ();
336 i != m_pendingInterestTable.end(); ++i)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800337 {
338 if ((*i)->getInterest()->matchesName(name))
339 {
340 return i;
341 }
342 }
343
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800344 return m_pendingInterestTable.end();
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800345}
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800346
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800347Face::RegisteredPrefixTable::iterator
348Face::getEntryForRegisteredPrefix(const Name& name)
349{
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800350 RegisteredPrefixTable::iterator longestPrefix = m_registeredPrefixTable.end();
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800351
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800352 for (RegisteredPrefixTable::iterator i = m_registeredPrefixTable.begin();
353 i != m_registeredPrefixTable.end();
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800354 ++i)
355 {
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800356 if ((*i)->getPrefix().isPrefixOf(name))
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800357 {
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800358
Alexander Afanasyevf39c5372014-02-17 19:42:56 -0800359 if (longestPrefix == m_registeredPrefixTable.end() ||
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800360 (*i)->getPrefix().size() > (*longestPrefix)->getPrefix().size())
361 {
362 longestPrefix = i;
363 }
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800364 }
365 }
366 return longestPrefix;
367}
368
369} // namespace ndn