rib-module.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2018, 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 #ifndef NFD_TOOLS_NFDC_RIB_MODULE_HPP
27 #define NFD_TOOLS_NFDC_RIB_MODULE_HPP
28 
29 #include "module.hpp"
30 #include "command-parser.hpp"
31 
32 namespace nfd {
33 namespace tools {
34 namespace nfdc {
35 
36 using ndn::nfd::RibEntry;
37 using ndn::nfd::Route;
38 
42 class RibModule : public Module, noncopyable
43 {
44 public:
47  static void
49 
52  static void
53  list(ExecuteContext& ctx);
54 
57  static void
58  show(ExecuteContext& ctx);
59 
62  static void
63  add(ExecuteContext& ctx);
64 
67  static void
68  remove(ExecuteContext& ctx);
69 
70  void
71  fetchStatus(Controller& controller,
72  const std::function<void()>& onSuccess,
73  const Controller::DatasetFailCallback& onFailure,
74  const CommandOptions& options) override;
75 
76  void
77  formatStatusXml(std::ostream& os) const override;
78 
79  void
80  formatStatusText(std::ostream& os) const override;
81 
82 private:
83  using RoutePredicate = std::function<bool(const RibEntry&, const Route&)>;
84 
85  static void
86  listRoutesImpl(ExecuteContext& ctx, const RoutePredicate& filter);
87 
92  void
93  formatItemXml(std::ostream& os, const RibEntry& item) const;
94 
99  static void
100  formatEntryText(std::ostream& os, const RibEntry& entry);
101 
108  static void
109  formatRouteText(std::ostream& os, const RibEntry& entry, const Route& route,
110  bool includePrefix);
111 
112 private:
113  std::vector<RibEntry> m_status;
114 };
115 
116 } // namespace nfdc
117 } // namespace tools
118 } // namespace nfd
119 
120 #endif // NFD_TOOLS_NFDC_RIB_MODULE_HPP
context for command execution
static void list(ExecuteContext &ctx)
the &#39;route list&#39; command
Definition: rib-module.cpp:73
void formatStatusText(std::ostream &os) const override
format collected status as text
Definition: rib-module.cpp:322
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
void formatStatusXml(std::ostream &os) const override
format collected status as XML
Definition: rib-module.cpp:274
provides access to NFD RIB management
Definition: rib-module.hpp:42
void fetchStatus(Controller &controller, const std::function< void()> &onSuccess, const Controller::DatasetFailCallback &onFailure, const CommandOptions &options) override
collect status from NFD
Definition: rib-module.cpp:260
static void add(ExecuteContext &ctx)
the &#39;route add&#39; command
Definition: rib-module.cpp:144
static void registerCommands(CommandParser &parser)
register &#39;route list&#39;, &#39;route show&#39;, &#39;route add&#39;, &#39;route remove&#39; commands
Definition: rib-module.cpp:35
provides access to an NFD management module
Definition: module.hpp:43
static void show(ExecuteContext &ctx)
the &#39;route show&#39; command
Definition: rib-module.cpp:107