27 #include "core/version.hpp"
36 #include <ndn-cxx/security/validator-null.hpp>
37 #include <boost/program_options.hpp>
46 bool wantForwarderGeneral =
false;
47 bool wantChannels =
false;
48 bool wantFaces =
false;
51 bool wantStrategyChoice =
false;
55 showUsage(std::ostream& os,
const boost::program_options::options_description& cmdOptions)
57 os <<
"Usage: nfd-status [options]\n\n"
58 <<
"Show NFD version and status information.\n\n"
66 static std::tuple<int, Options>
71 namespace po = boost::program_options;
72 po::options_description cmdOptions(
"Options");
73 cmdOptions.add_options()
74 (
"help,h",
"print this help message")
75 (
"version,V",
"show program version")
76 (
"general,v", po::bool_switch(&options.wantForwarderGeneral),
"show general status")
77 (
"channels,c", po::bool_switch(&options.wantChannels),
"show channels")
78 (
"faces,f", po::bool_switch(&options.wantFaces),
"show faces")
79 (
"fib,b", po::bool_switch(&options.wantFib),
"show FIB entries")
80 (
"rib,r", po::bool_switch(&options.wantRib),
"show RIB routes")
81 (
"sc,s", po::bool_switch(&options.wantStrategyChoice),
"show strategy choice entries")
82 (
"xml,x",
"output as XML instead of text (implies -vcfbrs)");
85 po::store(po::command_line_parser(args).options(cmdOptions).run(), vm);
88 catch (
const po::error& e) {
89 std::cerr << e.what() <<
"\n";
91 return std::make_tuple(2, options);
94 if (vm.count(
"help") > 0) {
96 return std::make_tuple(0, options);
98 if (vm.count(
"version") > 0) {
99 std::cout <<
"nfd-status " << NFD_VERSION_BUILD_STRING <<
"\n";
100 return std::make_tuple(0, options);
103 if (vm.count(
"xml") > 0) {
107 (!options.wantForwarderGeneral && !options.wantChannels && !options.wantFaces &&
108 !options.wantFib && !options.wantRib && !options.wantStrategyChoice)) {
109 options.wantForwarderGeneral = options.wantChannels = options.wantFaces =
110 options.wantFib = options.wantRib = options.wantStrategyChoice =
true;
113 return std::make_tuple(-1, options);
117 statusMain(
const std::vector<std::string>& args, Face& face, KeyChain& keyChain)
126 unique_ptr<Validator> validator = make_unique<ndn::ValidatorNull>();
127 CommandOptions ctrlOptions;
131 if (options.wantForwarderGeneral) {
132 auto nfdIdCollector = make_unique<NfdIdCollector>(std::move(validator));
133 auto forwarderGeneralModule = make_unique<ForwarderGeneralModule>();
134 forwarderGeneralModule->setNfdIdCollector(*nfdIdCollector);
135 report.
sections.push_back(std::move(forwarderGeneralModule));
136 validator = std::move(nfdIdCollector);
139 if (options.wantChannels) {
140 report.
sections.push_back(make_unique<ChannelModule>());
143 if (options.wantFaces) {
144 report.
sections.push_back(make_unique<FaceModule>());
147 if (options.wantFib) {
148 report.
sections.push_back(make_unique<FibModule>());
151 if (options.wantRib) {
152 report.
sections.push_back(make_unique<RibModule>());
155 if (options.wantStrategyChoice) {
156 report.
sections.push_back(make_unique<StrategyChoiceModule>());
159 uint32_t code = report.
collect(face, keyChain, *validator, ctrlOptions);
166 std::cerr <<
"Error while collecting status report (" << code <<
").\n";
170 switch (options.output) {
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...