Add NextHopFaceId test scenario
Add libssl-dev to install_dependencies.py
refs #1942
Change-Id: I39270df30f5946e9acc18e1c008a30b6184bca47
diff --git a/install_helpers/tools/test-nexthopfaceid-consumer.cpp b/install_helpers/tools/test-nexthopfaceid-consumer.cpp
new file mode 100644
index 0000000..90ba6b6
--- /dev/null
+++ b/install_helpers/tools/test-nexthopfaceid-consumer.cpp
@@ -0,0 +1,102 @@
+/**
+ * Consumer for the NextHopFaceId test (test_nexthopfaceid)
+ *
+ * Author: Eric Newberry <enewberry@email.arizona.edu>
+ *
+ * Based on ndn-cxx example consumer
+ */
+
+#include <ndn-cxx/lp/tags.hpp>
+#include <ndn-cxx/mgmt/nfd/controller.hpp>
+
+#include <cstring>
+#include <cstdlib>
+
+using namespace ndn;
+
+class TestNextHopFaceIdConsumer : noncopyable
+{
+public:
+ void
+ run(Name name, bool enableLocalFields, int nextHopFaceId)
+ {
+ nfd::ControlParameters params;
+ params.setFlagBit(nfd::BIT_LOCAL_FIELDS_ENABLED, enableLocalFields);
+
+ ndn::nfd::Controller controller(m_face, m_keyChain);
+ controller.start<ndn::nfd::FaceUpdateCommand>(params,
+ nullptr,
+ [] (const ndn::nfd::ControlResponse& resp) {
+ throw std::runtime_error("Unable to toggle local fields");
+ });
+ m_face.processEvents();
+
+ // Now, send test case Interest
+ Interest interest(name);
+
+ if (nextHopFaceId != -1) {
+ interest.setTag(make_shared<lp::NextHopFaceIdTag>(nextHopFaceId));
+ }
+
+ m_face.expressInterest(interest,
+ [] (const Interest& interest, const Data& data) {
+ std::cout.write(reinterpret_cast<const char*>(data.getContent().value()),
+ data.getContent().value_size());
+ std::cout << std::endl;
+ },
+ [] (const Interest& interest, const lp::Nack& nack) {
+ std::cout << "Nack" << std::endl;
+ },
+ [] (const Interest& interest) {
+ std::cout << "Timeout" << std::endl;
+ });
+ m_face.processEvents();
+ }
+
+private:
+ Face m_face;
+ KeyChain m_keyChain;
+};
+
+static void
+usage(const char* name)
+{
+ std::cerr << "Usage: " << name
+ << " [prefix] [enableLocalFields - t/f] [NextHopFaceId (-1 if not set)]" << std::endl;
+}
+
+int
+main(int argc, char** argv)
+{
+ if (argc != 4) {
+ usage(argv[0]);
+ return -1;
+ }
+
+ Name name(argv[1]);
+
+ bool enableLocalFields = false;
+ if (std::strcmp(argv[2], "t") == 0) {
+ enableLocalFields = true;
+ }
+ else if (std::strcmp(argv[2], "f") == 0) {
+ enableLocalFields = false;
+ }
+ else {
+ usage(argv[0]);
+ return -1;
+ }
+
+ int nextHopFaceId = std::atoi(argv[3]);
+
+ try {
+ TestNextHopFaceIdConsumer consumer;
+ consumer.run(name, enableLocalFields, nextHopFaceId);
+ }
+ catch (const std::exception& e) {
+ std::cerr << "ERROR: " << e.what() << std::endl;
+ return -2;
+ }
+
+ return 0;
+}