Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 2 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 5 | * See COPYING for copyright and distribution information. |
| 6 | */ |
| 7 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 8 | #include "common.hpp" |
| 9 | |
Alexander Afanasyev | 09c613f | 2014-01-29 00:23:58 -0800 | [diff] [blame] | 10 | #include "face.hpp" |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 11 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 12 | #include "security/signature-sha256-with-rsa.hpp" |
| 13 | |
| 14 | #include "util/time.hpp" |
| 15 | #include "util/random.hpp" |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 16 | #include <cstdlib> |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 17 | |
| 18 | #include "management/ndnd-controller.hpp" |
| 19 | #include "management/nfd-controller.hpp" |
Jeff Thompson | b982b6d | 2013-07-15 18:15:45 -0700 | [diff] [blame] | 20 | |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 21 | namespace ndn { |
Alexander Afanasyev | b790d95 | 2014-01-24 12:07:53 -0800 | [diff] [blame] | 22 | |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 23 | Face::Face() |
Jeff Thompson | fb29cda | 2013-08-24 10:26:54 -0700 | [diff] [blame] | 24 | { |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 25 | construct(shared_ptr<Transport>(new UnixTransport()), |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 26 | make_shared<boost::asio::io_service>()); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 27 | } |
| 28 | |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 29 | Face::Face(const shared_ptr<boost::asio::io_service> &ioService) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 30 | { |
| 31 | construct(shared_ptr<Transport>(new UnixTransport()), |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 32 | ioService); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 33 | } |
| 34 | |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 35 | Face::Face(const std::string &host, const std::string &port/* = "6363"*/) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 36 | { |
| 37 | construct(shared_ptr<Transport>(new TcpTransport(host, port)), |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 38 | make_shared<boost::asio::io_service>()); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 39 | } |
| 40 | |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 41 | Face::Face(const shared_ptr<Transport>& transport) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 42 | { |
| 43 | construct(transport, |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 44 | make_shared<boost::asio::io_service>()); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | Face::Face(const shared_ptr<Transport>& transport, |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 48 | const shared_ptr<boost::asio::io_service> &ioService) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 49 | { |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 50 | construct(transport, ioService); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void |
| 54 | Face::construct(const shared_ptr<Transport>& transport, |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 55 | const shared_ptr<boost::asio::io_service> &ioService) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 56 | { |
| 57 | pitTimeoutCheckTimerActive_ = false; |
| 58 | transport_ = transport; |
| 59 | ioService_ = ioService; |
| 60 | |
| 61 | pitTimeoutCheckTimer_ = make_shared<boost::asio::deadline_timer>(boost::ref(*ioService_)); |
| 62 | processEventsTimeoutTimer_ = make_shared<boost::asio::deadline_timer>(boost::ref(*ioService_)); |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 63 | |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame^] | 64 | if (std::getenv("NFD") != 0) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 65 | m_fwController = make_shared<nfd::Controller>(boost::ref(*this)); |
Jeff Thompson | fb29cda | 2013-08-24 10:26:54 -0700 | [diff] [blame] | 66 | else |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 67 | m_fwController = make_shared<ndnd::Controller>(boost::ref(*this)); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | const PendingInterestId* |
| 72 | Face::expressInterest(const Interest& interest, const OnData& onData, const OnTimeout& onTimeout) |
| 73 | { |
| 74 | if (!transport_->isConnected()) |
| 75 | transport_->connect(*ioService_, |
| 76 | bind(&Face::onReceiveElement, this, _1)); |
| 77 | |
| 78 | shared_ptr<const Interest> interestToExpress(new Interest(interest)); |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 79 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 80 | ioService_->post(bind(&Face::asyncExpressInterest, this, interestToExpress, onData, onTimeout)); |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 81 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 82 | return reinterpret_cast<const PendingInterestId*>(interestToExpress.get()); |
| 83 | } |
| 84 | |
| 85 | const PendingInterestId* |
| 86 | Face::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 | |
| 101 | void |
| 102 | Face::asyncExpressInterest(const shared_ptr<const Interest> &interest, |
| 103 | const OnData& onData, const OnTimeout& onTimeout) |
| 104 | { |
| 105 | pendingInterestTable_.push_back(shared_ptr<PendingInterest>(new PendingInterest |
| 106 | (interest, onData, onTimeout))); |
| 107 | |
| 108 | transport_->send(interest->wireEncode()); |
| 109 | |
| 110 | if (!pitTimeoutCheckTimerActive_) { |
| 111 | pitTimeoutCheckTimerActive_ = true; |
| 112 | pitTimeoutCheckTimer_->expires_from_now(boost::posix_time::milliseconds(100)); |
| 113 | pitTimeoutCheckTimer_->async_wait(bind(&Face::checkPitExpire, this)); |
| 114 | } |
| 115 | } |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 116 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 117 | void |
| 118 | Face::put(const Data &data) |
| 119 | { |
| 120 | if (!transport_->isConnected()) |
| 121 | transport_->connect(*ioService_, |
| 122 | bind(&Face::onReceiveElement, this, _1)); |
| 123 | |
| 124 | transport_->send(data.wireEncode()); |
| 125 | } |
| 126 | |
| 127 | |
| 128 | void |
| 129 | Face::removePendingInterest(const PendingInterestId *pendingInterestId) |
| 130 | { |
| 131 | ioService_->post(bind(&Face::asyncRemovePendingInterest, this, pendingInterestId)); |
| 132 | } |
| 133 | |
| 134 | |
| 135 | void |
| 136 | Face::asyncRemovePendingInterest(const PendingInterestId *pendingInterestId) |
| 137 | { |
| 138 | pendingInterestTable_.remove_if(MatchPendingInterestId(pendingInterestId)); |
| 139 | } |
| 140 | |
| 141 | const RegisteredPrefixId* |
| 142 | Face::setInterestFilter(const Name& prefix, |
| 143 | const OnInterest& onInterest, |
| 144 | const OnSetInterestFilterFailed& onSetInterestFilterFailed) |
| 145 | { |
| 146 | shared_ptr<RegisteredPrefix> prefixToRegister(new RegisteredPrefix(prefix, onInterest)); |
| 147 | |
| 148 | m_fwController->selfRegisterPrefix(prefixToRegister->getPrefix(), |
| 149 | bind(&RegisteredPrefixTable::push_back, ®isteredPrefixTable_, prefixToRegister), |
| 150 | bind(onSetInterestFilterFailed, prefixToRegister->getPrefix(), _1)); |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 151 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 152 | return reinterpret_cast<const RegisteredPrefixId*>(prefixToRegister.get()); |
| 153 | } |
| 154 | |
| 155 | void |
| 156 | Face::unsetInterestFilter(const RegisteredPrefixId *registeredPrefixId) |
| 157 | { |
| 158 | ioService_->post(bind(&Face::asyncUnsetInterestFilter, this, registeredPrefixId)); |
| 159 | } |
| 160 | |
| 161 | void |
| 162 | Face::asyncUnsetInterestFilter(const RegisteredPrefixId *registeredPrefixId) |
| 163 | { |
| 164 | RegisteredPrefixTable::iterator i = std::find_if(registeredPrefixTable_.begin(), registeredPrefixTable_.end(), |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 165 | MatchRegisteredPrefixId(registeredPrefixId)); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 166 | if (i != registeredPrefixTable_.end()) |
| 167 | { |
| 168 | m_fwController->selfDeregisterPrefix((*i)->getPrefix(), |
Alexander Afanasyev | 12dfbad | 2014-02-11 14:42:46 -0800 | [diff] [blame] | 169 | bind(&Face::finalizeUnsertInterestFilter, this, i), |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 170 | Controller::FailCallback()); |
| 171 | } |
| 172 | |
| 173 | // there cannot be two registered prefixes with the same id. if there are, then something is broken |
| 174 | } |
| 175 | |
Alexander Afanasyev | 12dfbad | 2014-02-11 14:42:46 -0800 | [diff] [blame] | 176 | void |
| 177 | Face::finalizeUnsertInterestFilter(RegisteredPrefixTable::iterator item) |
| 178 | { |
| 179 | registeredPrefixTable_.erase(item); |
| 180 | |
| 181 | if (!pitTimeoutCheckTimerActive_ && registeredPrefixTable_.empty()) |
| 182 | { |
| 183 | transport_->close(); |
| 184 | if (!ioServiceWork_) { |
| 185 | processEventsTimeoutTimer_->cancel(); |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 190 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 191 | Face::processEvents(Milliseconds timeout/* = 0 */, bool keepThread/* = false*/) |
| 192 | { |
| 193 | try |
| 194 | { |
| 195 | if (timeout < 0) |
| 196 | { |
| 197 | // do not block if timeout is negative, but process pending events |
| 198 | ioService_->poll(); |
| 199 | return; |
| 200 | } |
| 201 | |
| 202 | if (timeout > 0) |
| 203 | { |
| 204 | processEventsTimeoutTimer_->expires_from_now(boost::posix_time::milliseconds(timeout)); |
| 205 | processEventsTimeoutTimer_->async_wait(&fireProcessEventsTimeout); |
| 206 | } |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 207 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 208 | if (keepThread) { |
| 209 | // work will ensure that ioService_ is running until work object exists |
| 210 | ioServiceWork_ = make_shared<boost::asio::io_service::work>(boost::ref(*ioService_)); |
| 211 | } |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 212 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 213 | ioService_->run(); |
| 214 | ioService_->reset(); // so it is possible to run processEvents again (if necessary) |
| 215 | } |
| 216 | catch(Face::ProcessEventsTimeout &) |
| 217 | { |
| 218 | // break |
| 219 | ioService_->reset(); |
| 220 | } |
| 221 | catch(const std::exception &) |
| 222 | { |
| 223 | ioService_->reset(); |
| 224 | pendingInterestTable_.clear(); |
| 225 | registeredPrefixTable_.clear(); |
| 226 | throw; |
| 227 | } |
Jeff Thompson | fb29cda | 2013-08-24 10:26:54 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 230 | void |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 231 | Face::shutdown() |
Jeff Thompson | 517ffa8 | 2013-08-05 16:04:34 -0700 | [diff] [blame] | 232 | { |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 233 | pendingInterestTable_.clear(); |
| 234 | registeredPrefixTable_.clear(); |
| 235 | |
| 236 | transport_->close(); |
| 237 | pitTimeoutCheckTimer_->cancel(); |
| 238 | processEventsTimeoutTimer_->cancel(); |
| 239 | pitTimeoutCheckTimerActive_ = false; |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 242 | void |
| 243 | Face::fireProcessEventsTimeout(const boost::system::error_code& error) |
| 244 | { |
| 245 | if (!error) // can fire for some other reason, e.g., cancelled |
| 246 | throw Face::ProcessEventsTimeout(); |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 247 | } |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 248 | |
| 249 | void |
| 250 | Face::checkPitExpire() |
| 251 | { |
| 252 | // Check for PIT entry timeouts. Go backwards through the list so we can erase entries. |
| 253 | MillisecondsSince1970 nowMilliseconds = getNowMilliseconds(); |
| 254 | |
| 255 | PendingInterestTable::iterator i = pendingInterestTable_.begin(); |
| 256 | while (i != pendingInterestTable_.end()) |
| 257 | { |
| 258 | if ((*i)->isTimedOut(nowMilliseconds)) |
| 259 | { |
| 260 | // Save the PendingInterest and remove it from the PIT. Then call the callback. |
| 261 | shared_ptr<PendingInterest> pendingInterest = *i; |
| 262 | |
| 263 | i = pendingInterestTable_.erase(i); |
| 264 | |
| 265 | pendingInterest->callTimeout(); |
| 266 | } |
| 267 | else |
| 268 | ++i; |
| 269 | } |
| 270 | |
| 271 | if (!pendingInterestTable_.empty()) { |
| 272 | pitTimeoutCheckTimerActive_ = true; |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 273 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 274 | pitTimeoutCheckTimer_->expires_from_now(boost::posix_time::milliseconds(100)); |
| 275 | pitTimeoutCheckTimer_->async_wait(bind(&Face::checkPitExpire, this)); |
| 276 | } |
| 277 | else { |
| 278 | pitTimeoutCheckTimerActive_ = false; |
| 279 | |
| 280 | if (registeredPrefixTable_.empty()) { |
| 281 | transport_->close(); |
| 282 | if (!ioServiceWork_) { |
| 283 | processEventsTimeoutTimer_->cancel(); |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 290 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 291 | Face::onReceiveElement(const Block &block) |
| 292 | { |
| 293 | if (block.type() == Tlv::Interest) |
| 294 | { |
| 295 | shared_ptr<Interest> interest(new Interest()); |
| 296 | interest->wireDecode(block); |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 297 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 298 | RegisteredPrefixTable::iterator entry = getEntryForRegisteredPrefix(interest->getName()); |
| 299 | if (entry != registeredPrefixTable_.end()) { |
| 300 | (*entry)->getOnInterest()((*entry)->getPrefix(), *interest); |
| 301 | } |
| 302 | } |
| 303 | else if (block.type() == Tlv::Data) |
| 304 | { |
| 305 | shared_ptr<Data> data(new Data()); |
| 306 | data->wireDecode(block); |
| 307 | |
| 308 | PendingInterestTable::iterator entry = getEntryIndexForExpressedInterest(data->getName()); |
| 309 | if (entry != pendingInterestTable_.end()) { |
| 310 | // Copy pointers to the needed objects and remove the PIT entry before the calling the callback. |
| 311 | const OnData onData = (*entry)->getOnData(); |
| 312 | const shared_ptr<const Interest> interest = (*entry)->getInterest(); |
| 313 | pendingInterestTable_.erase(entry); |
| 314 | |
| 315 | if (onData) { |
| 316 | onData(*interest, *data); |
| 317 | } |
| 318 | |
| 319 | if (pendingInterestTable_.empty()) { |
| 320 | pitTimeoutCheckTimer_->cancel(); // this will cause checkPitExpire invocation |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 326 | Face::PendingInterestTable::iterator |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 327 | Face::getEntryIndexForExpressedInterest(const Name& name) |
| 328 | { |
| 329 | for (PendingInterestTable::iterator i = pendingInterestTable_.begin (); |
| 330 | i != pendingInterestTable_.end(); ++i) |
| 331 | { |
| 332 | if ((*i)->getInterest()->matchesName(name)) |
| 333 | { |
| 334 | return i; |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | return pendingInterestTable_.end(); |
| 339 | } |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 340 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 341 | Face::RegisteredPrefixTable::iterator |
| 342 | Face::getEntryForRegisteredPrefix(const Name& name) |
| 343 | { |
| 344 | RegisteredPrefixTable::iterator longestPrefix = registeredPrefixTable_.end(); |
| 345 | |
| 346 | for (RegisteredPrefixTable::iterator i = registeredPrefixTable_.begin(); |
| 347 | i != registeredPrefixTable_.end(); |
| 348 | ++i) |
| 349 | { |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 350 | if ((*i)->getPrefix().isPrefixOf(name)) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 351 | { |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 352 | |
| 353 | if (longestPrefix == registeredPrefixTable_.end() || |
| 354 | (*i)->getPrefix().size() > (*longestPrefix)->getPrefix().size()) |
| 355 | { |
| 356 | longestPrefix = i; |
| 357 | } |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 358 | } |
| 359 | } |
| 360 | return longestPrefix; |
| 361 | } |
| 362 | |
| 363 | } // namespace ndn |