ndnpeek: replace --link-file with --fwhint
refs #4207, #5187
Change-Id: I8213e971520d3edab631634a03bf7950d265dc11
diff --git a/tools/peek/ndnpeek/main.cpp b/tools/peek/ndnpeek/main.cpp
index ff9f2af..22523b7 100644
--- a/tools/peek/ndnpeek/main.cpp
+++ b/tools/peek/ndnpeek/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,6 +28,7 @@
*/
#include "ndnpeek.hpp"
+#include "core/program-options-ext.hpp"
#include "core/version.hpp"
#include <ndn-cxx/util/io.hpp>
@@ -85,7 +86,8 @@
interestOptDesc.add_options()
("prefix,P", po::bool_switch(&options.canBePrefix), "set CanBePrefix")
("fresh,f", po::bool_switch(&options.mustBeFresh), "set MustBeFresh")
- ("link-file", po::value<std::string>(), "set ForwardingHint from a raw binary file")
+ ("fwhint,F", po::value<std::vector<Name>>(&options.forwardingHint)->composing(),
+ "add ForwardingHint delegation name")
("lifetime,l", po::value<time::milliseconds::rep>()->default_value(options.interestLifetime.count()),
"set InterestLifetime, in milliseconds")
("hop-limit,H", po::value<int>(), "set HopLimit")
@@ -98,7 +100,7 @@
po::options_description hiddenOptDesc;
hiddenOptDesc.add_options()
- ("name", po::value<std::string>(), "Interest name");
+ ("name", po::value<Name>(&options.name), "Interest name");
po::options_description optDesc;
optDesc.add(visibleOptDesc).add(hiddenOptDesc);
@@ -132,14 +134,6 @@
return 2;
}
- try {
- options.name = vm["name"].as<std::string>();
- }
- catch (const Name::Error& e) {
- std::cerr << "ERROR: invalid name: " << e.what() << std::endl;
- return 2;
- }
-
if (vm.count("timeout") > 0) {
options.timeout = time::milliseconds(vm["timeout"].as<time::milliseconds::rep>());
if (*options.timeout < 0_ms) {
@@ -148,19 +142,6 @@
}
}
- if (vm.count("link-file") > 0) {
- auto filename = vm["link-file"].as<std::string>();
- std::ifstream linkFile = openBinaryFile(filename);
- if (!linkFile) {
- return 2;
- }
- options.link = io::load<Link>(linkFile, io::NO_ENCODING);
- if (!options.link) {
- std::cerr << "ERROR: cannot parse a valid Link object from file '" << filename << "'" << std::endl;
- return 2;
- }
- }
-
options.interestLifetime = time::milliseconds(vm["lifetime"].as<time::milliseconds::rep>());
if (options.interestLifetime < 0_ms) {
std::cerr << "ERROR: InterestLifetime cannot be negative" << std::endl;
diff --git a/tools/peek/ndnpeek/ndnpeek.cpp b/tools/peek/ndnpeek/ndnpeek.cpp
index cc9286c..01fd6de 100644
--- a/tools/peek/ndnpeek/ndnpeek.cpp
+++ b/tools/peek/ndnpeek/ndnpeek.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -63,9 +63,7 @@
Interest interest(m_options.name);
interest.setCanBePrefix(m_options.canBePrefix);
interest.setMustBeFresh(m_options.mustBeFresh);
- if (m_options.link) {
- interest.setForwardingHint(m_options.link->getDelegationList());
- }
+ interest.setForwardingHint(m_options.forwardingHint);
interest.setInterestLifetime(m_options.interestLifetime);
interest.setHopLimit(m_options.hopLimit);
if (m_options.applicationParameters) {
diff --git a/tools/peek/ndnpeek/ndnpeek.hpp b/tools/peek/ndnpeek/ndnpeek.hpp
index afb0ea7..ce37712 100644
--- a/tools/peek/ndnpeek/ndnpeek.hpp
+++ b/tools/peek/ndnpeek/ndnpeek.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -47,7 +47,7 @@
Name name;
bool canBePrefix = false;
bool mustBeFresh = false;
- shared_ptr<Link> link;
+ std::vector<Name> forwardingHint;
time::milliseconds interestLifetime = DEFAULT_INTEREST_LIFETIME;
optional<uint8_t> hopLimit;
shared_ptr<Buffer> applicationParameters;