publisher: implement routing table dataset publisher
refs: #3631, #3634
Change-Id: I7e961fdd0857690bee65d2bdfa4cf3de90ccac06
diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index 4b702fc..896e7b3 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -22,7 +22,7 @@
#ifndef NLSR_PUBLISHER_FIXTURE_HPP
#define NLSR_PUBLISHER_FIXTURE_HPP
-#include "publisher/lsdb-dataset-interest-handler.hpp"
+#include "publisher/dataset-interest-handler.hpp"
#include "nlsr.hpp"
#include "../boost-test.hpp"
@@ -48,6 +48,7 @@
: face(m_ioService, m_keyChain, {true, true})
, nlsr(m_ioService, m_scheduler, face, m_keyChain)
, lsdb(nlsr.getLsdb())
+ , rt1(nlsr.getRoutingTable())
{
INIT_LOGGERS("/tmp/", "TRACE");
nlsr.getConfParameter().setNetwork("/ndn");
@@ -100,6 +101,13 @@
}
}
+ NextHop
+ createNextHop(const std::string& faceUri, double cost)
+ {
+ NextHop nexthop(faceUri, cost);
+ return nexthop;
+ }
+
CoordinateLsa
createCoordinateLsa(const std::string& origin, double radius, std::vector<double> angle)
{
@@ -159,6 +167,7 @@
Lsdb& lsdb;
ndn::security::pib::Identity routerId;
+ RoutingTable& rt1;
};
} // namespace test
diff --git a/tests/publisher/test-lsdb-dataset-interest-handler.cpp b/tests/publisher/test-dataset-interest-handler.cpp
similarity index 81%
rename from tests/publisher/test-lsdb-dataset-interest-handler.cpp
rename to tests/publisher/test-dataset-interest-handler.cpp
index cd9fcf3..ccd3b64 100644
--- a/tests/publisher/test-lsdb-dataset-interest-handler.cpp
+++ b/tests/publisher/test-dataset-interest-handler.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -19,7 +19,7 @@
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
-#include "publisher/lsdb-dataset-interest-handler.hpp"
+#include "publisher/dataset-interest-handler.hpp"
#include "tests/test-common.hpp"
#include "tlv/tlv-nlsr.hpp"
@@ -28,6 +28,8 @@
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
+#include <iostream>
+
namespace nlsr {
namespace test {
@@ -36,6 +38,7 @@
std::function<bool(const ndn::Block&)> isSameType)
{
face.processEvents(ndn::time::milliseconds(30));
+
BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
ndn::Block parser(face.sentData[0].getContent());
@@ -50,17 +53,6 @@
face.sentData.clear();
}
-void
-checkErrorResponse(ndn::util::DummyClientFace& face, uint64_t expectedCode)
-{
- BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
-
- ndn::nfd::ControlResponse response(face.sentData[0].getContent().blockFromValue());
- BOOST_CHECK_EQUAL(response.getCode(), expectedCode);
-
- face.sentData.clear();
-}
-
BOOST_FIXTURE_TEST_SUITE(PublisherTestLsdbDatasetInterestHandler, PublisherFixture)
BOOST_AUTO_TEST_CASE(Localhost)
@@ -83,6 +75,14 @@
nameLsa.addName("/RouterA/name1");
lsdb.installNameLsa(nameLsa);
+ // Install routing table
+ RoutingTableEntry rte1("desrouter1");
+ const ndn::Name& DEST_ROUTER = rte1.getDestination();
+
+ NextHop nh = createNextHop("udp://face-test1", 10);
+
+ rt1.addNextHop(DEST_ROUTER, nh);
+
// Request adjacency LSAs
face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("adjacencies")));
processDatasetInterest(face,
@@ -98,10 +98,11 @@
processDatasetInterest(face,
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
- // Request LSDB Status
- face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("list")));
+ // Request Routing Table
+ face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/routing-table")));
processDatasetInterest(face,
- [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::LsdbStatus; });
+ [] (const ndn::Block& block) {
+ return block.type() == ndn::tlv::nlsr::RouteTableEntry; });
}
@@ -119,6 +120,14 @@
CoordinateLsa coordinateLsa = createCoordinateLsa("/RouterA", 10.0, angles);
lsdb.installCoordinateLsa(coordinateLsa);
+ //Install routing table
+ RoutingTableEntry rte1("desrouter1");
+ const ndn::Name& DEST_ROUTER = rte1.getDestination();
+
+ NextHop nh = createNextHop("udp://face-test1", 10);
+
+ rt1.addNextHop(DEST_ROUTER, nh);
+
// Request adjacency LSAs
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("adjacencies")));
processDatasetInterest(face,
@@ -134,10 +143,11 @@
processDatasetInterest(face,
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
- // Request LSDB Status
- face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("list")));
+ // Request Routing Table
+ face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/routing-table")));
processDatasetInterest(face,
- [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::LsdbStatus; });
+ [] (const ndn::Block& block) {
+ return block.type() == ndn::tlv::nlsr::RouteTableEntry; });
}
BOOST_AUTO_TEST_SUITE_END()