tools: delete legacy nfdc and nfd-status invocations
The following legacy nfdc sub-commands are deleted:
- register
- unregister
- create
- destroy
- set-strategy
- unset-strategy
- add-nexthop
- remove nexthop
nfd-status no longer accepts command line arguments.
refs #4198
Change-Id: I3ec61fd24c09599c87f07bd92d8f0b5f4e7c70de
diff --git a/tools/nfdc/available-commands.cpp b/tools/nfdc/available-commands.cpp
index 0d4847f..272c13d 100644
--- a/tools/nfdc/available-commands.cpp
+++ b/tools/nfdc/available-commands.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -26,8 +26,6 @@
#include "available-commands.hpp"
#include "face-module.hpp"
#include "help.hpp"
-#include "legacy-nfdc.hpp"
-#include "legacy-status.hpp"
#include "rib-module.hpp"
#include "status.hpp"
#include "strategy-choice-module.hpp"
@@ -44,35 +42,6 @@
FaceModule::registerCommands(parser);
RibModule::registerCommands(parser);
StrategyChoiceModule::registerCommands(parser);
-
- registerLegacyStatusCommand(parser);
-
- struct LegacyNfdcCommandDefinition
- {
- std::string subcommand;
- std::string title;
- std::string replacementCommand; ///< replacement for deprecated legacy subcommand
- };
- const std::vector<LegacyNfdcCommandDefinition> legacyNfdcSubcommands{
- {"register", "register a prefix", "route add"},
- {"unregister", "unregister a prefix", "route remove"},
- {"create", "create a face", "face create"},
- {"destroy", "destroy a face", "face destroy"},
- {"set-strategy", "set strategy choice on namespace", "strategy set"},
- {"unset-strategy", "unset strategy choice on namespace", "strategy unset"},
- {"add-nexthop", "add FIB nexthop", "route add"},
- {"remove-nexthop", "remove FIB nexthop", "route remove"}
- };
- for (const LegacyNfdcCommandDefinition& lncd : legacyNfdcSubcommands) {
- CommandDefinition def(lncd.subcommand, "");
- def.setTitle(lncd.title);
- def.addArg("args", ArgValueType::ANY, Required::NO, Positional::YES);
- auto modes = AVAILABLE_IN_ONE_SHOT | AVAILABLE_IN_HELP;
- if (!lncd.replacementCommand.empty()) {
- modes = modes & ~AVAILABLE_IN_HELP;
- }
- parser.addCommand(def, bind(&legacyNfdcMain, _1, lncd.replacementCommand), modes);
- }
}
} // namespace nfdc
diff --git a/tools/nfdc/command-parser.cpp b/tools/nfdc/command-parser.cpp
index b4c4558..74c5202 100644
--- a/tools/nfdc/command-parser.cpp
+++ b/tools/nfdc/command-parser.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-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -120,7 +120,7 @@
i = m_commands.find({noun, "list"});
}
else {
- // help, exit, quit, legacy nfdc commands
+ // help, exit, quit commands
i = m_commands.find({noun, ""});
}
nameLen = std::min<size_t>(1, tokens.size());
diff --git a/tools/nfdc/face-id-fetcher.cpp b/tools/nfdc/face-id-fetcher.cpp
deleted file mode 100644
index f0bf841..0000000
--- a/tools/nfdc/face-id-fetcher.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2014-2017, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "face-id-fetcher.hpp"
-
-#include <boost/lexical_cast.hpp>
-#include <boost/regex.hpp>
-
-#include <ndn-cxx/mgmt/nfd/face-query-filter.hpp>
-#include <ndn-cxx/mgmt/nfd/face-status.hpp>
-#include <ndn-cxx/security/validator-null.hpp>
-#include <ndn-cxx/util/segment-fetcher.hpp>
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-FaceIdFetcher::FaceIdFetcher(ndn::Face& face,
- ndn::nfd::Controller& controller,
- bool allowCreate,
- const SuccessCallback& onSucceed,
- const FailureCallback& onFail)
- : m_face(face)
- , m_controller(controller)
- , m_allowCreate(allowCreate)
- , m_onSucceed(onSucceed)
- , m_onFail(onFail)
-{
-}
-
-void
-FaceIdFetcher::start(ndn::Face& face,
- ndn::nfd::Controller& controller,
- const std::string& input,
- bool allowCreate,
- const SuccessCallback& onSucceed,
- const FailureCallback& onFail)
-{
- // 1. Try parse input as FaceId, if input is FaceId, succeed with parsed FaceId
- // 2. Try parse input as FaceUri, if input is not FaceUri, fail
- // 3. Canonize faceUri
- // 4. If canonization fails, fail
- // 5. Query for face
- // 6. If query succeeds and finds a face, succeed with found FaceId
- // 7. Create face
- // 8. If face creation succeeds, succeed with created FaceId
- // 9. Fail
-
- boost::regex e("^[a-z0-9]+\\:.*");
- if (!boost::regex_match(input, e)) {
- try {
- uint32_t faceId = boost::lexical_cast<uint32_t>(input);
- onSucceed(faceId);
- return;
- }
- catch (const boost::bad_lexical_cast&) {
- onFail("No valid faceId or faceUri is provided");
- return;
- }
- }
- else {
- FaceUri faceUri;
- if (!faceUri.parse(input)) {
- onFail("FaceUri parse failed");
- return;
- }
-
- auto fetcher = new FaceIdFetcher(std::ref(face), std::ref(controller),
- allowCreate, onSucceed, onFail);
- fetcher->startGetFaceId(faceUri);
- }
-}
-
-void
-FaceIdFetcher::startGetFaceId(const FaceUri& faceUri)
-{
- faceUri.canonize(bind(&FaceIdFetcher::onCanonizeSuccess, this, _1),
- bind(&FaceIdFetcher::onCanonizeFailure, this, _1),
- m_face.getIoService(), time::seconds(4));
-}
-
-void
-FaceIdFetcher::onCanonizeSuccess(const FaceUri& canonicalUri)
-{
- ndn::Name queryName("/localhost/nfd/faces/query");
- ndn::nfd::FaceQueryFilter queryFilter;
- queryFilter.setRemoteUri(canonicalUri.toString());
- queryName.append(queryFilter.wireEncode());
-
- ndn::Interest interestPacket(queryName);
- interestPacket.setMustBeFresh(true);
- interestPacket.setInterestLifetime(time::milliseconds(4000));
- auto interest = std::make_shared<ndn::Interest>(interestPacket);
-
- ndn::util::SegmentFetcher::fetch(
- m_face, *interest, ndn::security::v2::getAcceptAllValidator(),
- bind(&FaceIdFetcher::onQuerySuccess, this, _1, canonicalUri),
- bind(&FaceIdFetcher::onQueryFailure, this, _1, canonicalUri));
-}
-
-void
-FaceIdFetcher::onCanonizeFailure(const std::string& reason)
-{
- fail("Canonize faceUri failed : " + reason);
-}
-
-void
-FaceIdFetcher::onQuerySuccess(const ndn::ConstBufferPtr& data,
- const FaceUri& canonicalUri)
-{
- size_t offset = 0;
- bool isOk = false;
- ndn::Block block;
- std::tie(isOk, block) = ndn::Block::fromBuffer(data, offset);
-
- if (!isOk) {
- if (m_allowCreate) {
- startFaceCreate(canonicalUri);
- }
- else {
- fail("Fail to find faceId");
- }
- }
- else {
- try {
- ndn::nfd::FaceStatus status(block);
- succeed(status.getFaceId());
- }
- catch (const ndn::tlv::Error& e) {
- std::string errorMessage(e.what());
- fail("ERROR: " + errorMessage);
- }
- }
-}
-
-void
-FaceIdFetcher::onQueryFailure(uint32_t errorCode,
- const FaceUri& canonicalUri)
-{
- std::stringstream ss;
- ss << "Cannot fetch data (code " << errorCode << ")";
- fail(ss.str());
-}
-
-void
-FaceIdFetcher::onFaceCreateError(const ndn::nfd::ControlResponse& response,
- const std::string& message)
-{
- std::stringstream ss;
- ss << message << " : " << response.getText() << " (code " << response.getCode() << ")";
- fail(ss.str());
-}
-
-void
-FaceIdFetcher::startFaceCreate(const FaceUri& canonicalUri)
-{
- ndn::nfd::ControlParameters parameters;
- parameters.setUri(canonicalUri.toString());
-
- m_controller.start<ndn::nfd::FaceCreateCommand>(parameters,
- [this] (const ndn::nfd::ControlParameters& result) { succeed(result.getFaceId()); },
- bind(&FaceIdFetcher::onFaceCreateError, this, _1, "Face creation failed"));
-}
-
-void
-FaceIdFetcher::succeed(uint32_t faceId)
-{
- m_onSucceed(faceId);
- delete this;
-}
-
-void
-FaceIdFetcher::fail(const std::string& reason)
-{
- m_onFail(reason);
- delete this;
-}
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
diff --git a/tools/nfdc/face-id-fetcher.hpp b/tools/nfdc/face-id-fetcher.hpp
deleted file mode 100644
index 5e45b7b..0000000
--- a/tools/nfdc/face-id-fetcher.hpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2014-2017, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NFD_TOOLS_NFDC_FACE_ID_FETCHER_HPP
-#define NFD_TOOLS_NFDC_FACE_ID_FETCHER_HPP
-
-#include "core/common.hpp"
-#include <ndn-cxx/face.hpp>
-#include <ndn-cxx/mgmt/nfd/controller.hpp>
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-class FaceIdFetcher
-{
-public:
- typedef std::function<void(uint32_t)> SuccessCallback;
- typedef std::function<void(const std::string&)> FailureCallback;
-
- /** \brief obtain FaceId from input
- * \param face Reference to the Face that should be used to fetch data
- * \param controller Reference to the controller that should be used to sign the Interest
- * \param input User input, either FaceId or FaceUri
- * \param allowCreate Whether creating face is allowed
- * \param onSucceed Callback to be fired when faceId is obtained
- * \param onFail Callback to be fired when an error occurs
- */
- static void
- start(ndn::Face& face,
- ndn::nfd::Controller& controller,
- const std::string& input,
- bool allowCreate,
- const SuccessCallback& onSucceed,
- const FailureCallback& onFail);
-
-private:
- FaceIdFetcher(ndn::Face& face,
- ndn::nfd::Controller& controller,
- bool allowCreate,
- const SuccessCallback& onSucceed,
- const FailureCallback& onFail);
-
- void
- onQuerySuccess(const ndn::ConstBufferPtr& data,
- const FaceUri& canonicalUri);
-
- void
- onQueryFailure(uint32_t errorCode,
- const FaceUri& canonicalUri);
-
- void
- onCanonizeSuccess(const FaceUri& canonicalUri);
-
- void
- onCanonizeFailure(const std::string& reason);
-
- void
- startGetFaceId(const FaceUri& faceUri);
-
- void
- startFaceCreate(const FaceUri& canonicalUri);
-
- void
- onFaceCreateError(const ndn::nfd::ControlResponse& response,
- const std::string& message);
-
- void
- succeed(uint32_t faceId);
-
- void
- fail(const std::string& reason);
-
-private:
- ndn::Face& m_face;
- ndn::nfd::Controller& m_controller;
- bool m_allowCreate;
- SuccessCallback m_onSucceed;
- FailureCallback m_onFail;
-};
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
-
-#endif // NFD_TOOLS_NFDC_FACE_ID_FETCHER_HPP
diff --git a/tools/nfdc/legacy-nfdc.cpp b/tools/nfdc/legacy-nfdc.cpp
deleted file mode 100644
index e0e6bcd..0000000
--- a/tools/nfdc/legacy-nfdc.cpp
+++ /dev/null
@@ -1,405 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "legacy-nfdc.hpp"
-#include "face-id-fetcher.hpp"
-
-#include <boost/program_options.hpp>
-#include <boost/regex.hpp>
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-using ndn::nfd::ControlParameters;
-
-const time::milliseconds LegacyNfdc::DEFAULT_EXPIRATION_PERIOD = time::milliseconds::max();
-const uint64_t LegacyNfdc::DEFAULT_COST = 0;
-
-LegacyNfdc::LegacyNfdc(Face& face, KeyChain& keyChain)
- : m_flags(ndn::nfd::ROUTE_FLAG_CHILD_INHERIT)
- , m_cost(DEFAULT_COST)
- , m_origin(ndn::nfd::ROUTE_ORIGIN_STATIC)
- , m_expires(DEFAULT_EXPIRATION_PERIOD)
- , m_facePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
- , m_face(face)
- , m_controller(face, keyChain)
-{
-}
-
-bool
-LegacyNfdc::dispatch(const std::string& command)
-{
- if (command == "add-nexthop") {
- if (m_commandLineArguments.size() != 2)
- return false;
- fibAddNextHop();
- }
- else if (command == "remove-nexthop") {
- if (m_commandLineArguments.size() != 2)
- return false;
- fibRemoveNextHop();
- }
- else if (command == "register") {
- if (m_commandLineArguments.size() != 2)
- return false;
- ribRegisterPrefix();
- }
- else if (command == "unregister") {
- if (m_commandLineArguments.size() != 2)
- return false;
- ribUnregisterPrefix();
- }
- else if (command == "create") {
- if (m_commandLineArguments.size() != 1)
- return false;
- faceCreate();
- }
- else if (command == "destroy") {
- if (m_commandLineArguments.size() != 1)
- return false;
- faceDestroy();
- }
- else if (command == "set-strategy") {
- if (m_commandLineArguments.size() != 2)
- return false;
- strategyChoiceSet();
- }
- else if (command == "unset-strategy") {
- if (m_commandLineArguments.size() != 1)
- return false;
- strategyChoiceUnset();
- }
- else
- return false;
-
- return true;
-}
-
-void
-LegacyNfdc::fibAddNextHop()
-{
- m_name = m_commandLineArguments[0];
- const std::string& faceName = m_commandLineArguments[1];
-
- FaceIdFetcher::start(m_face, m_controller, faceName, true,
- [this] (const uint32_t faceId) {
- ControlParameters parameters;
- parameters
- .setName(m_name)
- .setCost(m_cost)
- .setFaceId(faceId);
-
- m_controller.start<ndn::nfd::FibAddNextHopCommand>(parameters,
- bind(&LegacyNfdc::onSuccess, this, _1, "Nexthop insertion succeeded"),
- bind(&LegacyNfdc::onError, this, _1, "Nexthop insertion failed"));
- },
- bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
-}
-
-void
-LegacyNfdc::fibRemoveNextHop()
-{
- m_name = m_commandLineArguments[0];
- const std::string& faceName = m_commandLineArguments[1];
-
- FaceIdFetcher::start(m_face, m_controller, faceName, false,
- [this] (const uint32_t faceId) {
- ControlParameters parameters;
- parameters
- .setName(m_name)
- .setFaceId(faceId);
-
- m_controller.start<ndn::nfd::FibRemoveNextHopCommand>(parameters,
- bind(&LegacyNfdc::onSuccess, this, _1, "Nexthop removal succeeded"),
- bind(&LegacyNfdc::onError, this, _1, "Nexthop removal failed"));
- },
- bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
-}
-
-void
-LegacyNfdc::ribRegisterPrefix()
-{
- m_name = m_commandLineArguments[0];
- const std::string& faceName = m_commandLineArguments[1];
-
- FaceIdFetcher::start(m_face, m_controller, faceName, true,
- [this] (const uint32_t faceId) {
- ControlParameters parameters;
- parameters
- .setName(m_name)
- .setCost(m_cost)
- .setFlags(m_flags)
- .setOrigin(m_origin)
- .setFaceId(faceId);
-
- if (m_expires != DEFAULT_EXPIRATION_PERIOD)
- parameters.setExpirationPeriod(m_expires);
-
- m_controller.start<ndn::nfd::RibRegisterCommand>(parameters,
- bind(&LegacyNfdc::onSuccess, this, _1, "Successful in name registration"),
- bind(&LegacyNfdc::onError, this, _1, "Failed in name registration"));
- },
- bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
-}
-
-void
-LegacyNfdc::ribUnregisterPrefix()
-{
- m_name = m_commandLineArguments[0];
- const std::string& faceName = m_commandLineArguments[1];
-
- FaceIdFetcher::start(m_face, m_controller, faceName, false,
- [this] (const uint32_t faceId) {
- ControlParameters parameters;
- parameters
- .setName(m_name)
- .setFaceId(faceId)
- .setOrigin(m_origin);
-
- m_controller.start<ndn::nfd::RibUnregisterCommand>(parameters,
- bind(&LegacyNfdc::onSuccess, this, _1, "Successful in unregistering name"),
- bind(&LegacyNfdc::onError, this, _1, "Failed in unregistering name"));
- },
- bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
-}
-
-void
-LegacyNfdc::onCanonizeFailure(const std::string& reason)
-{
- BOOST_THROW_EXCEPTION(Error(reason));
-}
-
-void
-LegacyNfdc::onObtainFaceIdFailure(const std::string& message)
-{
- BOOST_THROW_EXCEPTION(Error(message));
-}
-
-void
-LegacyNfdc::faceCreate()
-{
- boost::regex e("^[a-z0-9]+\\:.*");
- if (!boost::regex_match(m_commandLineArguments[0], e))
- BOOST_THROW_EXCEPTION(Error("invalid uri format"));
-
- FaceUri faceUri;
- faceUri.parse(m_commandLineArguments[0]);
-
- faceUri.canonize(bind(&LegacyNfdc::startFaceCreate, this, _1),
- bind(&LegacyNfdc::onCanonizeFailure, this, _1),
- m_face.getIoService(), time::seconds(4));
-}
-
-void
-LegacyNfdc::startFaceCreate(const FaceUri& canonicalUri)
-{
- ControlParameters parameters;
- parameters.setUri(canonicalUri.toString());
- parameters.setFacePersistency(m_facePersistency);
-
- m_controller.start<ndn::nfd::FaceCreateCommand>(parameters,
- bind(&LegacyNfdc::onSuccess, this, _1, "Face creation succeeded"),
- bind(&LegacyNfdc::onError, this, _1, "Face creation failed"));
-}
-
-void
-LegacyNfdc::faceDestroy()
-{
- ControlParameters parameters;
- const std::string& faceName = m_commandLineArguments[0];
-
- FaceIdFetcher::start(m_face, m_controller, faceName, false,
- [this] (const uint32_t faceId) {
- ControlParameters faceParameters;
- faceParameters.setFaceId(faceId);
-
- m_controller.start<ndn::nfd::FaceDestroyCommand>(faceParameters,
- bind(&LegacyNfdc::onSuccess, this, _1, "Face destroy succeeded"),
- bind(&LegacyNfdc::onError, this, _1, "Face destroy failed"));
- },
- bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
-}
-
-void
-LegacyNfdc::strategyChoiceSet()
-{
- const std::string& name = m_commandLineArguments[0];
- const std::string& strategy = m_commandLineArguments[1];
-
- ControlParameters parameters;
- parameters
- .setName(name)
- .setStrategy(strategy);
-
- m_controller.start<ndn::nfd::StrategyChoiceSetCommand>(parameters,
- bind(&LegacyNfdc::onSuccess, this, _1, "Successfully set strategy choice"),
- bind(&LegacyNfdc::onError, this, _1, "Failed to set strategy choice"));
-}
-
-void
-LegacyNfdc::strategyChoiceUnset()
-{
- const std::string& name = m_commandLineArguments[0];
-
- ControlParameters parameters;
- parameters.setName(name);
-
- m_controller.start<ndn::nfd::StrategyChoiceUnsetCommand>(parameters,
- bind(&LegacyNfdc::onSuccess, this, _1, "Successfully unset strategy choice"),
- bind(&LegacyNfdc::onError, this, _1, "Failed to unset strategy choice"));
-}
-
-void
-LegacyNfdc::onSuccess(const ControlParameters& commandSuccessResult, const std::string& message)
-{
- std::cout << message << ": " << commandSuccessResult << std::endl;
-}
-
-void
-LegacyNfdc::onError(const ndn::nfd::ControlResponse& response, const std::string& message)
-{
- std::ostringstream os;
- os << message << ": " << response.getText() << " (code: " << response.getCode() << ")";
- BOOST_THROW_EXCEPTION(Error(os.str()));
-}
-
-void
-legacyNfdcUsage()
-{
- std::cout << "Usage:\n"
- "nfdc [-h] [-V] COMMAND [<Command Options>]\n"
- " -h print usage and exit\n"
- " -V print version and exit\n"
- "\n"
- " COMMAND can be one of the following:\n"
- " register [-I] [-C] [-c cost] [-e expiration time] [-o origin] name <faceId | faceUri>\n"
- " register name to the given faceId or faceUri\n"
- " -I: unset CHILD_INHERIT flag\n"
- " -C: set CAPTURE flag\n"
- " -c: specify cost (default 0)\n"
- " -e: specify expiration time in ms\n"
- " (by default the entry remains in FIB for the lifetime of the associated face)\n"
- " -o: specify origin\n"
- " 0 for Local producer applications, 128 for NLSR, 255(default) for static routes\n"
- " unregister [-o origin] name <faceId | faceUri>\n"
- " unregister name from the given faceId\n"
- " create [-P] <faceUri> \n"
- " Create a face in one of the following formats:\n"
- " UDP unicast: udp[4|6]://<remote-IP-or-host>[:<remote-port>]\n"
- " TCP: tcp[4|6]://<remote-IP-or-host>[:<remote-port>] \n"
- " -P: create permanent (instead of persistent) face\n"
- " destroy <faceId | faceUri> \n"
- " Destroy a face\n"
- " set-strategy <name> <strategy> \n"
- " Set the strategy for a namespace \n"
- " unset-strategy <name> \n"
- " Unset the strategy for a namespace \n"
- " add-nexthop [-c <cost>] <name> <faceId | faceUri>\n"
- " Add a nexthop to a FIB entry\n"
- " -c: specify cost (default 0)\n"
- " remove-nexthop <name> <faceId | faceUri> \n"
- " Remove a nexthop from a FIB entry\n"
- << std::endl;
-}
-
-void
-legacyNfdcMain(ExecuteContext& ctx, const std::string& replacementCommand)
-{
- if (!replacementCommand.empty()) {
- std::cerr << "'nfdc " << ctx.noun << "' command is deprecated. "
- << "Use 'nfdc " << replacementCommand << "' instead.\n";
- }
-
- LegacyNfdc p(ctx.face, ctx.keyChain);
-
- const std::string& subcommand = ctx.noun;
- auto args = ctx.args.get<std::vector<std::string>>("args");
- bool wantUnsetChildInherit = false;
- bool wantCapture = false;
- bool wantPermanentFace = false;
- int64_t expires = -1;
- std::underlying_type<ndn::nfd::RouteOrigin>::type origin = ndn::nfd::ROUTE_ORIGIN_STATIC;
-
- namespace po = boost::program_options;
- po::options_description options;
- options.add_options()
- (",I", po::bool_switch(&wantUnsetChildInherit))
- (",C", po::bool_switch(&wantCapture))
- (",c", po::value<uint64_t>(&p.m_cost))
- (",e", po::value<int64_t>(&expires))
- (",o", po::value<std::underlying_type<ndn::nfd::RouteOrigin>::type>(&origin))
- (",P", po::bool_switch(&wantPermanentFace));
- po::variables_map vm;
- std::vector<std::string> unparsed;
- try {
- po::parsed_options parsed = po::command_line_parser(args).options(options).allow_unregistered().run();
- unparsed = po::collect_unrecognized(parsed.options, po::include_positional);
- po::store(parsed, vm);
- po::notify(vm);
- }
- catch (const po::error& e) {
- std::cerr << e.what() << std::endl;
- legacyNfdcUsage();
- ctx.exitCode = 2;
- return;
- }
-
- if (wantUnsetChildInherit) {
- p.m_flags &= ~(ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
- }
- if (wantCapture) {
- p.m_flags |= ndn::nfd::ROUTE_FLAG_CAPTURE;
- }
- if (expires >= 0) {
- // accept negative values as no expiration
- p.m_expires = time::milliseconds(expires);
- }
- p.m_origin = static_cast<ndn::nfd::RouteOrigin>(origin);
- if (wantPermanentFace) {
- p.m_facePersistency = ndn::nfd::FACE_PERSISTENCY_PERMANENT;
- }
-
- if (std::any_of(unparsed.begin(), unparsed.end(),
- [] (const std::string& s) { return s.empty() || s[0] == '-'; })) {
- // unrecognized -option
- legacyNfdcUsage();
- ctx.exitCode = 2;
- return;
- }
- p.m_commandLineArguments = unparsed;
-
- bool isOk = p.dispatch(subcommand);
- if (!isOk) {
- legacyNfdcUsage();
- ctx.exitCode = 2;
- return;
- }
- ctx.face.processEvents();
-}
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
diff --git a/tools/nfdc/legacy-nfdc.hpp b/tools/nfdc/legacy-nfdc.hpp
deleted file mode 100644
index 782c255..0000000
--- a/tools/nfdc/legacy-nfdc.hpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NFD_TOOLS_NFDC_LEGACY_NFDC_HPP
-#define NFD_TOOLS_NFDC_LEGACY_NFDC_HPP
-
-#include "execute-command.hpp"
-
-#include <ndn-cxx/encoding/nfd-constants.hpp>
-#include <ndn-cxx/mgmt/nfd/controller.hpp>
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-class LegacyNfdc : noncopyable
-{
-public:
- static const time::milliseconds DEFAULT_EXPIRATION_PERIOD;
- static const uint64_t DEFAULT_COST;
-
- class Error : public std::runtime_error
- {
- public:
- explicit
- Error(const std::string& what)
- : std::runtime_error(what)
- {
- }
- };
-
- LegacyNfdc(Face& face, KeyChain& keyChain);
-
- bool
- dispatch(const std::string& cmd);
-
- /**
- * \brief Adds a nexthop to a FIB entry
- *
- * If the FIB entry does not exist, it is inserted automatically
- *
- * cmd format:
- * [-c cost] name faceId|faceUri
- *
- */
- void
- fibAddNextHop();
-
- /**
- * \brief Removes a nexthop from an existing FIB entry
- *
- * If the last nexthop record in a FIB entry is removed, the FIB entry is also deleted
- *
- * cmd format:
- * name faceId
- *
- */
- void
- fibRemoveNextHop();
-
- /**
- * \brief Registers name to the given faceId or faceUri
- *
- * cmd format:
- * [-I] [-C] [-c cost] name faceId|faceUri
- */
- void
- ribRegisterPrefix();
-
- /**
- * \brief Unregisters name from the given faceId/faceUri
- *
- * cmd format:
- * name faceId/faceUri
- */
- void
- ribUnregisterPrefix();
-
- /**
- * \brief Creates new face
- *
- * This command allows creation of UDP unicast and TCP faces only
- *
- * cmd format:
- * uri
- *
- */
- void
- faceCreate();
-
- /**
- * \brief Destroys face
- *
- * cmd format:
- * faceId|faceUri
- *
- */
- void
- faceDestroy();
-
- /**
- * \brief Sets the strategy for a namespace
- *
- * cmd format:
- * name strategy
- *
- */
- void
- strategyChoiceSet();
-
- /**
- * \brief Unset the strategy for a namespace
- *
- * cmd format:
- * name strategy
- *
- */
- void
- strategyChoiceUnset();
-
-private:
- void
- onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
- const std::string& message);
-
- void
- onError(const ndn::nfd::ControlResponse& response, const std::string& message);
-
- void
- onCanonizeFailure(const std::string& reason);
-
- void
- startFaceCreate(const FaceUri& canonicalUri);
-
- void
- onObtainFaceIdFailure(const std::string& message);
-
-public:
- std::vector<std::string> m_commandLineArguments; // positional arguments
- uint64_t m_flags;
- uint64_t m_cost;
- uint64_t m_faceId;
- ndn::nfd::RouteOrigin m_origin;
- time::milliseconds m_expires;
- std::string m_name;
- ndn::nfd::FacePersistency m_facePersistency;
-
-private:
- Face& m_face;
- ndn::nfd::Controller m_controller;
-};
-
-void
-legacyNfdcUsage();
-
-void
-legacyNfdcMain(ExecuteContext& ctx, const std::string& replacementCommand);
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
-
-#endif // NFD_TOOLS_NFDC_LEGACY_NFDC_HPP
diff --git a/tools/nfdc/legacy-status.cpp b/tools/nfdc/legacy-status.cpp
deleted file mode 100644
index a61defd..0000000
--- a/tools/nfdc/legacy-status.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "legacy-status.hpp"
-#include "core/version.hpp"
-
-#include <boost/program_options.hpp>
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-static void
-showUsage(std::ostream& os, const boost::program_options::options_description& cmdOptions)
-{
- os << "Usage: nfd-status [options]\n\n"
- << "Show NFD version and status information.\n\n"
- << cmdOptions;
-}
-
-/** \brief parse legacy nfd-status command line, and show usage if necessary
- * \return if first item is -1, caller should retrieve and display StatusReport;
- * otherwise, caller should immediately exit with the specified exit code
- */
-static std::tuple<int, StatusReportOptions>
-parseCommandLine(ExecuteContext& ctx, const std::vector<std::string>& args)
-{
- StatusReportOptions options;
-
- namespace po = boost::program_options;
- po::options_description cmdOptions("StatusReportOptions");
- cmdOptions.add_options()
- ("help,h", "print this help message")
- ("version,V", "show program version")
- ("general,v", po::bool_switch(&options.wantForwarderGeneral), "show general status")
- ("channels,c", po::bool_switch(&options.wantChannels), "show channels")
- ("faces,f", po::bool_switch(&options.wantFaces), "show faces")
- ("fib,b", po::bool_switch(&options.wantFib), "show FIB entries")
- ("rib,r", po::bool_switch(&options.wantRib), "show RIB routes")
- ("sc,s", po::bool_switch(&options.wantStrategyChoice), "show strategy choice entries")
- ("xml,x", "output as XML instead of text (implies -vcfbrs)");
- po::variables_map vm;
- try {
- po::store(po::command_line_parser(args).options(cmdOptions).run(), vm);
- po::notify(vm);
- }
- catch (const po::error& e) {
- ctx.err << e.what() << "\n";
- showUsage(ctx.err, cmdOptions);
- return std::make_tuple(2, options);
- }
-
- if (vm.count("help") > 0) {
- showUsage(ctx.out, cmdOptions);
- return std::make_tuple(0, options);
- }
- if (vm.count("version") > 0) {
- ctx.out << "nfd-status " << NFD_VERSION_BUILD_STRING << "\n";
- return std::make_tuple(0, options);
- }
-
- if (vm.count("xml") > 0) {
- options.output = ReportFormat::XML;
- }
- if (options.output == ReportFormat::XML ||
- (!options.wantForwarderGeneral && !options.wantChannels && !options.wantFaces &&
- !options.wantFib && !options.wantRib && !options.wantStrategyChoice)) {
- options.wantForwarderGeneral = options.wantChannels = options.wantFaces =
- options.wantFib = options.wantRib = options.wantStrategyChoice = true;
- }
-
- return std::make_tuple(-1, options);
-}
-
-/** \brief the 'legacy-nfd-status' command
- */
-static void
-legacyNfdStatus(ExecuteContext& ctx)
-{
- auto args = ctx.args.get<std::vector<std::string>>("args");
-
- int exitCode = -1;
- StatusReportOptions options;
- std::tie(exitCode, options) = parseCommandLine(ctx, args);
- if (exitCode >= 0) {
- ctx.exitCode = exitCode;
- return;
- }
-
- reportStatus(ctx, options);
-}
-
-void
-registerLegacyStatusCommand(CommandParser& parser)
-{
- CommandDefinition defLegacyNfdStatus("legacy-nfd-status", "");
- defLegacyNfdStatus
- .addArg("args", ArgValueType::ANY, Required::NO, Positional::YES);
- parser.addCommand(defLegacyNfdStatus, &legacyNfdStatus, AVAILABLE_IN_ALL & ~AVAILABLE_IN_HELP);
-}
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
diff --git a/tools/nfdc/legacy-status.hpp b/tools/nfdc/legacy-status.hpp
deleted file mode 100644
index e200292..0000000
--- a/tools/nfdc/legacy-status.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NFD_TOOLS_NFDC_LEGACY_STATUS_HPP
-#define NFD_TOOLS_NFDC_LEGACY_STATUS_HPP
-
-#include "status.hpp"
-
-namespace nfd {
-namespace tools {
-namespace nfdc {
-
-/** \brief registers 'legacy-nfd-status' command
- */
-void
-registerLegacyStatusCommand(CommandParser& parser);
-
-} // namespace nfdc
-} // namespace tools
-} // namespace nfd
-
-#endif // NFD_TOOLS_NFDC_LEGACY_STATUS_HPP