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