tools: nfdc route list and nfd route show commands
refs #3866
Change-Id: Ic8feab0ce9e5707c1cf382cdea7264e28e3edb30
diff --git a/tools/nfdc/rib-module.hpp b/tools/nfdc/rib-module.hpp
index aee2c8b..ae53928 100644
--- a/tools/nfdc/rib-module.hpp
+++ b/tools/nfdc/rib-module.hpp
@@ -47,6 +47,16 @@
static void
registerCommands(CommandParser& parser);
+ /** \brief the 'route list' command
+ */
+ static void
+ list(ExecuteContext& ctx);
+
+ /** \brief the 'route show' command
+ */
+ static void
+ show(ExecuteContext& ctx);
+
/** \brief the 'route add' command
*/
static void
@@ -66,6 +76,15 @@
void
formatStatusXml(std::ostream& os) const override;
+ void
+ formatStatusText(std::ostream& os) const override;
+
+private:
+ using RoutePredicate = function<bool(const RibEntry&, const Route&)>;
+
+ static void
+ listRoutesImpl(ExecuteContext& ctx, const RoutePredicate& filter);
+
/** \brief format a single status item as XML
* \param os output stream
* \param item status item
@@ -73,15 +92,22 @@
void
formatItemXml(std::ostream& os, const RibEntry& item) const;
- void
- formatStatusText(std::ostream& os) const override;
-
- /** \brief format a single status item as text
+ /** \brief format a RibEntry as text
* \param os output stream
- * \param item status item
+ * \param entry RIB entry
*/
- void
- formatItemText(std::ostream& os, const RibEntry& item) const;
+ static void
+ formatEntryText(std::ostream& os, const RibEntry& entry);
+
+ /** \brief format a Route as text
+ * \param os output stream
+ * \param entry RIB entry
+ * \param route RIB route within \p entry
+ * \param includePrefix whether to print the name prefix
+ */
+ static void
+ formatRouteText(std::ostream& os, const RibEntry& entry, const Route& route,
+ bool includePrefix);
private:
std::vector<RibEntry> m_status;