rib+tools: use ndn::nfd::RouteOrigin instead of uint64_t
Change-Id: Ic8cbe95491a41e1d34b66d406da8637aeb5fd9e3
Refs: #3903
diff --git a/tools/nfdc/legacy-nfdc.cpp b/tools/nfdc/legacy-nfdc.cpp
index 5f4f81f..e0e6bcd 100644
--- a/tools/nfdc/legacy-nfdc.cpp
+++ b/tools/nfdc/legacy-nfdc.cpp
@@ -341,6 +341,7 @@
bool wantCapture = false;
bool wantPermanentFace = false;
int64_t expires = -1;
+ std::underlying_type<ndn::nfd::RouteOrigin>::type origin = ndn::nfd::ROUTE_ORIGIN_STATIC;
namespace po = boost::program_options;
po::options_description options;
@@ -349,7 +350,7 @@
(",C", po::bool_switch(&wantCapture))
(",c", po::value<uint64_t>(&p.m_cost))
(",e", po::value<int64_t>(&expires))
- (",o", po::value<uint64_t>(&p.m_origin))
+ (",o", po::value<std::underlying_type<ndn::nfd::RouteOrigin>::type>(&origin))
(",P", po::bool_switch(&wantPermanentFace));
po::variables_map vm;
std::vector<std::string> unparsed;
@@ -376,6 +377,7 @@
// accept negative values as no expiration
p.m_expires = time::milliseconds(expires);
}
+ p.m_origin = static_cast<ndn::nfd::RouteOrigin>(origin);
if (wantPermanentFace) {
p.m_facePersistency = ndn::nfd::FACE_PERSISTENCY_PERMANENT;
}
diff --git a/tools/nfdc/legacy-nfdc.hpp b/tools/nfdc/legacy-nfdc.hpp
index 6ae9abe..ada0a7d 100644
--- a/tools/nfdc/legacy-nfdc.hpp
+++ b/tools/nfdc/legacy-nfdc.hpp
@@ -27,6 +27,8 @@
#define NFD_TOOLS_NFDC_LEGACY_NFDC_HPP
#include "execute-command.hpp"
+
+#include <ndn-cxx/encoding/nfd-constants.hpp>
#include <ndn-cxx/mgmt/nfd/controller.hpp>
namespace nfd {
@@ -160,7 +162,7 @@
uint64_t m_flags;
uint64_t m_cost;
uint64_t m_faceId;
- uint64_t m_origin;
+ ndn::nfd::RouteOrigin m_origin;
time::milliseconds m_expires;
std::string m_name;
ndn::nfd::FacePersistency m_facePersistency;
diff --git a/tools/nfdc/rib-module.cpp b/tools/nfdc/rib-module.cpp
index ffcb18c..5ca7195 100644
--- a/tools/nfdc/rib-module.cpp
+++ b/tools/nfdc/rib-module.cpp
@@ -191,7 +191,7 @@
text::ItemAttributes ia;
ctx.out << ia("prefix") << resp.getName()
<< ia("nexthop") << resp.getFaceId()
- << ia("origin") << static_cast<RouteOrigin>(resp.getOrigin())
+ << ia("origin") << resp.getOrigin()
<< ia("cost") << resp.getCost()
<< ia("flags") << static_cast<ndn::nfd::RouteFlags>(resp.getFlags());
if (resp.hasExpirationPeriod()) {
@@ -245,7 +245,7 @@
text::ItemAttributes ia;
ctx.out << ia("prefix") << resp.getName()
<< ia("nexthop") << resp.getFaceId()
- << ia("origin") << static_cast<RouteOrigin>(resp.getOrigin())
+ << ia("origin") << resp.getOrigin()
<< '\n';
},
ctx.makeCommandFailureHandler("removing route"),
@@ -290,7 +290,7 @@
for (const Route& route : item.getRoutes()) {
os << "<route>"
<< "<faceId>" << route.getFaceId() << "</faceId>"
- << "<origin>" << static_cast<RouteOrigin>(route.getOrigin()) << "</origin>"
+ << "<origin>" << route.getOrigin() << "</origin>"
<< "<cost>" << route.getCost() << "</cost>";
if (route.getFlags() == ndn::nfd::ROUTE_FLAGS_NONE) {
os << "<flags/>";
@@ -352,14 +352,9 @@
os << ia("prefix") << entry.getName();
}
os << ia("nexthop") << route.getFaceId();
- os << ia("origin") << static_cast<RouteOrigin>(route.getOrigin());
+ os << ia("origin") << route.getOrigin();
os << ia("cost") << route.getCost();
os << ia("flags") << static_cast<ndn::nfd::RouteFlags>(route.getFlags());
-
- // 'origin' field is printed as a number, because printing 'origin' as string may mislead user
- // into passing strings to 'origin' command line argument which currently only accepts numbers.
- ///\todo #3987 print 'origin' with RouteOrigin stream insertion operator
-
if (route.hasExpirationPeriod()) {
os << ia("expires") << text::formatDuration(route.getExpirationPeriod());
}