blob: 99a53e08436400f8712362af6817535e0288c7b9 [file] [log] [blame]
Junxiao Shi64567bb2016-09-04 16:00:27 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2016, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#include "available-commands.hpp"
27#include "status-report.hpp"
28#include "status-main.hpp"
29#include "legacy-nfdc.hpp"
30
31namespace nfd {
32namespace tools {
33namespace nfdc {
34
Junxiao Shi737c43c2016-09-14 02:51:44 +000035static int
36statusReport(ExecuteContext& ctx)
Junxiao Shi64567bb2016-09-04 16:00:27 +000037{
Junxiao Shi737c43c2016-09-14 02:51:44 +000038 ReportFormat fmt = ctx.args.get<ReportFormat>("format", ReportFormat::TEXT);
Junxiao Shi64567bb2016-09-04 16:00:27 +000039 switch (fmt) {
40 case ReportFormat::XML:
Junxiao Shi737c43c2016-09-14 02:51:44 +000041 return statusMain(std::vector<std::string>{"-x"}, ctx.face, ctx.keyChain);
Junxiao Shi64567bb2016-09-04 16:00:27 +000042 case ReportFormat::TEXT:
Junxiao Shi737c43c2016-09-14 02:51:44 +000043 return statusMain(std::vector<std::string>{}, ctx.face, ctx.keyChain);
Junxiao Shi64567bb2016-09-04 16:00:27 +000044 }
Junxiao Shi737c43c2016-09-14 02:51:44 +000045 BOOST_ASSERT(false);
46 return 1;
Junxiao Shi64567bb2016-09-04 16:00:27 +000047}
48
Junxiao Shi737c43c2016-09-14 02:51:44 +000049static int
50legacyNfdStatus(ExecuteContext& ctx)
Junxiao Shi64567bb2016-09-04 16:00:27 +000051{
Junxiao Shi737c43c2016-09-14 02:51:44 +000052 auto args = ctx.args.get<std::vector<std::string>>("args");
53 return statusMain(args, ctx.face, ctx.keyChain);
Junxiao Shi64567bb2016-09-04 16:00:27 +000054}
55
56void
57registerCommands(CommandParser& parser)
58{
59 CommandDefinition defStatusReport("status", "report");
60 defStatusReport
61 .addArg("format", ArgValueType::REPORT_FORMAT, Required::NO, Positional::YES);
62 parser.addCommand(defStatusReport, &statusReport);
63
64 CommandDefinition defLegacyNfdStatus("legacy-nfd-status", "");
65 defLegacyNfdStatus
66 .addArg("args", ArgValueType::ANY, Required::NO, Positional::YES);
67 parser.addCommand(defLegacyNfdStatus, &legacyNfdStatus);
68
69 const std::vector<std::string> legacyNfdcSubcommands{
70 "register",
71 "unregister",
72 "create",
73 "destroy",
74 "set-strategy",
75 "unset-strategy",
76 "add-nexthop",
77 "remove-nexthop"
78 };
79 for (const std::string& subcommand : legacyNfdcSubcommands) {
80 CommandDefinition def(subcommand, "");
81 def.addArg("args", ArgValueType::ANY, Required::NO, Positional::YES);
Junxiao Shi737c43c2016-09-14 02:51:44 +000082 parser.addCommand(def, &legacyNfdcMain);
Junxiao Shi64567bb2016-09-04 16:00:27 +000083 }
84}
85
86} // namespace nfdc
87} // namespace tools
88} // namespace nfd