blob: 6a221ead004ccb8706345dd3060909c380206261 [file] [log] [blame]
Alexander Afanasyev3ecec502014-04-16 13:42:44 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventoa3148082018-04-12 18:21:54 -04002/*
3 * Copyright (c) 2014-2018, Regents of the University of California,
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -08004 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070010 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Vince12e49462014-06-09 13:29:32 -050024 */
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070025
26#include "rib.hpp"
Vince Lehman76c751c2014-11-18 17:36:38 -060027#include "fib-updater.hpp"
Vince Lehman281ded72014-08-21 12:17:08 -050028#include "core/logger.hpp"
29
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070030namespace nfd {
31namespace rib {
32
Davide Pesaventoa3148082018-04-12 18:21:54 -040033NFD_LOG_INIT(Rib);
34
Junxiao Shi89c0ea02017-03-06 19:52:05 +000035bool
36operator<(const RibRouteRef& lhs, const RibRouteRef& rhs)
37{
38 return std::tie(lhs.entry->getName(), lhs.route->faceId, lhs.route->origin) <
39 std::tie(rhs.entry->getName(), rhs.route->faceId, rhs.route->origin);
40}
41
Vince Lehman4387e782014-06-19 16:57:45 -050042static inline bool
Vince Lehman218be0a2015-01-15 17:25:20 -060043sortRoutes(const Route& lhs, const Route& rhs)
Vince Lehman4387e782014-06-19 16:57:45 -050044{
Vince Lehman218be0a2015-01-15 17:25:20 -060045 return lhs.faceId < rhs.faceId;
Vince Lehman4387e782014-06-19 16:57:45 -050046}
47
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070048Rib::Rib()
Vince12e49462014-06-09 13:29:32 -050049 : m_nItems(0)
Vince Lehman76c751c2014-11-18 17:36:38 -060050 , m_isUpdateInProgress(false)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070051{
52}
53
Davide Pesaventoa3148082018-04-12 18:21:54 -040054Rib::~Rib() = default;
Vince Lehman76c751c2014-11-18 17:36:38 -060055
56void
57Rib::setFibUpdater(FibUpdater* updater)
58{
59 m_fibUpdater = updater;
60}
61
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070062Rib::const_iterator
Vince12e49462014-06-09 13:29:32 -050063Rib::find(const Name& prefix) const
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070064{
Vince12e49462014-06-09 13:29:32 -050065 return m_rib.find(prefix);
66}
67
Vince Lehman218be0a2015-01-15 17:25:20 -060068Route*
69Rib::find(const Name& prefix, const Route& route) const
Vince12e49462014-06-09 13:29:32 -050070{
Davide Pesaventoe4b22382018-06-10 14:37:24 -040071 auto ribIt = m_rib.find(prefix);
Vince12e49462014-06-09 13:29:32 -050072
73 // Name prefix exists
Vince Lehman76c751c2014-11-18 17:36:38 -060074 if (ribIt != m_rib.end()) {
75 shared_ptr<RibEntry> entry = ribIt->second;
Davide Pesaventoe4b22382018-06-10 14:37:24 -040076 auto routeIt = entry->findRoute(route);
Vince Lehman76c751c2014-11-18 17:36:38 -060077 if (routeIt != entry->end()) {
Davide Pesaventoe4b22382018-06-10 14:37:24 -040078 return &*routeIt;
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070079 }
Vince Lehman76c751c2014-11-18 17:36:38 -060080 }
Vince Lehman218be0a2015-01-15 17:25:20 -060081
82 return nullptr;
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070083}
84
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070085void
Vince Lehman218be0a2015-01-15 17:25:20 -060086Rib::insert(const Name& prefix, const Route& route)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070087{
Davide Pesaventoe4b22382018-06-10 14:37:24 -040088 auto ribIt = m_rib.find(prefix);
Vince12e49462014-06-09 13:29:32 -050089
90 // Name prefix exists
Vince Lehman76c751c2014-11-18 17:36:38 -060091 if (ribIt != m_rib.end()) {
92 shared_ptr<RibEntry> entry(ribIt->second);
Vince12e49462014-06-09 13:29:32 -050093
Nick Gordon89c4cca2016-11-02 15:42:32 +000094 RibEntry::iterator entryIt;
95 bool didInsert = false;
96 std::tie(entryIt, didInsert) = entry->insertRoute(route);
Vince12e49462014-06-09 13:29:32 -050097
Nick Gordon89c4cca2016-11-02 15:42:32 +000098 if (didInsert) {
99 // The route was new and we successfully inserted it.
Vince Lehman76c751c2014-11-18 17:36:38 -0600100 m_nItems++;
Vince12e49462014-06-09 13:29:32 -0500101
Nick Gordon89c4cca2016-11-02 15:42:32 +0000102 afterAddRoute(RibRouteRef{entry, entryIt});
103
Vince12e49462014-06-09 13:29:32 -0500104 // Register with face lookup table
Vince Lehman218be0a2015-01-15 17:25:20 -0600105 m_faceMap[route.faceId].push_back(entry);
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700106 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600107 else {
108 // Route exists, update fields
109 // First cancel old scheduled event, if any, then set the EventId to new one
Nick Gordon89c4cca2016-11-02 15:42:32 +0000110 if (static_cast<bool>(entryIt->getExpirationEvent())) {
Vince Lehman76c751c2014-11-18 17:36:38 -0600111 NFD_LOG_TRACE("Cancelling expiration event for " << entry->getName() << " "
Nick Gordon89c4cca2016-11-02 15:42:32 +0000112 << (*entryIt));
113 scheduler::cancel(entryIt->getExpirationEvent());
Vince Lehman76c751c2014-11-18 17:36:38 -0600114 }
115
116 // No checks are required here as the iterator needs to be updated in all cases.
Nick Gordon89c4cca2016-11-02 15:42:32 +0000117 entryIt->setExpirationEvent(route.getExpirationEvent());
Vince Lehman76c751c2014-11-18 17:36:38 -0600118
Nick Gordon89c4cca2016-11-02 15:42:32 +0000119 entryIt->flags = route.flags;
120 entryIt->cost = route.cost;
121 entryIt->expires = route.expires;
Vince Lehman76c751c2014-11-18 17:36:38 -0600122 }
123 }
124 else {
125 // New name prefix
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400126 auto entry = make_shared<RibEntry>();
Vince Lehman76c751c2014-11-18 17:36:38 -0600127
128 m_rib[prefix] = entry;
129 m_nItems++;
130
131 entry->setName(prefix);
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400132 auto routeIt = entry->insertRoute(route).first;
Vince Lehman76c751c2014-11-18 17:36:38 -0600133
134 // Find prefix's parent
135 shared_ptr<RibEntry> parent = findParent(prefix);
136
137 // Add self to parent's children
138 if (parent != nullptr) {
139 parent->addChild(entry);
140 }
141
142 RibEntryList children = findDescendants(prefix);
143
144 for (const auto& child : children) {
145 if (child->getParent() == parent) {
146 // Remove child from parent and inherit parent's child
147 if (parent != nullptr) {
148 parent->removeChild(child);
149 }
150
151 entry->addChild(child);
152 }
153 }
154
155 // Register with face lookup table
156 m_faceMap[route.faceId].push_back(entry);
157
158 // do something after inserting an entry
159 afterInsertEntry(prefix);
Nick Gordon89c4cca2016-11-02 15:42:32 +0000160 afterAddRoute(RibRouteRef{entry, routeIt});
Vince Lehman76c751c2014-11-18 17:36:38 -0600161 }
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700162}
163
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700164void
Vince Lehman218be0a2015-01-15 17:25:20 -0600165Rib::erase(const Name& prefix, const Route& route)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700166{
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400167 auto ribIt = m_rib.find(prefix);
Vince12e49462014-06-09 13:29:32 -0500168
169 // Name prefix exists
Vince Lehman76c751c2014-11-18 17:36:38 -0600170 if (ribIt != m_rib.end()) {
Davide Pesaventoe94804b2016-09-19 17:23:21 +0000171 shared_ptr<RibEntry> entry = ribIt->second;
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400172 auto routeIt = entry->findRoute(route);
Vince Lehman4387e782014-06-19 16:57:45 -0500173
Vince Lehman76c751c2014-11-18 17:36:38 -0600174 if (routeIt != entry->end()) {
Nick Gordon89c4cca2016-11-02 15:42:32 +0000175 beforeRemoveRoute(RibRouteRef{entry, routeIt});
176
Davide Pesaventoe94804b2016-09-19 17:23:21 +0000177 auto faceId = route.faceId;
Vince Lehman76c751c2014-11-18 17:36:38 -0600178 entry->eraseRoute(routeIt);
179 m_nItems--;
Vince Lehman4387e782014-06-19 16:57:45 -0500180
Vince Lehman76c751c2014-11-18 17:36:38 -0600181 // If this RibEntry no longer has this faceId, unregister from face lookup table
Davide Pesaventoe94804b2016-09-19 17:23:21 +0000182 if (!entry->hasFaceId(faceId)) {
183 m_faceMap[faceId].remove(entry);
Vince Lehman76c751c2014-11-18 17:36:38 -0600184 }
Syed Obaid3313a372014-07-01 01:31:33 -0500185
Vince Lehman76c751c2014-11-18 17:36:38 -0600186 // If a RibEntry's route list is empty, remove it from the tree
Davide Pesaventoe94804b2016-09-19 17:23:21 +0000187 if (entry->getRoutes().empty()) {
Vince Lehman76c751c2014-11-18 17:36:38 -0600188 eraseEntry(ribIt);
189 }
Vince12e49462014-06-09 13:29:32 -0500190 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600191 }
Vince12e49462014-06-09 13:29:32 -0500192}
193
194void
Vince Lehman76c751c2014-11-18 17:36:38 -0600195Rib::onRouteExpiration(const Name& prefix, const Route& route)
Vince12e49462014-06-09 13:29:32 -0500196{
Vince Lehman76c751c2014-11-18 17:36:38 -0600197 NFD_LOG_DEBUG(route << " for " << prefix << " has expired");
Vince12e49462014-06-09 13:29:32 -0500198
Vince Lehman76c751c2014-11-18 17:36:38 -0600199 RibUpdate update;
200 update.setAction(RibUpdate::UNREGISTER)
201 .setName(prefix)
202 .setRoute(route);
Vince12e49462014-06-09 13:29:32 -0500203
Vince Lehman76c751c2014-11-18 17:36:38 -0600204 beginApplyUpdate(update, nullptr, nullptr);
Vince12e49462014-06-09 13:29:32 -0500205}
206
207shared_ptr<RibEntry>
208Rib::findParent(const Name& prefix) const
209{
Vince Lehman76c751c2014-11-18 17:36:38 -0600210 for (int i = prefix.size() - 1; i >= 0; i--) {
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400211 auto it = m_rib.find(prefix.getPrefix(i));
Vince Lehman76c751c2014-11-18 17:36:38 -0600212 if (it != m_rib.end()) {
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400213 return it->second;
Vince12e49462014-06-09 13:29:32 -0500214 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600215 }
Vince12e49462014-06-09 13:29:32 -0500216
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400217 return nullptr;
Vince12e49462014-06-09 13:29:32 -0500218}
219
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400220std::list<shared_ptr<RibEntry>>
Vince12e49462014-06-09 13:29:32 -0500221Rib::findDescendants(const Name& prefix) const
222{
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400223 std::list<shared_ptr<RibEntry>> children;
Vince12e49462014-06-09 13:29:32 -0500224
225 RibTable::const_iterator it = m_rib.find(prefix);
Vince Lehman76c751c2014-11-18 17:36:38 -0600226 if (it != m_rib.end()) {
227 ++it;
228 for (; it != m_rib.end(); ++it) {
229 if (prefix.isPrefixOf(it->first)) {
230 children.push_back((it->second));
231 }
232 else {
233 break;
234 }
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700235 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600236 }
237
238 return children;
239}
240
241std::list<shared_ptr<RibEntry>>
242Rib::findDescendantsForNonInsertedName(const Name& prefix) const
243{
244 std::list<shared_ptr<RibEntry>> children;
245
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400246 for (const auto& pair : m_rib) {
Vince Lehman76c751c2014-11-18 17:36:38 -0600247 if (prefix.isPrefixOf(pair.first)) {
248 children.push_back(pair.second);
249 }
250 }
Vince12e49462014-06-09 13:29:32 -0500251
252 return children;
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700253}
254
Vince12e49462014-06-09 13:29:32 -0500255Rib::RibTable::iterator
256Rib::eraseEntry(RibTable::iterator it)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700257{
Vince12e49462014-06-09 13:29:32 -0500258 // Entry does not exist
Vince Lehman76c751c2014-11-18 17:36:38 -0600259 if (it == m_rib.end()) {
260 return m_rib.end();
261 }
Vince12e49462014-06-09 13:29:32 -0500262
263 shared_ptr<RibEntry> entry(it->second);
264
265 shared_ptr<RibEntry> parent = entry->getParent();
266
267 // Remove self from parent's children
Vince Lehman76c751c2014-11-18 17:36:38 -0600268 if (parent != nullptr) {
269 parent->removeChild(entry);
270 }
271
272 for (auto childIt = entry->getChildren().begin(); childIt != entry->getChildren().end(); ) {
273 shared_ptr<RibEntry> child = *childIt;
274
275 // Advance iterator so it is not invalidated by removal
276 ++childIt;
277
278 // Remove children from self
279 entry->removeChild(child);
280
281 // Update parent's children
282 if (parent != nullptr) {
283 parent->addChild(child);
Vince12e49462014-06-09 13:29:32 -0500284 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600285 }
Vince12e49462014-06-09 13:29:32 -0500286
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400287 auto nextIt = m_rib.erase(it);
Vince12e49462014-06-09 13:29:32 -0500288
Yanbiao Lic17de832014-11-21 17:51:45 -0800289 // do something after erasing an entry.
290 afterEraseEntry(entry->getName());
291
Vince12e49462014-06-09 13:29:32 -0500292 return nextIt;
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700293}
294
Vince Lehman218be0a2015-01-15 17:25:20 -0600295Rib::RouteSet
296Rib::getAncestorRoutes(const RibEntry& entry) const
Vince Lehman4387e782014-06-19 16:57:45 -0500297{
Vince Lehman218be0a2015-01-15 17:25:20 -0600298 RouteSet ancestorRoutes(&sortRoutes);
Vince Lehman4387e782014-06-19 16:57:45 -0500299
300 shared_ptr<RibEntry> parent = entry.getParent();
301
Vince Lehman76c751c2014-11-18 17:36:38 -0600302 while (parent != nullptr) {
303 for (const Route& route : parent->getRoutes()) {
304 if (route.isChildInherit()) {
305 ancestorRoutes.insert(route);
Vince Lehman4387e782014-06-19 16:57:45 -0500306 }
Vince Lehman4387e782014-06-19 16:57:45 -0500307 }
308
Vince Lehman76c751c2014-11-18 17:36:38 -0600309 if (parent->hasCapture()) {
310 break;
Vince Lehman4387e782014-06-19 16:57:45 -0500311 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600312
313 parent = parent->getParent();
314 }
315
316 return ancestorRoutes;
317}
318
319Rib::RouteSet
320Rib::getAncestorRoutes(const Name& name) const
321{
322 RouteSet ancestorRoutes(&sortRoutes);
323
324 shared_ptr<RibEntry> parent = findParent(name);
325
326 while (parent != nullptr) {
327 for (const Route& route : parent->getRoutes()) {
328 if (route.isChildInherit()) {
329 ancestorRoutes.insert(route);
330 }
331 }
332
333 if (parent->hasCapture()) {
334 break;
335 }
336
337 parent = parent->getParent();
338 }
339
340 return ancestorRoutes;
341}
342
343void
344Rib::beginApplyUpdate(const RibUpdate& update,
345 const Rib::UpdateSuccessCallback& onSuccess,
346 const Rib::UpdateFailureCallback& onFailure)
347{
348 BOOST_ASSERT(m_fibUpdater != nullptr);
349
350 addUpdateToQueue(update, onSuccess, onFailure);
351
352 sendBatchFromQueue();
353}
354
355void
356Rib::beginRemoveFace(uint64_t faceId)
357{
358 for (const auto& nameAndRoute : findRoutesWithFaceId(faceId)) {
359 RibUpdate update;
360 update.setAction(RibUpdate::REMOVE_FACE)
361 .setName(nameAndRoute.first)
362 .setRoute(nameAndRoute.second);
363
364 addUpdateToQueue(update, nullptr, nullptr);
365 }
366
367 sendBatchFromQueue();
368}
369
370void
371Rib::addUpdateToQueue(const RibUpdate& update,
372 const Rib::UpdateSuccessCallback& onSuccess,
373 const Rib::UpdateFailureCallback& onFailure)
374{
375 RibUpdateBatch batch(update.getRoute().faceId);
376 batch.add(update);
377
378 UpdateQueueItem item{batch, onSuccess, onFailure};
379 m_updateBatches.push_back(std::move(item));
380}
381
382void
383Rib::sendBatchFromQueue()
384{
385 if (m_updateBatches.empty() || m_isUpdateInProgress) {
386 return;
387 }
388
389 m_isUpdateInProgress = true;
390
391 UpdateQueueItem item = std::move(m_updateBatches.front());
392 m_updateBatches.pop_front();
393
394 RibUpdateBatch& batch = item.batch;
395
396 // Until task #1698, each RibUpdateBatch contains exactly one RIB update
397 BOOST_ASSERT(batch.size() == 1);
398
399 const Rib::UpdateSuccessCallback& managerSuccessCallback = item.managerSuccessCallback;
400 const Rib::UpdateFailureCallback& managerFailureCallback = item.managerFailureCallback;
401
402 m_fibUpdater->computeAndSendFibUpdates(batch,
403 bind(&Rib::onFibUpdateSuccess, this,
404 batch, _1, managerSuccessCallback),
405 bind(&Rib::onFibUpdateFailure, this,
406 managerFailureCallback, _1, _2));
407
408 if (m_onSendBatchFromQueue != nullptr) {
409 m_onSendBatchFromQueue(batch);
410 }
411}
412
413void
414Rib::onFibUpdateSuccess(const RibUpdateBatch& batch,
415 const RibUpdateList& inheritedRoutes,
416 const Rib::UpdateSuccessCallback& onSuccess)
417{
418 for (const RibUpdate& update : batch) {
419 switch (update.getAction()) {
420 case RibUpdate::REGISTER:
421 insert(update.getName(), update.getRoute());
422 break;
423 case RibUpdate::UNREGISTER:
424 case RibUpdate::REMOVE_FACE:
425 erase(update.getName(), update.getRoute());
426 break;
427 }
428 }
429
430 // Add and remove precalculated inherited routes to RibEntries
431 modifyInheritedRoutes(inheritedRoutes);
432
433 m_isUpdateInProgress = false;
434
435 if (onSuccess != nullptr) {
436 onSuccess();
437 }
438
439 // Try to advance the batch queue
440 sendBatchFromQueue();
441}
442
443void
444Rib::onFibUpdateFailure(const Rib::UpdateFailureCallback& onFailure,
445 uint32_t code, const std::string& error)
446{
447 m_isUpdateInProgress = false;
448
449 if (onFailure != nullptr) {
450 onFailure(code, error);
451 }
452
453 // Try to advance the batch queue
454 sendBatchFromQueue();
455}
456
457void
458Rib::modifyInheritedRoutes(const RibUpdateList& inheritedRoutes)
459{
460 for (const RibUpdate& update : inheritedRoutes) {
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400461 auto ribIt = m_rib.find(update.getName());
Vince Lehman76c751c2014-11-18 17:36:38 -0600462 BOOST_ASSERT(ribIt != m_rib.end());
463 shared_ptr<RibEntry> entry(ribIt->second);
464
465 switch (update.getAction()) {
466 case RibUpdate::REGISTER:
467 entry->addInheritedRoute(update.getRoute());
468 break;
469 case RibUpdate::UNREGISTER:
470 entry->removeInheritedRoute(update.getRoute());
471 break;
472 case RibUpdate::REMOVE_FACE:
473 break;
474 }
475 }
476}
477
478std::list<Rib::NameAndRoute>
479Rib::findRoutesWithFaceId(uint64_t faceId)
480{
481 std::list<NameAndRoute> routes;
482
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400483 auto lookupIt = m_faceMap.find(faceId);
Vince Lehman76c751c2014-11-18 17:36:38 -0600484 if (lookupIt == m_faceMap.end()) {
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400485 // No RIB entries have this face
Vince Lehman76c751c2014-11-18 17:36:38 -0600486 return routes;
487 }
488
Vince Lehman76c751c2014-11-18 17:36:38 -0600489 // For each RIB entry that has faceId
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400490 for (const auto& entry : lookupIt->second) {
Vince Lehman76c751c2014-11-18 17:36:38 -0600491 // Find the routes in the entry
492 for (const Route& route : *entry) {
493 if (route.faceId == faceId) {
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400494 routes.emplace_back(entry->getName(), route);
Vince Lehman76c751c2014-11-18 17:36:38 -0600495 }
496 }
497 }
498
499 return routes;
Vince Lehman4387e782014-06-19 16:57:45 -0500500}
501
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700502std::ostream&
Vince12e49462014-06-09 13:29:32 -0500503operator<<(std::ostream& os, const Rib& rib)
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700504{
Vince Lehman76c751c2014-11-18 17:36:38 -0600505 for (const auto& item : rib) {
Weiwei Liuaaa58a62016-11-28 23:15:15 -0700506 os << *item.second << "\n";
Vince Lehman76c751c2014-11-18 17:36:38 -0600507 }
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700508
509 return os;
510}
511
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700512} // namespace rib
513} // namespace nfd