fib: add EndpointId field in NextHop record
refs: #4284
Change-Id: If0cfc21cfa81d6fa3c1590ecdce8fbbc1ea95e13
diff --git a/daemon/fw/access-strategy.cpp b/daemon/fw/access-strategy.cpp
index 8460a00..31e2b91 100644
--- a/daemon/fw/access-strategy.cpp
+++ b/daemon/fw/access-strategy.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -137,7 +137,7 @@
}
Face* outFace = this->getFace(mi.lastNexthop);
- if (outFace == nullptr || !fibEntry.hasNextHop(*outFace)) {
+ if (outFace == nullptr || !fibEntry.hasNextHop(*outFace, 0)) {
NFD_LOG_DEBUG(pitEntry->getInterest() << " last-nexthop-gone");
return false;
}
diff --git a/daemon/fw/ncc-strategy.cpp b/daemon/fw/ncc-strategy.cpp
index 0f7f4e1..bb96009 100644
--- a/daemon/fw/ncc-strategy.cpp
+++ b/daemon/fw/ncc-strategy.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -81,7 +81,7 @@
size_t nUpstreams = nexthops.size();
shared_ptr<Face> bestFace = meInfo.getBestFace();
- if (bestFace != nullptr && fibEntry.hasNextHop(*bestFace) &&
+ if (bestFace != nullptr && fibEntry.hasNextHop(*bestFace, 0) &&
!wouldViolateScope(inFace, interest, *bestFace) &&
canForwardToLegacy(*pitEntry, *bestFace)) {
// TODO Should we use `randlow = 100 + nrand48(h->seed) % 4096U;` ?
@@ -111,7 +111,7 @@
}
shared_ptr<Face> previousFace = meInfo.previousFace.lock();
- if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace) &&
+ if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace, 0) &&
!wouldViolateScope(inFace, interest, *previousFace) &&
canForwardToLegacy(*pitEntry, *previousFace)) {
--nUpstreams;
@@ -157,7 +157,7 @@
MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(pitEntry);
shared_ptr<Face> previousFace = meInfo.previousFace.lock();
- if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace) &&
+ if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace, 0) &&
!wouldViolateScope(*inFace, interest, *previousFace) &&
canForwardToLegacy(*pitEntry, *previousFace)) {
this->sendInterest(pitEntry, *previousFace, interest);
diff --git a/daemon/mgmt/fib-manager.cpp b/daemon/mgmt/fib-manager.cpp
index 5c04977..b73698d 100644
--- a/daemon/mgmt/fib-manager.cpp
+++ b/daemon/mgmt/fib-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -78,7 +78,7 @@
}
fib::Entry* entry = m_fib.insert(prefix).first;
- entry->addNextHop(*face, cost);
+ entry->addOrUpdateNextHop(*face, 0, cost);
NFD_LOG_TRACE("fib/add-nexthop(" << prefix << ',' << faceId << ',' << cost << "): OK");
return done(ControlResponse(200, "Success").setBody(parameters.wireEncode()));
@@ -107,7 +107,7 @@
return;
}
- entry->removeNextHop(*face);
+ entry->removeNextHop(*face, 0);
if (!entry->hasNextHops()) {
m_fib.erase(*entry);
NFD_LOG_TRACE("fib/remove-nexthop(" << prefix << ',' << faceId << "): OK entry-erased");
diff --git a/daemon/nfd.cpp b/daemon/nfd.cpp
index 28f6989..f4d136a 100644
--- a/daemon/nfd.cpp
+++ b/daemon/nfd.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -169,7 +169,7 @@
// add FIB entry for NFD Management Protocol
Name topPrefix("/localhost/nfd");
- m_forwarder->getFib().insert(topPrefix).first->addNextHop(*m_internalFace, 0);
+ m_forwarder->getFib().insert(topPrefix).first->addOrUpdateNextHop(*m_internalFace, 0, 0);
m_dispatcher->addTopPrefix(topPrefix, false);
}
diff --git a/daemon/table/cleanup.cpp b/daemon/table/cleanup.cpp
index 104bdf1..5a45bf7 100644
--- a/daemon/table/cleanup.cpp
+++ b/daemon/table/cleanup.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -36,7 +36,7 @@
for (const name_tree::Entry& nte : nt) {
fib::Entry* fibEntry = nte.getFibEntry();
if (fibEntry != nullptr) {
- fib.removeNextHop(*fibEntry, face);
+ fib.removeNextHopByFace(*fibEntry, face);
}
for (const auto& pitEntry : nte.getPitEntries()) {
diff --git a/daemon/table/fib-entry.cpp b/daemon/table/fib-entry.cpp
index c2e299f..cf14936 100644
--- a/daemon/table/fib-entry.cpp
+++ b/daemon/table/fib-entry.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -35,43 +35,52 @@
}
NextHopList::iterator
-Entry::findNextHop(const Face& face)
+Entry::findNextHop(const Face& face, uint64_t endpointId)
{
return std::find_if(m_nextHops.begin(), m_nextHops.end(),
- [&face] (const NextHop& nexthop) {
- return &nexthop.getFace() == &face;
+ [&face, endpointId] (const NextHop& nexthop) {
+ return &nexthop.getFace() == &face && nexthop.getEndpointId() == endpointId;
});
}
bool
-Entry::hasNextHop(const Face& face) const
+Entry::hasNextHop(const Face& face, uint64_t endpointId) const
{
- return const_cast<Entry*>(this)->findNextHop(face) != m_nextHops.end();
+ return const_cast<Entry*>(this)->findNextHop(face, endpointId) != m_nextHops.end();
}
void
-Entry::addNextHop(Face& face, uint64_t cost)
+Entry::addOrUpdateNextHop(Face& face, uint64_t endpointId, uint64_t cost)
{
- auto it = this->findNextHop(face);
+ auto it = this->findNextHop(face, endpointId);
if (it == m_nextHops.end()) {
- m_nextHops.emplace_back(face);
+ m_nextHops.emplace_back(face, endpointId);
it = std::prev(m_nextHops.end());
}
-
it->setCost(cost);
this->sortNextHops();
}
void
-Entry::removeNextHop(const Face& face)
+Entry::removeNextHop(const Face& face, uint64_t endpointId)
{
- auto it = this->findNextHop(face);
+ auto it = this->findNextHop(face, endpointId);
if (it != m_nextHops.end()) {
m_nextHops.erase(it);
}
}
void
+Entry::removeNextHopByFace(const Face& face)
+{
+ auto it = std::remove_if(m_nextHops.begin(), m_nextHops.end(),
+ [&face] (const NextHop& nexthop) {
+ return &nexthop.getFace() == &face;
+ });
+ m_nextHops.erase(it, m_nextHops.end());
+}
+
+void
Entry::sortNextHops()
{
std::sort(m_nextHops.begin(), m_nextHops.end(),
diff --git a/daemon/table/fib-entry.hpp b/daemon/table/fib-entry.hpp
index 24489b9..2b86f66 100644
--- a/daemon/table/fib-entry.hpp
+++ b/daemon/table/fib-entry.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -74,32 +74,36 @@
return !m_nextHops.empty();
}
- /** \return whether there is a NextHop record for \p face
+ /** \return whether there is a NextHop record for \p face with the given \p endpointId
*/
bool
- hasNextHop(const Face& face) const;
+ hasNextHop(const Face& face, uint64_t endpointId) const;
/** \brief adds a NextHop record
*
- * If a NextHop record for \p face already exists, its cost is updated.
+ * If a NextHop record for \p face and \p endpointId already exists,
+ * its cost is updated.
*/
void
- addNextHop(Face& face, uint64_t cost);
+ addOrUpdateNextHop(Face& face, uint64_t endpointId, uint64_t cost);
- /** \brief removes a NextHop record
- *
- * If no NextHop record for face exists, do nothing.
+ /** \brief removes the NextHop record for \p face with the given \p endpointId
*/
void
- removeNextHop(const Face& face);
+ removeNextHop(const Face& face, uint64_t endpointId);
+
+ /** \brief removes all NextHop records on \p face for any \p endpointId
+ */
+ void
+ removeNextHopByFace(const Face& face);
private:
/** \note This method is non-const because mutable iterators are needed by callers.
*/
NextHopList::iterator
- findNextHop(const Face& face);
+ findNextHop(const Face& face, uint64_t endpointId);
- /** \brief sorts the nexthop list
+ /** \brief sorts the nexthop list by cost
*/
void
sortNextHops();
diff --git a/daemon/table/fib-nexthop.cpp b/daemon/table/fib-nexthop.cpp
index e554362..e456c15 100644
--- a/daemon/table/fib-nexthop.cpp
+++ b/daemon/table/fib-nexthop.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,8 +28,9 @@
namespace nfd {
namespace fib {
-NextHop::NextHop(Face& face)
+NextHop::NextHop(Face& face, uint64_t endpointId)
: m_face(&face)
+ , m_endpointId(endpointId)
, m_cost(0)
{
}
diff --git a/daemon/table/fib-nexthop.hpp b/daemon/table/fib-nexthop.hpp
index 83b774f..313508d 100644
--- a/daemon/table/fib-nexthop.hpp
+++ b/daemon/table/fib-nexthop.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -39,7 +39,7 @@
{
public:
explicit
- NextHop(Face& face);
+ NextHop(Face& face, uint64_t endpointId);
Face&
getFace() const
@@ -48,6 +48,12 @@
}
uint64_t
+ getEndpointId() const
+ {
+ return m_endpointId;
+ }
+
+ uint64_t
getCost() const
{
return m_cost;
@@ -61,6 +67,7 @@
private:
Face* m_face;
+ uint64_t m_endpointId;
uint64_t m_cost;
};
diff --git a/daemon/table/fib.cpp b/daemon/table/fib.cpp
index 7b6d21a..ccde921 100644
--- a/daemon/table/fib.cpp
+++ b/daemon/table/fib.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -134,16 +134,28 @@
}
void
-Fib::removeNextHop(Entry& entry, const Face& face)
+Fib::eraseIfEmpty(Entry& entry)
{
- entry.removeNextHop(face);
-
if (!entry.hasNextHops()) {
name_tree::Entry* nte = m_nameTree.getEntry(entry);
this->erase(nte, false);
}
}
+void
+Fib::removeNextHop(Entry& entry, const Face& face, uint64_t endpointId)
+{
+ entry.removeNextHop(face, endpointId);
+ this->eraseIfEmpty(entry);
+}
+
+void
+Fib::removeNextHopByFace(Entry& entry, const Face& face)
+{
+ entry.removeNextHopByFace(face);
+ this->eraseIfEmpty(entry);
+}
+
Fib::Range
Fib::getRange() const
{
diff --git a/daemon/table/fib.hpp b/daemon/table/fib.hpp
index 4b94c21..cfdc4f1 100644
--- a/daemon/table/fib.hpp
+++ b/daemon/table/fib.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -105,10 +105,15 @@
void
erase(const Entry& entry);
- /** \brief removes the NextHop record for face
+ /** \brief removes the NextHop record for \p face with a given \p endpointId
*/
void
- removeNextHop(Entry& entry, const Face& face);
+ removeNextHop(Entry& entry, const Face& face, uint64_t endpointId);
+
+ /** \brief removes the NextHop record for \p face for any \p endpointId
+ */
+ void
+ removeNextHopByFace(Entry& entry, const Face& face);
public: // enumeration
typedef boost::transformed_range<name_tree::GetTableEntry<Entry>, const name_tree::Range> Range;
@@ -144,6 +149,11 @@
void
erase(name_tree::Entry* nte, bool canDeleteNte = true);
+ /** \brief erase \p entry if it contains no nexthop record
+ */
+ void
+ eraseIfEmpty(Entry& entry);
+
Range
getRange() const;
diff --git a/tests/daemon/fw/best-route-strategy2.t.cpp b/tests/daemon/fw/best-route-strategy2.t.cpp
index 2337e07..c0d9ba8 100644
--- a/tests/daemon/fw/best-route-strategy2.t.cpp
+++ b/tests/daemon/fw/best-route-strategy2.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -78,9 +78,9 @@
BOOST_AUTO_TEST_CASE(Forward)
{
fib::Entry& fibEntry = *fib.insert(Name()).first;
- fibEntry.addNextHop(*face1, 10);
- fibEntry.addNextHop(*face2, 20);
- fibEntry.addNextHop(*face3, 30);
+ fibEntry.addOrUpdateNextHop(*face1, 0, 10);
+ fibEntry.addOrUpdateNextHop(*face2, 0, 20);
+ fibEntry.addOrUpdateNextHop(*face3, 0, 30);
shared_ptr<Interest> interest = makeInterest("ndn:/BzgFBchqA");
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
@@ -129,7 +129,7 @@
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[4].outFaceId, face1->getId());
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[5].outFaceId, face3->getId());
- fibEntry.removeNextHop(*face1);
+ fibEntry.removeNextHop(*face1, 0);
strategy.sendInterestHistory.clear();
for (int i = 0; i < 3; ++i) {
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index 82a93ea..85e77d0 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -52,7 +52,7 @@
forwarder.addFace(face2);
Fib& fib = forwarder.getFib();
- fib.insert("/A").first->addNextHop(*face2, 0);
+ fib.insert("/A").first->addOrUpdateNextHop(*face2, 0, 0);
BOOST_CHECK_EQUAL(forwarder.getCounters().nInInterests, 0);
BOOST_CHECK_EQUAL(forwarder.getCounters().nOutInterests, 0);
@@ -98,7 +98,7 @@
dataA->setTag(make_shared<lp::IncomingFaceIdTag>(face3->getId()));
Fib& fib = forwarder.getFib();
- fib.insert("/A").first->addNextHop(*face2, 0);
+ fib.insert("/A").first->addOrUpdateNextHop(*face2, 0, 0);
Pit& pit = forwarder.getPit();
BOOST_CHECK_EQUAL(pit.size(), 0);
@@ -163,7 +163,7 @@
forwarder.addFace(face3);
Fib& fib = forwarder.getFib();
- fib.insert("/A").first->addNextHop(*face3, 0);
+ fib.insert("/A").first->addOrUpdateNextHop(*face3, 0, 0);
shared_ptr<Interest> interest = makeInterest("/A/B");
interest->setTag(make_shared<lp::NextHopFaceIdTag>(face2->getId()));
@@ -498,7 +498,7 @@
forwarder.addFace(face4);
Fib& fib = forwarder.getFib();
- fib.insert("/zT4XwK0Hnx").first->addNextHop(*face4, 0);
+ fib.insert("/zT4XwK0Hnx").first->addOrUpdateNextHop(*face4, 0, 0);
// receive Interest on face1
face1->sentNacks.clear();
@@ -550,7 +550,7 @@
});
Fib& fib = forwarder.getFib();
- fib.insert("/A").first->addNextHop(*face2, 0);
+ fib.insert("/A").first->addOrUpdateNextHop(*face2, 0, 0);
// receive an Interest
shared_ptr<Interest> interest = makeInterest("ndn:/A/1");
diff --git a/tests/daemon/fw/multicast-strategy.t.cpp b/tests/daemon/fw/multicast-strategy.t.cpp
index d57f801..04de9b2 100644
--- a/tests/daemon/fw/multicast-strategy.t.cpp
+++ b/tests/daemon/fw/multicast-strategy.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -70,9 +70,9 @@
BOOST_AUTO_TEST_CASE(Forward2)
{
fib::Entry& fibEntry = *fib.insert(Name()).first;
- fibEntry.addNextHop(*face1, 0);
- fibEntry.addNextHop(*face2, 0);
- fibEntry.addNextHop(*face3, 0);
+ fibEntry.addOrUpdateNextHop(*face1, 0, 0);
+ fibEntry.addOrUpdateNextHop(*face2, 0, 0);
+ fibEntry.addOrUpdateNextHop(*face3, 0, 0);
shared_ptr<Interest> interest = makeInterest("ndn:/H0D6i5fc");
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
@@ -124,7 +124,7 @@
BOOST_AUTO_TEST_CASE(RejectLoopback)
{
fib::Entry& fibEntry = *fib.insert(Name()).first;
- fibEntry.addNextHop(*face1, 0);
+ fibEntry.addOrUpdateNextHop(*face1, 0, 0);
shared_ptr<Interest> interest = makeInterest("ndn:/H0D6i5fc");
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
diff --git a/tests/daemon/fw/ncc-strategy.t.cpp b/tests/daemon/fw/ncc-strategy.t.cpp
index 2e9ee18..38a2401 100644
--- a/tests/daemon/fw/ncc-strategy.t.cpp
+++ b/tests/daemon/fw/ncc-strategy.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -63,8 +63,8 @@
Fib& fib = forwarder.getFib();
fib::Entry& fibEntry = *fib.insert(Name()).first;
- fibEntry.addNextHop(*face1, 10);
- fibEntry.addNextHop(*face2, 20);
+ fibEntry.addOrUpdateNextHop(*face1, 0, 10);
+ fibEntry.addOrUpdateNextHop(*face2, 0, 20);
Pit& pit = forwarder.getPit();
@@ -122,7 +122,7 @@
Fib& fib = forwarder.getFib();
fib::Entry& fibEntry = *fib.insert(Name()).first;
- fibEntry.addNextHop(*face1, 10);
+ fibEntry.addOrUpdateNextHop(*face1, 0, 10);
Pit& pit = forwarder.getPit();
@@ -153,7 +153,7 @@
strategy.afterReceiveInterest(*face3, *interest2, pitEntry2);
// FIB entry is changed before doPropagate executes
- fibEntry.addNextHop(*face2, 20);
+ fibEntry.addOrUpdateNextHop(*face2, 0, 20);
this->advanceClocks(time::milliseconds(10), time::milliseconds(1000));// should not crash
}
@@ -173,8 +173,8 @@
Fib& fib = forwarder.getFib();
fib::Entry& fibEntry = *fib.insert(Name()).first;
- fibEntry.addNextHop(*face1, 10);
- fibEntry.addNextHop(*face2, 20);
+ fibEntry.addOrUpdateNextHop(*face1, 0, 10);
+ fibEntry.addOrUpdateNextHop(*face2, 0, 20);
Pit& pit = forwarder.getPit();
@@ -228,7 +228,7 @@
Fib& fib = forwarder.getFib();
fib::Entry& fibEntry = *fib.insert(Name()).first;
- fibEntry.addNextHop(*face2, 10);
+ fibEntry.addOrUpdateNextHop(*face2, 0, 10);
Pit& pit = forwarder.getPit();
@@ -273,8 +273,8 @@
Fib& fib = forwarder.getFib();
fib::Entry& fibEntry = *fib.insert(Name()).first;
- fibEntry.addNextHop(*face1, 10); // face1 is top-ranked nexthop
- fibEntry.addNextHop(*face2, 20);
+ fibEntry.addOrUpdateNextHop(*face1, 0, 10); // face1 is top-ranked nexthop
+ fibEntry.addOrUpdateNextHop(*face2, 0, 20);
Pit& pit = forwarder.getPit();
@@ -376,7 +376,7 @@
// NccStrategy has selected one path as the best.
// When we reduce the RTT of the other path, ideally it should be selected as the best face.
// However, this won't happen due to a weakness in NccStrategy.
- // See http://redmine.named-data.net/issues/3411#note-4
+ // See https://redmine.named-data.net/issues/3411#note-4
shared_ptr<Face> bestFace1 = getMeInfo()->bestFace.lock();
if (bestFace1.get() == &linkAB->getFace(nodeA)) {
linkCD->setDelay(time::milliseconds(5));
diff --git a/tests/daemon/fw/strategy-nack-return.t.cpp b/tests/daemon/fw/strategy-nack-return.t.cpp
index b9c2421..aea8d88 100644
--- a/tests/daemon/fw/strategy-nack-return.t.cpp
+++ b/tests/daemon/fw/strategy-nack-return.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -96,9 +96,9 @@
S, Strategies, StrategyNackReturnFixture<S>)
{
fib::Entry& fibEntry = *this->fib.insert(Name()).first;
- fibEntry.addNextHop(*this->face3, 10);
- fibEntry.addNextHop(*this->face4, 20);
- fibEntry.addNextHop(*this->face5, 30);
+ fibEntry.addOrUpdateNextHop(*this->face3, 0, 10);
+ fibEntry.addOrUpdateNextHop(*this->face4, 0, 20);
+ fibEntry.addOrUpdateNextHop(*this->face5, 0, 30);
shared_ptr<Interest> interest1 = makeInterest("/McQYjMbm", 992);
shared_ptr<Interest> interest2 = makeInterest("/McQYjMbm", 114);
@@ -131,9 +131,9 @@
S, Strategies, StrategyNackReturnFixture<S>)
{
fib::Entry& fibEntry = *this->fib.insert(Name()).first;
- fibEntry.addNextHop(*this->face3, 10);
- fibEntry.addNextHop(*this->face4, 20);
- fibEntry.addNextHop(*this->face5, 30);
+ fibEntry.addOrUpdateNextHop(*this->face3, 0, 10);
+ fibEntry.addOrUpdateNextHop(*this->face4, 0, 20);
+ fibEntry.addOrUpdateNextHop(*this->face5, 0, 30);
shared_ptr<Interest> interest1 = makeInterest("/aS9FAyUV19", 286);
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest1).first;
@@ -164,9 +164,9 @@
S, Strategies, StrategyNackReturnFixture<S>)
{
fib::Entry& fibEntry = *this->fib.insert(Name()).first;
- fibEntry.addNextHop(*this->face3, 10);
- fibEntry.addNextHop(*this->face4, 20);
- fibEntry.addNextHop(*this->face5, 30);
+ fibEntry.addOrUpdateNextHop(*this->face3, 0, 10);
+ fibEntry.addOrUpdateNextHop(*this->face4, 0, 20);
+ fibEntry.addOrUpdateNextHop(*this->face5, 0, 30);
shared_ptr<Interest> interest1 = makeInterest("/sIYw0TXWDj", 115);
interest1->setInterestLifetime(time::milliseconds(400));
@@ -317,9 +317,9 @@
StrategyNackReturnFixture<BestRouteStrategy2>)
{
fib::Entry& fibEntry = *fib.insert(Name()).first;
- fibEntry.addNextHop(*face3, 10);
- fibEntry.addNextHop(*face4, 20);
- fibEntry.addNextHop(*face5, 30);
+ fibEntry.addOrUpdateNextHop(*face3, 0, 10);
+ fibEntry.addOrUpdateNextHop(*face4, 0, 20);
+ fibEntry.addOrUpdateNextHop(*face5, 0, 30);
shared_ptr<Interest> interest1 = makeInterest("/F6sEwB24I", 282);
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
diff --git a/tests/daemon/fw/strategy-no-route.t.cpp b/tests/daemon/fw/strategy-no-route.t.cpp
index 18f45a8..8183caf 100644
--- a/tests/daemon/fw/strategy-no-route.t.cpp
+++ b/tests/daemon/fw/strategy-no-route.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -117,7 +117,7 @@
void
insertFibEntry(StrategyNoRouteFixture<S>* fixture)
{
- fixture->fib.insert(Name()).first->addNextHop(*fixture->face1, 10);
+ fixture->fib.insert(Name()).first->addOrUpdateNextHop(*fixture->face1, 0, 10);
}
};
@@ -134,7 +134,7 @@
void
insertFibEntry(StrategyNoRouteFixture<S>* fixture)
{
- fixture->fib.insert("/localhop").first->addNextHop(*fixture->face2, 10);
+ fixture->fib.insert("/localhop").first->addOrUpdateNextHop(*fixture->face2, 0, 10);
// face1 and face2 are both non-local; Interest from face1 cannot be forwarded to face2
}
};
diff --git a/tests/daemon/fw/strategy-scope-control.t.cpp b/tests/daemon/fw/strategy-scope-control.t.cpp
index 4c6494a..bd59838 100644
--- a/tests/daemon/fw/strategy-scope-control.t.cpp
+++ b/tests/daemon/fw/strategy-scope-control.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -118,7 +118,7 @@
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
{
fib::Entry* fibEntry = this->fib.insert("/localhost/A").first;
- fibEntry->addNextHop(*this->localFace4, 10);
+ fibEntry->addOrUpdateNextHop(*this->localFace4, 0, 10);
shared_ptr<Interest> interest = makeInterest("/localhost/A/1");
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
@@ -137,7 +137,7 @@
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
{
fib::Entry* fibEntry = this->fib.insert("/localhost/A").first;
- fibEntry->addNextHop(*this->nonLocalFace2, 10);
+ fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 10);
shared_ptr<Interest> interest = makeInterest("/localhost/A/1");
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
@@ -159,8 +159,8 @@
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
{
fib::Entry* fibEntry = this->fib.insert("/localhost/A").first;
- fibEntry->addNextHop(*this->nonLocalFace2, 10);
- fibEntry->addNextHop(*this->localFace4, 20);
+ fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 10);
+ fibEntry->addOrUpdateNextHop(*this->localFace4, 0, 20);
shared_ptr<Interest> interest = makeInterest("/localhost/A/1");
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
@@ -180,7 +180,7 @@
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
{
fib::Entry* fibEntry = this->fib.insert("/localhop/A").first;
- fibEntry->addNextHop(*this->nonLocalFace2, 10);
+ fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 10);
shared_ptr<Interest> interest = makeInterest("/localhop/A/1");
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
@@ -202,8 +202,8 @@
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
{
fib::Entry* fibEntry = this->fib.insert("/localhop/A").first;
- fibEntry->addNextHop(*this->nonLocalFace2, 10);
- fibEntry->addNextHop(*this->localFace4, 20);
+ fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 10);
+ fibEntry->addOrUpdateNextHop(*this->localFace4, 0, 20);
shared_ptr<Interest> interest = makeInterest("/localhop/A/1");
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
@@ -223,8 +223,8 @@
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
{
fib::Entry* fibEntry = this->fib.insert("/localhost/A").first;
- fibEntry->addNextHop(*this->localFace4, 10);
- fibEntry->addNextHop(*this->nonLocalFace2, 20);
+ fibEntry->addOrUpdateNextHop(*this->localFace4, 0, 10);
+ fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 20);
shared_ptr<Interest> interest = makeInterest("/localhost/A/1", 1460);
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
@@ -248,8 +248,8 @@
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
{
fib::Entry* fibEntry = this->fib.insert("/localhop/A").first;
- fibEntry->addNextHop(*this->localFace4, 10);
- fibEntry->addNextHop(*this->nonLocalFace2, 20);
+ fibEntry->addOrUpdateNextHop(*this->localFace4, 0, 10);
+ fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 20);
shared_ptr<Interest> interest = makeInterest("/localhop/A/1", 1377);
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
diff --git a/tests/daemon/fw/topology-tester.cpp b/tests/daemon/fw/topology-tester.cpp
index 41d5d8c..15bbc3c 100644
--- a/tests/daemon/fw/topology-tester.cpp
+++ b/tests/daemon/fw/topology-tester.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -241,7 +241,7 @@
{
Forwarder& forwarder = this->getForwarder(i);
Fib& fib = forwarder.getFib();
- fib.insert(prefix).first->addNextHop(const_cast<Face&>(face), cost);
+ fib.insert(prefix).first->addOrUpdateNextHop(const_cast<Face&>(face), 0, cost);
}
void
diff --git a/tests/daemon/mgmt/fib-manager.t.cpp b/tests/daemon/mgmt/fib-manager.t.cpp
index f0a91ff..5fd193d 100644
--- a/tests/daemon/mgmt/fib-manager.t.cpp
+++ b/tests/daemon/mgmt/fib-manager.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -301,9 +301,9 @@
BOOST_REQUIRE_NE(face3, face::INVALID_FACEID);
fib::Entry* entry = m_fib.insert("/hello").first;
- entry->addNextHop(*m_faceTable.get(face1), 101);
- entry->addNextHop(*m_faceTable.get(face2), 202);
- entry->addNextHop(*m_faceTable.get(face3), 303);
+ entry->addOrUpdateNextHop(*m_faceTable.get(face1), 0, 101);
+ entry->addOrUpdateNextHop(*m_faceTable.get(face2), 0, 202);
+ entry->addOrUpdateNextHop(*m_faceTable.get(face3), 0, 303);
testRemoveNextHop(makeParameters("/hello", face1));
BOOST_REQUIRE_EQUAL(m_responses.size(), 1);
@@ -354,8 +354,8 @@
};
fib::Entry* entry = m_fib.insert("/hello").first;
- entry->addNextHop(*m_faceTable.get(face1), 101);
- entry->addNextHop(*m_faceTable.get(face2), 202);
+ entry->addOrUpdateNextHop(*m_faceTable.get(face1), 0, 101);
+ entry->addOrUpdateNextHop(*m_faceTable.get(face2), 0, 202);
testWithImplicitFaceId(ControlParameters().setName("/hello").setFaceId(0), face1);
BOOST_REQUIRE_EQUAL(m_responses.size(), 1);
@@ -385,7 +385,7 @@
receiveInterest(req);
};
- m_fib.insert("/hello").first->addNextHop(*m_faceTable.get(face1), 101);
+ m_fib.insert("/hello").first->addOrUpdateNextHop(*m_faceTable.get(face1), 0, 101);
testRemoveNextHop(makeParameters("/hello", face2 + 100));
BOOST_REQUIRE_EQUAL(m_responses.size(), 1); // face does not exist
@@ -410,8 +410,8 @@
Name prefix = Name("test").appendSegment(i);
actualPrefixes.insert(prefix);
fib::Entry* fibEntry = m_fib.insert(prefix).first;
- fibEntry->addNextHop(*m_faceTable.get(addFace()), std::numeric_limits<uint8_t>::max() - 1);
- fibEntry->addNextHop(*m_faceTable.get(addFace()), std::numeric_limits<uint8_t>::max() - 2);
+ fibEntry->addOrUpdateNextHop(*m_faceTable.get(addFace()), 0, std::numeric_limits<uint8_t>::max() - 1);
+ fibEntry->addOrUpdateNextHop(*m_faceTable.get(addFace()), 0, std::numeric_limits<uint8_t>::max() - 2);
}
receiveInterest(Interest("/localhost/nfd/fib/list").setCanBePrefix(true));
diff --git a/tests/daemon/table/cleanup.t.cpp b/tests/daemon/table/cleanup.t.cpp
index 20638ab..3365a50 100644
--- a/tests/daemon/table/cleanup.t.cpp
+++ b/tests/daemon/table/cleanup.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -50,7 +50,7 @@
Name name = Name("/P").appendVersion(i);
fib::Entry* fibEntry = fib.insert(name).first;
- fibEntry->addNextHop(*face1, 0);
+ fibEntry->addOrUpdateNextHop(*face1, 0, 0);
shared_ptr<Interest> interest = makeInterest(name);
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
@@ -89,24 +89,24 @@
BOOST_CHECK_EQUAL(fib.size(), 0);
fib::Entry* entryA = fib.insert("/A").first;
- entryA->addNextHop(*face1, 0);
- entryA->addNextHop(*face2, 0);
+ entryA->addOrUpdateNextHop(*face1, 0, 0);
+ entryA->addOrUpdateNextHop(*face2, 0, 0);
// {'/A':[1,2]}
fib::Entry* entryB = fib.insert("/B").first;
- entryB->addNextHop(*face1, 0);
+ entryB->addOrUpdateNextHop(*face1, 0, 0);
// {'/A':[1,2], '/B':[1]}
fib::Entry* entryC = fib.insert("/C").first;
- entryC->addNextHop(*face2, 1);
+ entryC->addOrUpdateNextHop(*face2, 0, 1);
// {'/A':[1,2], '/B':[1], '/C':[2]}
fib::Entry* entryB1 = fib.insert("/B/1").first;
- entryB1->addNextHop(*face1, 0);
+ entryB1->addOrUpdateNextHop(*face1, 0, 0);
// {'/A':[1,2], '/B':[1], '/B/1':[1], '/C':[2]}
fib::Entry* entryB12 = fib.insert("/B/1/2").first;
- entryB12->addNextHop(*face1, 0);
+ entryB12->addOrUpdateNextHop(*face1, 0, 0);
// {'/A':[1,2], '/B':[1], '/B/1':[1], '/B/1/2':[1], '/C':[2]}
// ---- close face1 ----
diff --git a/tests/daemon/table/fib.t.cpp b/tests/daemon/table/fib.t.cpp
index 204c5a3..0a6ccff 100644
--- a/tests/daemon/table/fib.t.cpp
+++ b/tests/daemon/table/fib.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -51,71 +51,138 @@
// []
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 0);
- entry.addNextHop(*face1, 20);
- // [(face1,20)]
+ // [(face, cost, endpointId)]
+ entry.addOrUpdateNextHop(*face1, 200, 20);
+ // [(face1,200,20)]
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 1);
BOOST_CHECK_EQUAL(&entry.getNextHops().begin()->getFace(), face1.get());
+ BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getEndpointId(), 200);
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getCost(), 20);
- entry.addNextHop(*face1, 30);
- // [(face1,30)]
- BOOST_CHECK_EQUAL(entry.getNextHops().size(), 1);
- BOOST_CHECK_EQUAL(&entry.getNextHops().begin()->getFace(), face1.get());
- BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getCost(), 30);
-
- entry.addNextHop(*face2, 40);
- // [(face1,30), (face2,40)]
+ entry.addOrUpdateNextHop(*face1, 300, 30);
+ // [(face1,200,20), (face1,300,30)]
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 2);
+ BOOST_CHECK_EQUAL(&entry.getNextHops().begin()->getFace(), face1.get());
+ BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getEndpointId(), 200);
+ BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getCost(), 20);
+
+ entry.addOrUpdateNextHop(*face2, 400, 40);
+ // [(face1,200,20), (face1,300,30), (face2,400,40)]
+ BOOST_CHECK_EQUAL(entry.getNextHops().size(), 3);
{
NextHopList::const_iterator it = entry.getNextHops().begin();
BOOST_REQUIRE(it != entry.getNextHops().end());
BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
+ BOOST_CHECK_EQUAL(it->getEndpointId(), 200);
+ BOOST_CHECK_EQUAL(it->getCost(), 20);
+
+ ++it;
+ BOOST_REQUIRE(it != entry.getNextHops().end());
+ BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
+ BOOST_CHECK_EQUAL(it->getEndpointId(), 300);
BOOST_CHECK_EQUAL(it->getCost(), 30);
++it;
BOOST_REQUIRE(it != entry.getNextHops().end());
BOOST_CHECK_EQUAL(&it->getFace(), face2.get());
+ BOOST_CHECK_EQUAL(it->getEndpointId(), 400);
BOOST_CHECK_EQUAL(it->getCost(), 40);
++it;
BOOST_CHECK(it == entry.getNextHops().end());
}
- entry.addNextHop(*face2, 10);
- // [(face2,10), (face1,30)]
- BOOST_CHECK_EQUAL(entry.getNextHops().size(), 2);
+ entry.addOrUpdateNextHop(*face2, 100, 10);
+ // [(face2,100,10), (face1,200,20), (face1,300,30), (face2,400,40)]
+ BOOST_CHECK_EQUAL(entry.getNextHops().size(), 4);
{
NextHopList::const_iterator it = entry.getNextHops().begin();
BOOST_REQUIRE(it != entry.getNextHops().end());
BOOST_CHECK_EQUAL(&it->getFace(), face2.get());
+ BOOST_CHECK_EQUAL(it->getEndpointId(), 100);
BOOST_CHECK_EQUAL(it->getCost(), 10);
++it;
BOOST_REQUIRE(it != entry.getNextHops().end());
BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
+ BOOST_CHECK_EQUAL(it->getEndpointId(), 200);
+ BOOST_CHECK_EQUAL(it->getCost(), 20);
+
+ ++it;
+ BOOST_REQUIRE(it != entry.getNextHops().end());
+ BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
+ BOOST_CHECK_EQUAL(it->getEndpointId(), 300);
BOOST_CHECK_EQUAL(it->getCost(), 30);
++it;
+ BOOST_REQUIRE(it != entry.getNextHops().end());
+ BOOST_CHECK_EQUAL(&it->getFace(), face2.get());
+ BOOST_CHECK_EQUAL(it->getEndpointId(), 400);
+ BOOST_CHECK_EQUAL(it->getCost(), 40);
+
+ ++it;
BOOST_CHECK(it == entry.getNextHops().end());
}
- entry.removeNextHop(*face1);
- // [(face2,10)]
- BOOST_CHECK_EQUAL(entry.getNextHops().size(), 1);
+ entry.addOrUpdateNextHop(*face1, 200, 50);
+ // [(face2,100,10), (face1,300,30), (face2,400,40), (face1,200,50)]
+ BOOST_CHECK_EQUAL(entry.getNextHops().size(), 4);
+ {
+ NextHopList::const_iterator it = entry.getNextHops().begin();
+ BOOST_REQUIRE(it != entry.getNextHops().end());
+ BOOST_CHECK_EQUAL(&it->getFace(), face2.get());
+ BOOST_CHECK_EQUAL(it->getEndpointId(), 100);
+ BOOST_CHECK_EQUAL(it->getCost(), 10);
+
+ ++it;
+ BOOST_REQUIRE(it != entry.getNextHops().end());
+ BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
+ BOOST_CHECK_EQUAL(it->getEndpointId(), 300);
+ BOOST_CHECK_EQUAL(it->getCost(), 30);
+
+ ++it;
+ BOOST_REQUIRE(it != entry.getNextHops().end());
+ BOOST_CHECK_EQUAL(&it->getFace(), face2.get());
+ BOOST_CHECK_EQUAL(it->getEndpointId(), 400);
+ BOOST_CHECK_EQUAL(it->getCost(), 40);
+
+ ++it;
+ BOOST_REQUIRE(it != entry.getNextHops().end());
+ BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
+ BOOST_CHECK_EQUAL(it->getEndpointId(), 200);
+ BOOST_CHECK_EQUAL(it->getCost(), 50);
+
+ ++it;
+ BOOST_CHECK(it == entry.getNextHops().end());
+ }
+
+ entry.removeNextHop(*face1, 200);
+ // [(face2,100,10), (face1,300,30), (face2,400,40)]
+ BOOST_CHECK_EQUAL(entry.getNextHops().size(), 3);
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getFace().getId(), face2->getId());
+ BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getEndpointId(), 100);
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getCost(), 10);
- entry.removeNextHop(*face1);
- // [(face2,10)]
- BOOST_CHECK_EQUAL(entry.getNextHops().size(), 1);
+ entry.removeNextHop(*face1, 200);
+ // [(face2,100,10), (face1,300,30), (face2,400,40)]
+ BOOST_CHECK_EQUAL(entry.getNextHops().size(), 3);
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getFace().getId(), face2->getId());
+ BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getEndpointId(), 100);
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getCost(), 10);
- entry.removeNextHop(*face2);
+ entry.removeNextHop(*face2,100);
+ // [(face1,300,30), (face2,400,40)]
+ BOOST_CHECK_EQUAL(entry.getNextHops().size(), 2);
+
+ entry.removeNextHop(*face2,400);
+ // [(face1,300,30)]
+ BOOST_CHECK_EQUAL(entry.getNextHops().size(), 1);
+
+ entry.removeNextHop(*face1,300);
// []
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 0);
- entry.removeNextHop(*face2);
+ entry.removeNextHop(*face1,300);
// []
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 0);
}