fib: add EndpointId field in NextHop record
refs: #4284
Change-Id: If0cfc21cfa81d6fa3c1590ecdce8fbbc1ea95e13
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);
}