Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | b347b7f | 2017-07-23 14:01:58 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | 4064127 | 2023-03-16 13:31:12 -0400 | [diff] [blame^] | 3 | * Copyright (c) 2014-2023, Regents of the University of California, |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 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 | |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 26 | #ifndef NFD_TOOLS_NFDC_STATUS_REPORT_HPP |
| 27 | #define NFD_TOOLS_NFDC_STATUS_REPORT_HPP |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 28 | |
Davide Pesavento | 4064127 | 2023-03-16 13:31:12 -0400 | [diff] [blame^] | 29 | #include "core/common.hpp" |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 30 | #include "module.hpp" |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 31 | |
Junxiao Shi | b347b7f | 2017-07-23 14:01:58 +0000 | [diff] [blame] | 32 | #include <ndn-cxx/face.hpp> |
| 33 | #include <ndn-cxx/security/key-chain.hpp> |
Alexander Afanasyev | a158370 | 2020-06-03 13:55:45 -0400 | [diff] [blame] | 34 | #include <ndn-cxx/security/validator.hpp> |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 35 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 36 | namespace nfd::tools::nfdc { |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 37 | |
| 38 | using ndn::Face; |
Junxiao Shi | 16a3adf | 2017-05-26 17:38:51 +0000 | [diff] [blame] | 39 | using ndn::KeyChain; |
Alexander Afanasyev | a158370 | 2020-06-03 13:55:45 -0400 | [diff] [blame] | 40 | using ndn::security::Validator; |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 41 | |
Junxiao Shi | 8c39bf0 | 2016-08-28 23:54:13 +0000 | [diff] [blame] | 42 | enum class ReportFormat { |
| 43 | XML = 1, |
Davide Pesavento | 990620a | 2022-06-05 00:25:53 -0400 | [diff] [blame] | 44 | TEXT = 2, |
Junxiao Shi | 8c39bf0 | 2016-08-28 23:54:13 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
Junxiao Shi | 8c39bf0 | 2016-08-28 23:54:13 +0000 | [diff] [blame] | 47 | std::ostream& |
| 48 | operator<<(std::ostream& os, ReportFormat fmt); |
| 49 | |
Davide Pesavento | 4064127 | 2023-03-16 13:31:12 -0400 | [diff] [blame^] | 50 | /** |
| 51 | * \brief Collects and prints NFD status report. |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 52 | */ |
Davide Pesavento | 4064127 | 2023-03-16 13:31:12 -0400 | [diff] [blame^] | 53 | class StatusReport : boost::noncopyable |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 54 | { |
| 55 | public: |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 56 | #ifdef NFD_WITH_TESTS |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 57 | virtual |
| 58 | ~StatusReport() = default; |
| 59 | #endif |
| 60 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 61 | /** \brief Collect status via chosen \p sections. |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 62 | * |
| 63 | * This function is blocking. It has exclusive use of \p face. |
| 64 | * |
| 65 | * \return if status has been fetched successfully, 0; |
| 66 | * otherwise, error code from any failed section, plus 1000000 * section index |
| 67 | */ |
| 68 | uint32_t |
| 69 | collect(Face& face, KeyChain& keyChain, Validator& validator, const CommandOptions& options); |
| 70 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 71 | /** \brief Print an XML report. |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 72 | * \param os output stream |
| 73 | */ |
| 74 | void |
| 75 | formatXml(std::ostream& os) const; |
| 76 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 77 | /** \brief Print a text report. |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 78 | * \param os output stream |
| 79 | */ |
| 80 | void |
| 81 | formatText(std::ostream& os) const; |
| 82 | |
| 83 | private: |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 84 | NFD_VIRTUAL_WITH_TESTS void |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 85 | processEvents(Face& face); |
| 86 | |
| 87 | public: |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 88 | /** \brief Modules through which status is collected. |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 89 | */ |
| 90 | std::vector<unique_ptr<Module>> sections; |
| 91 | }; |
| 92 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 93 | } // namespace nfd::tools::nfdc |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 94 | |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 95 | #endif // NFD_TOOLS_NFDC_STATUS_REPORT_HPP |