mgmt: use RouteOrigin type in Route and ControlParameters
Change-Id: I1fb7e29efbb7ae9523ca294df03478498ef04322
Refs: #3903
diff --git a/src/mgmt/nfd/control-parameters.cpp b/src/mgmt/nfd/control-parameters.cpp
index a414567..a489c3f 100644
--- a/src/mgmt/nfd/control-parameters.cpp
+++ b/src/mgmt/nfd/control-parameters.cpp
@@ -169,7 +169,7 @@
val = m_wire.find(tlv::nfd::Origin);
m_hasFields[CONTROL_PARAMETER_ORIGIN] = val != m_wire.elements_end();
if (this->hasOrigin()) {
- m_origin = static_cast<uint64_t>(readNonNegativeInteger(*val));
+ m_origin = static_cast<RouteOrigin>(readNonNegativeInteger(*val));
}
val = m_wire.find(tlv::nfd::Cost);
diff --git a/src/mgmt/nfd/control-parameters.hpp b/src/mgmt/nfd/control-parameters.hpp
index cd432ca..df19488 100644
--- a/src/mgmt/nfd/control-parameters.hpp
+++ b/src/mgmt/nfd/control-parameters.hpp
@@ -276,7 +276,7 @@
return m_hasFields[CONTROL_PARAMETER_ORIGIN];
}
- uint64_t
+ RouteOrigin
getOrigin() const
{
BOOST_ASSERT(this->hasOrigin());
@@ -284,7 +284,7 @@
}
ControlParameters&
- setOrigin(uint64_t origin)
+ setOrigin(RouteOrigin origin)
{
m_wire.reset();
m_origin = origin;
@@ -526,7 +526,7 @@
std::string m_uri;
std::string m_localUri;
LocalControlFeature m_localControlFeature;
- uint64_t m_origin;
+ RouteOrigin m_origin;
uint64_t m_cost;
uint64_t m_flags;
uint64_t m_mask;
diff --git a/src/mgmt/nfd/rib-entry.cpp b/src/mgmt/nfd/rib-entry.cpp
index 315b4bd..619fd5e 100644
--- a/src/mgmt/nfd/rib-entry.cpp
+++ b/src/mgmt/nfd/rib-entry.cpp
@@ -36,7 +36,7 @@
Route::Route()
: m_faceId(INVALID_FACE_ID)
- , m_origin(0)
+ , m_origin(ROUTE_ORIGIN_APP)
, m_cost(0)
, m_flags(ROUTE_FLAG_CHILD_INHERIT)
{
@@ -56,7 +56,7 @@
}
Route&
-Route::setOrigin(uint64_t origin)
+Route::setOrigin(RouteOrigin origin)
{
m_origin = origin;
m_wire.reset();
@@ -159,7 +159,7 @@
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::Origin) {
- m_origin = readNonNegativeInteger(*val);
+ m_origin = static_cast<RouteOrigin>(readNonNegativeInteger(*val));
++val;
}
else {
diff --git a/src/mgmt/nfd/rib-entry.hpp b/src/mgmt/nfd/rib-entry.hpp
index 8b82238..e515e64 100644
--- a/src/mgmt/nfd/rib-entry.hpp
+++ b/src/mgmt/nfd/rib-entry.hpp
@@ -66,17 +66,14 @@
Route&
setFaceId(uint64_t faceId);
- uint64_t
+ RouteOrigin
getOrigin() const
{
return m_origin;
}
- /** @brief set Origin
- * @param origin a code defined in ndn::nfd::RouteOrigin
- */
Route&
- setOrigin(uint64_t origin);
+ setOrigin(RouteOrigin origin);
uint64_t
getCost() const
@@ -93,9 +90,6 @@
return m_flags;
}
- /** @brief set route inheritance flags
- * @param flags a bitwise OR'ed code from ndn::nfd::RouteFlags
- */
Route&
setFlags(uint64_t flags);
@@ -129,7 +123,7 @@
private:
uint64_t m_faceId;
- uint64_t m_origin;
+ RouteOrigin m_origin;
uint64_t m_cost;
uint64_t m_flags;
optional<time::milliseconds> m_expirationPeriod;
diff --git a/src/util/dummy-client-face.cpp b/src/util/dummy-client-face.cpp
index f84d997..af1f702 100644
--- a/src/util/dummy-client-face.cpp
+++ b/src/util/dummy-client-face.cpp
@@ -199,7 +199,7 @@
nfd::ControlParameters params(interest.getName().get(-5).blockFromValue());
params.setFaceId(1);
- params.setOrigin(0);
+ params.setOrigin(nfd::ROUTE_ORIGIN_APP);
if (interest.getName().get(3) == name::Component("register")) {
params.setCost(0);
}