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/docs/conf.py b/docs/conf.py
index 0dc99d2..f3fec93 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -12,8 +12,9 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys
+import datetime
import os
+import sys
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -62,7 +63,7 @@
# General information about the project.
project = u'NFD - Named Data Networking Forwarding Daemon'
-copyright = u'2014-2016, Named Data Networking Project'
+copyright = u'2014-%d, Named Data Networking Project' % datetime.date.today().year
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -241,21 +242,21 @@
# (source start file, name, description, authors, manual section).
man_pages = [
('manpages/nfd', 'nfd', u'Named Data Networking Forwarding Daemon', None, 1),
+ ('manpages/nfdc', 'nfdc', u'interact with NFD management', None, 1),
+ ('manpages/nfdc-status', 'nfdc-status', u'show NFD status', None, 1),
+ ('manpages/nfdc-face', 'nfdc-face', u'show and manipulate NFD faces', None, 1),
+ ('manpages/nfdc-route', 'nfdc-route', u'show and manipulate NFD routes', None, 1),
+ ('manpages/nfdc-strategy', 'nfdc-strategy', u'show and manipulate NFD strategy choices', None, 1),
+ ('manpages/nfd-status', 'nfd-status', u'comprehensive report of NFD status', None, 1),
+ ('manpages/nfd-status-http-server', 'nfd-status-http-server',
+ u'NFD status HTTP server', None, 1),
('manpages/ndn-autoconfig-server', 'ndn-autoconfig-server',
u'NDN auto-configuration server', None, 1),
('manpages/ndn-autoconfig', 'ndn-autoconfig',
u'NDN auto-configuration client', None, 1),
('manpages/ndn-autoconfig.conf', 'ndn-autoconfig.conf',
u'NDN auto-configuration client configuration file', None, 5),
- ('manpages/nfdc', 'nfdc', u'show / manipulate NFD state and configuration', None, 1),
- ('manpages/nfdc-status', 'nfdc-status', u'show NFD status', None, 1),
- ('manpages/nfdc-face', 'nfdc-face', u'show and manipulate NFD faces', None, 1),
- ('manpages/nfdc-route', 'nfdc-route', u'show and manipulate NFD routes', None, 1),
- ('manpages/nfdc-strategy', 'nfdc-strategy', u'show and manipulate NFD strategy choices', None, 1),
('manpages/nfd-autoreg', 'nfd-autoreg', u'NFD Auto-registration Server', None, 1),
- ('manpages/nfd-status-http-server', 'nfd-status-http-server',
- u'NFD status HTTP server', None, 1),
- ('manpages/nfd-status', 'nfd-status', u'Command-line utility to show NFD status', None, 1),
]
diff --git a/docs/manpages/nfd-status.rst b/docs/manpages/nfd-status.rst
index 732cd86..f140483 100644
--- a/docs/manpages/nfd-status.rst
+++ b/docs/manpages/nfd-status.rst
@@ -1,56 +1,14 @@
nfd-status
==========
-Usage
------
+SYNOPSIS
+--------
+| nfd-status
-::
-
- nfd-status
-
-Description
+DESCRIPTION
-----------
+**nfd-status** is an alias of **nfdc status report**, which prints a comprehensive report of NFD status.
-``nfd-status`` is an alias of ``nfdc status report``, which generates a comprehensive report of NFD status.
-
-Deprecated Options
-------------------
-
-nfd-status used to support the following command line options.
-They have been deprecated and will be removed in a future release of NFD.
-
-``-v``
- Print general status. Use ``nfdc status show`` instead.
-
-``-c``
- Print channel list. Use ``nfdc channel list`` instead.
-
-``-f``
- Print face list. Use ``nfdc face list`` instead.
-
-``-b``
- Print FIB entries. Use ``nfdc fib list`` instead.
-
-``-r``
- Print RIB entries. Use ``nfdc route list`` instead.
-
-``-s``
- Print strategy choices. Use ``nfdc strategy list`` instead.
-
-``-x``
- Generate a comprehensive report of NFD status in XML format. Use ``nfdc status report xml`` instead.
-
-``-h``
- Print usage information.
-
-``-V``
- Show version information of nfd-status and exit.
-
-Exit Codes
-----------
-
-0: Success
-
-1: An unspecified error occurred
-
-2: Malformed command line
+SEE ALSO
+--------
+nfdc-status(1)
diff --git a/docs/manpages/nfdc-status.rst b/docs/manpages/nfdc-status.rst
index c5bdede..cfbdec4 100644
--- a/docs/manpages/nfdc-status.rst
+++ b/docs/manpages/nfdc-status.rst
@@ -11,7 +11,7 @@
The **nfdc status show** command shows general status of NFD, including its version,
uptime, data structure counters, and global packet counters.
-The **nfdc status report** command generates a comprehensive report of NFD status, including:
+The **nfdc status report** command prints a comprehensive report of NFD status, including:
- general status (individually available from **nfdc status show**)
- list of channels (individually available from **nfdc channel list**)
diff --git a/docs/manpages/nfdc.rst b/docs/manpages/nfdc.rst
index c6fb3b8..406bf35 100644
--- a/docs/manpages/nfdc.rst
+++ b/docs/manpages/nfdc.rst
@@ -1,206 +1,48 @@
nfdc
====
-Usage
------
-
-::
-
- nfdc [-h] COMMAND [<command options>]
-
-
-Description
------------
-
-``nfdc`` is a tool to manipulate routing information base (RIB), forwarding information
-base (FIB), and StrategyChoices table (i.e., which strategy should be used by which
-namespaces).
-
-Options
--------
-
-``-h``
- Print usage information.
-
-``COMMAND``
-
- ``register``
- Register a new or update existing routing entry in Routing Information Base (RIB).
-
- ``register [-I] [-C] [-c <cost>] [-e expiration time] [-o origin] <prefix> <faceId | faceUri>``
-
- ``-I``
- Unset CHILD_INHERIT flag from the routing entry.
-
- ``-C``
- Set CAPTURE flag in the routing entry.
-
- ``-c <cost>``
- Cost for the RIB entry (default is 0).
-
- ``-e <expiration time>``
- Expiration time of the RIB entry in milliseconds. If not specified, the entry remains in FIB
- for the lifetime of the associated face.
-
- ``-o <origin>``
- Origin of the registration request (default is 255).
- 0 for Local producer applications, 128 for NLSR, 255 for static routes.
-
- ``prefix``
- A prefix of an existing or to be created RIB entry, for which routing entry is
- requested to be added or updated.
-
- ``faceId``
- An existing NFD Face ID number, which can be obtained, for example, using
- ``nfd-status`` command.
-
- ``faceUri``
- URI of the existing or to be created Face.
-
- ``unregister``
- Unregister an existing routing entry from Routing Information Base (RIB).
-
- ``unregister [-o origin] <prefix> <faceId>``
-
- ``-o <origin>``
- Origin of the unregistration request (default is 255).
-
- ``prefix``
- A prefix of an existing RIB entry, from which routing entry is requested to be
- removed.
-
- ``faceId``
- An existing NFD Face ID number, which can be obtained, for example, using
- ``nfd-status`` command.
-
- ``create``
- Create a UDP unicast or TCP Face
-
- ``create [-P] <faceUri>``
-
- ``-P``
- create permanent (instead of persistent) face:
-
- .. note::
- Persistent (default) faces remain open until they are explicitly destroyed or
- there is a transport failure. Permanent faces remain open until they are
- explicitly destroyed; any transport failures will be recovered internally.
-
- ``faceUri``
- UDP unicast or TCP Face URI::
-
- UDP unicast: udp[4|6]://<remote-IP-or-host>[:<remote-port>]
- TCP: tcp[4|6]://<remote-IP-or-host>[:<remote-port>]
-
- ``destroy``
- Create an existing UDP unicast or TCP Face.
-
- ``destroy <faceId | faceUri>``
-
- ``faceId``
- An existing NFD Face ID number, which can be obtained, for example, using
- ``nfd-status`` command.
-
- ``faceUri``
- UDP unicast or TCP Face URI::
-
- UDP unicast: udp[4|6]://<remote-IP-or-host>[:<remote-port>]
- TCP: tcp[4|6]://<remote-IP-or-host>[:<remote-port>]
-
- ``set-strategy``
- Select strategy to be used for the specified namespace
-
- ``set-strategy <namespace> <strategy-name>``
-
- ``namespace``
- Namespace that will use the specified strategy.
-
- Note that more specific namespace(s) can use different strategy or strategies.
- For example, if namespace ``/A/B/C`` was using strategy
- ``ndn:/localhost/nfd/strategy/best-route`` before running ``set-strategy`` on
- ``/A`` namespace, it will continue using the same strategy no matter which
- namespace was specified for ``/A``.
-
- ``strategy-name``
- Name of one of the available strategies.
-
- Currently, NFD supports the following strategies::
-
- ndn:/localhost/nfd/strategy/best-route
- ndn:/localhost/nfd/strategy/multicast
- ndn:/localhost/nfd/strategy/client-control
- ndn:/localhost/nfd/strategy/ncc
- ndn:/localhost/nfd/strategy/access
-
- ``unset-strategy``
- Unset the strategy for a given ``namespace``.
-
- Effectively, this command select parent's namespace strategy to be used for the
- specified ``namespace``.
-
- ``unset-strategy <namespace>``
-
- ``namespace``
- Namespace from which namespace customization should be removed.
-
- ``add-nexthop``
- Directly add nexthop entry info NFD's Forwarding Information Base (FIB). This command
- is intended only for debugging purposes. Normally, prefix-nexhop association should
- be registered in Routing Information Base using ``register`` command.
-
- ``add-nexthop [-c <cost>] <prefix> <faceId | faceUri>``
-
- ``-c <cost>``
- Cost for the nexthop entry to be inserted (default is 0).
-
- ``prefix``
- A prefix of an existing or to be created FIB entry, to which nexthop
- entry is requested to be added.
-
- ``faceId``
- An existing NFD Face ID number, which can be obtained, for example, using
- ``nfd-status`` command
-
- ``faceUri``
- URI of the existing or to be created Face.
-
- ``remove-nexthop``
- Directly remove nexthop entry from NFD'S FIB. This command
- is intended only for debugging purposes. Normally, prefix-nexhop association should
- be unregistered from Routing Information Base using ``unregister`` command.
-
- ``remove-nexthop <prefix> <faceId>``
-
- ``prefix``
- A prefix of an existing FIB entry, from which nexthop entry is requested to be removed.
-
- ``faceId``
- An existing NFD Face ID number, which can be obtained, for example, using
- ``nfd-status`` command.
-
- Note that when ``faceId`` is the last Face associated with ``prefix`` FIB entry,
- the whole FIB entry will be removed.
-
-Exit Codes
-----------
-
-0: Success
-
-1: An unspecified error occurred
-
-2: Malformed command line
-
-Examples
+SYNOPSIS
--------
+| nfdc COMMAND ARGUMENTS
+| nfdc [-h]
+| nfdc -V
+| nfdc help COMMAND
-Add a namespace to a face uri:
+DESCRIPTION
+-----------
+**nfdc** is a tool to manage a running instance of NFD.
+Features of nfdc are organized into subcommands.
+To print a list of all subcommands, run **nfdc** without arguments.
+To show how to use a subcommand, run **nfdc help** followed by the subcommand name.
+
+OPTIONS
+-------
+<COMMAND>
+ A subcommand name.
+ It usually contains a noun and a verb.
+
+<ARGUMENTS>
+ Arguments to the subcommand.
+
+-h
+ Print a list of available subcommands.
+
+-V
+ Print version number.
+
+EXAMPLES
+--------
+Print a list of all subcommands:
::
- nfdc register ndn:/app1/video udp://192.168.1.2
+ $ nfdc
-Set strategy to a name:
-
+Show how to use ``nfdc face create`` command:
::
- nfdc set-strategy ndn:/app1/video ndn:/localhost/nfd/strategy/broadcast
+ $ nfdc help face create
+
+SEE ALSO
+--------
+nfdc-status(1), nfdc-face(1), nfdc-route(1), nfdc-strategy(1)
diff --git a/tools/nfd-status.sh b/tools/nfd-status.sh
index 6b9336e..f306b9d 100755
--- a/tools/nfd-status.sh
+++ b/tools/nfd-status.sh
@@ -1,9 +1,2 @@
#!@BASH@
-if [[ $# -gt 0 ]]; then
- echo 'nfd-status command line options are deprecated.' >&2
- echo 'Use the `nfdc` subcommands instead. See `nfdc help` for details.' >&2
- exec "$(dirname "$0")/nfdc" legacy-nfd-status "$@"
-else
- # nfd-status is an alias of `nfdc status report`
- exec "$(dirname "$0")/nfdc" status report
-fi
+exec "$(dirname "$0")/nfdc" status report
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