management: FacePersistency field in ControlParameters
Change-Id: I3a93bd658d40f3d77f7790b72e8873646ecc7990
Refs: #2991
diff --git a/src/management/nfd-control-command.cpp b/src/management/nfd-control-command.cpp
index d8ab2c6..746db92 100644
--- a/src/management/nfd-control-command.cpp
+++ b/src/management/nfd-control-command.cpp
@@ -95,10 +95,20 @@
: ControlCommand("faces", "create")
{
m_requestValidator
- .required(CONTROL_PARAMETER_URI);
+ .required(CONTROL_PARAMETER_URI)
+ .optional(CONTROL_PARAMETER_FACE_PERSISTENCY);
m_responseValidator
.required(CONTROL_PARAMETER_URI)
- .required(CONTROL_PARAMETER_FACE_ID);
+ .required(CONTROL_PARAMETER_FACE_ID)
+ .required(CONTROL_PARAMETER_FACE_PERSISTENCY);
+}
+
+void
+FaceCreateCommand::applyDefaultsToRequest(ControlParameters& parameters) const
+{
+ if (!parameters.hasFacePersistency()) {
+ parameters.setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT);
+ }
}
void
diff --git a/src/management/nfd-control-command.hpp b/src/management/nfd-control-command.hpp
index 9d3cbb3..2934e4e 100644
--- a/src/management/nfd-control-command.hpp
+++ b/src/management/nfd-control-command.hpp
@@ -142,6 +142,9 @@
FaceCreateCommand();
virtual void
+ applyDefaultsToRequest(ControlParameters& parameters) const;
+
+ virtual void
validateResponse(const ControlParameters& parameters) const;
};
diff --git a/src/management/nfd-control-parameters.cpp b/src/management/nfd-control-parameters.cpp
index d777843..d0a663e 100644
--- a/src/management/nfd-control-parameters.cpp
+++ b/src/management/nfd-control-parameters.cpp
@@ -50,6 +50,10 @@
{
size_t totalLength = 0;
+ if (this->hasFacePersistency()) {
+ totalLength += prependNonNegativeIntegerBlock(encoder,
+ tlv::nfd::FacePersistency, m_facePersistency);
+ }
if (this->hasExpirationPeriod()) {
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::ExpirationPeriod, m_expirationPeriod.count());
@@ -180,6 +184,12 @@
if (this->hasExpirationPeriod()) {
m_expirationPeriod = time::milliseconds(readNonNegativeInteger(*val));
}
+
+ val = m_wire.find(tlv::nfd::FacePersistency);
+ m_hasFields[CONTROL_PARAMETER_FACE_PERSISTENCY] = val != m_wire.elements_end();
+ if (this->hasFacePersistency()) {
+ m_facePersistency = static_cast<FacePersistency>(readNonNegativeInteger(*val));
+ }
}
std::ostream&
diff --git a/src/management/nfd-control-parameters.hpp b/src/management/nfd-control-parameters.hpp
index 3a099cc..ab287a5 100644
--- a/src/management/nfd-control-parameters.hpp
+++ b/src/management/nfd-control-parameters.hpp
@@ -43,6 +43,7 @@
CONTROL_PARAMETER_FLAGS,
CONTROL_PARAMETER_STRATEGY,
CONTROL_PARAMETER_EXPIRATION_PERIOD,
+ CONTROL_PARAMETER_FACE_PERSISTENCY,
CONTROL_PARAMETER_UBOUND
};
@@ -56,6 +57,7 @@
"Flags",
"Strategy",
"ExpirationPeriod",
+ "FacePersistency",
};
/**
@@ -372,6 +374,36 @@
return *this;
}
+ bool
+ hasFacePersistency() const
+ {
+ return m_hasFields[CONTROL_PARAMETER_FACE_PERSISTENCY];
+ }
+
+ FacePersistency
+ getFacePersistency() const
+ {
+ BOOST_ASSERT(this->hasFacePersistency());
+ return m_facePersistency;
+ }
+
+ ControlParameters&
+ setFacePersistency(FacePersistency persistency)
+ {
+ m_wire.reset();
+ m_facePersistency = persistency;
+ m_hasFields[CONTROL_PARAMETER_FACE_PERSISTENCY] = true;
+ return *this;
+ }
+
+ ControlParameters&
+ unsetFacePersistency()
+ {
+ m_wire.reset();
+ m_hasFields[CONTROL_PARAMETER_FACE_PERSISTENCY] = false;
+ return *this;
+ }
+
const std::vector<bool>&
getPresentFields() const
{
@@ -390,6 +422,7 @@
uint64_t m_flags;
Name m_strategy;
time::milliseconds m_expirationPeriod;
+ FacePersistency m_facePersistency;
private:
mutable Block m_wire;