management: nfd::Controller allows specifying timeout
refs #1455
Change-Id: I2c9fbba76d8166f7696b6dacb110fe1dba7d3db7
diff --git a/src/management/nfd-controller.hpp b/src/management/nfd-controller.hpp
index 1b46c76..91025de 100644
--- a/src/management/nfd-controller.hpp
+++ b/src/management/nfd-controller.hpp
@@ -36,7 +36,8 @@
void
start(const ControlParameters& parameters,
const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure);
+ const CommandFailCallback& onFailure,
+ time::milliseconds timeout = getDefaultCommandTimeout());
public: // selfreg using FIB Management commands
virtual void
@@ -56,6 +57,13 @@
const CommandSucceedCallback& onSuccess,
const CommandFailCallback& onFailure);
+public:
+ static time::milliseconds
+ getDefaultCommandTimeout()
+ {
+ return time::milliseconds(10000);
+ }
+
protected:
Face& m_face;
CommandInterestGenerator m_commandInterestGenerator;
@@ -66,11 +74,15 @@
void
Controller::start(const ControlParameters& parameters,
const CommandSucceedCallback& onSuccess,
- const CommandFailCallback& onFailure)
+ const CommandFailCallback& onFailure,
+ time::milliseconds timeout)
{
+ BOOST_ASSERT(timeout > time::milliseconds::zero());
+
shared_ptr<ControlCommand> command = make_shared<Command>();
Interest commandInterest = command->makeCommandInterest(parameters, m_commandInterestGenerator);
+ commandInterest.setInterestLifetime(timeout);
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668.aspx
const uint32_t timeoutCode = 10060;
diff --git a/tests/management/test-nfd-controller.cpp b/tests/management/test-nfd-controller.cpp
index fcb53b2..99a028c 100644
--- a/tests/management/test-nfd-controller.cpp
+++ b/tests/management/test-nfd-controller.cpp
@@ -77,6 +77,7 @@
BOOST_REQUIRE_NO_THROW(request.wireDecode(commandInterest.getName().at(4).blockFromValue()));
BOOST_CHECK_NO_THROW(command.validateRequest(request));
BOOST_CHECK_EQUAL(request.getUri(), parameters.getUri());
+ BOOST_CHECK_EQUAL(commandInterest.getInterestLifetime(), Controller::getDefaultCommandTimeout());
ControlParameters responseBody;
responseBody.setUri("tcp4://192.0.2.1:6363")