Add Mobility with Link scenario
refs #3074
Change-Id: I2d4c12195ad0441370c34260425be482ed7a47f4
diff --git a/install_helpers/tools/Makefile b/install_helpers/tools/Makefile
index 0d802a4..6a41305 100644
--- a/install_helpers/tools/Makefile
+++ b/install_helpers/tools/Makefile
@@ -3,7 +3,7 @@
LIBS = `pkg-config --libs libndn-cxx`
DESTDIR ?= /usr/local
-PROGRAMS = test-nack-consumer test-nexthopfaceid-consumer
+PROGRAMS = test-nack-consumer test-nexthopfaceid-consumer generate-link-object
all: $(PROGRAMS)
diff --git a/install_helpers/tools/generate-link-object.cpp b/install_helpers/tools/generate-link-object.cpp
new file mode 100644
index 0000000..91d4560
--- /dev/null
+++ b/install_helpers/tools/generate-link-object.cpp
@@ -0,0 +1,35 @@
+/**
+ * Generates a predefined link object and outputs it to a file
+ *
+ * Author: Eric Newberry <enewberry@email.arizona.edu>
+ */
+
+#include <ndn-cxx/link.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/util/io.hpp>
+
+#include <iostream>
+
+int
+main(int argc, char* argv[])
+{
+ if (argc < 5 || argc % 2 != 1) {
+ std::cout << "Usage: " << argv[0] << " [outfile] [name] [pref-1] [delegation-1] ... [pref-n] [delegation-n]" << std::endl;
+ return -1;
+ }
+
+ // Create initial link object
+ ndn::Link link(argv[2]);
+
+ // Load delegations into object
+ for (int i = 0; i < (argc - 3) / 2; i++) {
+ link.addDelegation(std::stoi(argv[2 * i + 3]), argv[2 * i + 4]);
+ }
+
+ // Sign and save object
+ ndn::KeyChain keyChain;
+ keyChain.sign(link);
+ link.wireEncode();
+ ndn::io::save(link, argv[1]);
+ return 0;
+}