tools: nfdc route commands accept and print RouteOrigin strings
refs #3987
Change-Id: I47594546e3fe9279fff5ea6ade9ce38cb3b05b6c
diff --git a/tools/nfdc/command-arguments.hpp b/tools/nfdc/command-arguments.hpp
index 1bec816..010c1c2 100644
--- a/tools/nfdc/command-arguments.hpp
+++ b/tools/nfdc/command-arguments.hpp
@@ -37,6 +37,7 @@
namespace nfdc {
using ndn::nfd::FacePersistency;
+using ndn::nfd::RouteOrigin;
using ndn::util::FaceUri;
/** \brief contains named command arguments
diff --git a/tools/nfdc/command-definition.cpp b/tools/nfdc/command-definition.cpp
index 18eee1e..a2ceb33 100644
--- a/tools/nfdc/command-definition.cpp
+++ b/tools/nfdc/command-definition.cpp
@@ -54,6 +54,8 @@
return os << "FaceId or FaceUri";
case ArgValueType::FACE_PERSISTENCY:
return os << "FacePersistency";
+ case ArgValueType::ROUTE_ORIGIN:
+ return os << "RouteOrigin";
}
return os << static_cast<int>(vt);
}
@@ -80,6 +82,8 @@
return "face";
case ArgValueType::FACE_PERSISTENCY:
return "persistency";
+ case ArgValueType::ROUTE_ORIGIN:
+ return "origin";
}
BOOST_ASSERT(false);
return "";
@@ -260,6 +264,9 @@
case ArgValueType::FACE_PERSISTENCY:
return parseFacePersistency(token);
+
+ case ArgValueType::ROUTE_ORIGIN:
+ return boost::lexical_cast<RouteOrigin>(token);
}
BOOST_ASSERT(false);
diff --git a/tools/nfdc/command-definition.hpp b/tools/nfdc/command-definition.hpp
index 47c6af3..813e744 100644
--- a/tools/nfdc/command-definition.hpp
+++ b/tools/nfdc/command-definition.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -90,7 +90,13 @@
*
* The argument appears in CommandArguments as ndn::nfd::FacePersistency.
*/
- FACE_PERSISTENCY
+ FACE_PERSISTENCY,
+
+ /** \brief route origin
+ *
+ * The argument appears in CommandArguments as ndn::nfd::RouteOrigin.
+ */
+ ROUTE_ORIGIN,
};
std::ostream&
diff --git a/tools/nfdc/rib-module.cpp b/tools/nfdc/rib-module.cpp
index d7f04cd..ffcb18c 100644
--- a/tools/nfdc/rib-module.cpp
+++ b/tools/nfdc/rib-module.cpp
@@ -38,7 +38,7 @@
defRouteList
.setTitle("print RIB routes")
.addArg("nexthop", ArgValueType::FACE_ID_OR_URI, Required::NO, Positional::YES)
- .addArg("origin", ArgValueType::UNSIGNED, Required::NO, Positional::NO);
+ .addArg("origin", ArgValueType::ROUTE_ORIGIN, Required::NO, Positional::NO);
parser.addCommand(defRouteList, &RibModule::list);
CommandDefinition defRouteShow("route", "show");
@@ -52,7 +52,7 @@
.setTitle("add a route")
.addArg("prefix", ArgValueType::NAME, Required::YES, Positional::YES)
.addArg("nexthop", ArgValueType::FACE_ID_OR_URI, Required::YES, Positional::YES)
- .addArg("origin", ArgValueType::UNSIGNED, Required::NO, Positional::NO)
+ .addArg("origin", ArgValueType::ROUTE_ORIGIN, Required::NO, Positional::NO)
.addArg("cost", ArgValueType::UNSIGNED, Required::NO, Positional::NO)
.addArg("no-inherit", ArgValueType::NONE, Required::NO, Positional::NO)
.addArg("capture", ArgValueType::NONE, Required::NO, Positional::NO)
@@ -64,7 +64,7 @@
.setTitle("remove a route")
.addArg("prefix", ArgValueType::NAME, Required::YES, Positional::YES)
.addArg("nexthop", ArgValueType::FACE_ID_OR_URI, Required::YES, Positional::YES)
- .addArg("origin", ArgValueType::UNSIGNED, Required::NO, Positional::NO);
+ .addArg("origin", ArgValueType::ROUTE_ORIGIN, Required::NO, Positional::NO);
parser.addCommand(defRouteRemove, &RibModule::remove);
}
@@ -73,7 +73,7 @@
{
auto nexthopIt = ctx.args.find("nexthop");
std::set<uint64_t> nexthops;
- auto origin = ctx.args.getOptional<uint64_t>("origin");
+ auto origin = ctx.args.getOptional<RouteOrigin>("origin");
if (nexthopIt != ctx.args.end()) {
FindFace findFace(ctx);
@@ -144,7 +144,7 @@
{
auto prefix = ctx.args.get<Name>("prefix");
const boost::any& nexthop = ctx.args.at("nexthop");
- auto origin = ctx.args.get<uint64_t>("origin", ndn::nfd::ROUTE_ORIGIN_STATIC);
+ auto origin = ctx.args.get<RouteOrigin>("origin", ndn::nfd::ROUTE_ORIGIN_STATIC);
auto cost = ctx.args.get<uint64_t>("cost", 0);
bool wantChildInherit = !ctx.args.get<bool>("no-inherit", false);
bool wantCapture = ctx.args.get<bool>("capture", false);
@@ -191,7 +191,7 @@
text::ItemAttributes ia;
ctx.out << ia("prefix") << resp.getName()
<< ia("nexthop") << resp.getFaceId()
- << ia("origin") << resp.getOrigin()
+ << ia("origin") << static_cast<RouteOrigin>(resp.getOrigin())
<< ia("cost") << resp.getCost()
<< ia("flags") << static_cast<ndn::nfd::RouteFlags>(resp.getFlags());
if (resp.hasExpirationPeriod()) {
@@ -212,7 +212,7 @@
{
auto prefix = ctx.args.get<Name>("prefix");
const boost::any& nexthop = ctx.args.at("nexthop");
- auto origin = ctx.args.get<uint64_t>("origin", ndn::nfd::ROUTE_ORIGIN_STATIC);
+ auto origin = ctx.args.get<RouteOrigin>("origin", ndn::nfd::ROUTE_ORIGIN_STATIC);
FindFace findFace(ctx);
FindFace::Code res = findFace.execute(nexthop, true);
@@ -245,7 +245,7 @@
text::ItemAttributes ia;
ctx.out << ia("prefix") << resp.getName()
<< ia("nexthop") << resp.getFaceId()
- << ia("origin") << resp.getOrigin()
+ << ia("origin") << static_cast<RouteOrigin>(resp.getOrigin())
<< '\n';
},
ctx.makeCommandFailureHandler("removing route"),
@@ -290,7 +290,7 @@
for (const Route& route : item.getRoutes()) {
os << "<route>"
<< "<faceId>" << route.getFaceId() << "</faceId>"
- << "<origin>" << route.getOrigin() << "</origin>"
+ << "<origin>" << static_cast<RouteOrigin>(route.getOrigin()) << "</origin>"
<< "<cost>" << route.getCost() << "</cost>";
if (route.getFlags() == ndn::nfd::ROUTE_FLAGS_NONE) {
os << "<flags/>";
@@ -352,7 +352,7 @@
os << ia("prefix") << entry.getName();
}
os << ia("nexthop") << route.getFaceId();
- os << ia("origin") << static_cast<uint64_t>(route.getOrigin());
+ os << ia("origin") << static_cast<RouteOrigin>(route.getOrigin());
os << ia("cost") << route.getCost();
os << ia("flags") << static_cast<ndn::nfd::RouteFlags>(route.getFlags());