blob: 67ff429d99f3f2403485cec57d5278f1121f187f [file] [log] [blame]
Junxiao Shi38f4ce92016-08-04 10:01:52 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shib347b7f2017-07-23 14:01:58 +00002/*
Davide Pesaventoe422f9e2022-06-03 01:30:23 -04003 * Copyright (c) 2014-2022, Regents of the University of California,
Junxiao Shi38f4ce92016-08-04 10:01:52 +00004 * 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
Junxiao Shi331ade72016-08-19 14:07:19 +000026#ifndef NFD_TOOLS_NFDC_STATUS_REPORT_HPP
27#define NFD_TOOLS_NFDC_STATUS_REPORT_HPP
Junxiao Shi38f4ce92016-08-04 10:01:52 +000028
29#include "module.hpp"
Davide Pesavento264af772021-02-09 21:48:24 -050030
Junxiao Shib347b7f2017-07-23 14:01:58 +000031#include <ndn-cxx/face.hpp>
32#include <ndn-cxx/security/key-chain.hpp>
Alexander Afanasyeva1583702020-06-03 13:55:45 -040033#include <ndn-cxx/security/validator.hpp>
Junxiao Shi38f4ce92016-08-04 10:01:52 +000034
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040035namespace nfd::tools::nfdc {
Junxiao Shi38f4ce92016-08-04 10:01:52 +000036
37using ndn::Face;
Junxiao Shi16a3adf2017-05-26 17:38:51 +000038using ndn::KeyChain;
Alexander Afanasyeva1583702020-06-03 13:55:45 -040039using ndn::security::Validator;
Junxiao Shi38f4ce92016-08-04 10:01:52 +000040
Junxiao Shi8c39bf02016-08-28 23:54:13 +000041enum class ReportFormat {
42 XML = 1,
Davide Pesavento990620a2022-06-05 00:25:53 -040043 TEXT = 2,
Junxiao Shi8c39bf02016-08-28 23:54:13 +000044};
45
Junxiao Shi8c39bf02016-08-28 23:54:13 +000046std::ostream&
47operator<<(std::ostream& os, ReportFormat fmt);
48
Junxiao Shi38f4ce92016-08-04 10:01:52 +000049/** \brief collects and prints NFD status report
50 */
51class StatusReport : noncopyable
52{
53public:
Davide Pesavento264af772021-02-09 21:48:24 -050054#ifdef NFD_WITH_TESTS
Junxiao Shi38f4ce92016-08-04 10:01:52 +000055 virtual
56 ~StatusReport() = default;
57#endif
58
59 /** \brief collect status via chosen \p sections
60 *
61 * This function is blocking. It has exclusive use of \p face.
62 *
63 * \return if status has been fetched successfully, 0;
64 * otherwise, error code from any failed section, plus 1000000 * section index
65 */
66 uint32_t
67 collect(Face& face, KeyChain& keyChain, Validator& validator, const CommandOptions& options);
68
69 /** \brief print an XML report
70 * \param os output stream
71 */
72 void
73 formatXml(std::ostream& os) const;
74
75 /** \brief print a text report
76 * \param os output stream
77 */
78 void
79 formatText(std::ostream& os) const;
80
81private:
Davide Pesavento264af772021-02-09 21:48:24 -050082 NFD_VIRTUAL_WITH_TESTS void
Junxiao Shi38f4ce92016-08-04 10:01:52 +000083 processEvents(Face& face);
84
85public:
86 /** \brief modules through which status is collected
87 */
88 std::vector<unique_ptr<Module>> sections;
89};
90
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040091} // namespace nfd::tools::nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +000092
Junxiao Shi331ade72016-08-19 14:07:19 +000093#endif // NFD_TOOLS_NFDC_STATUS_REPORT_HPP