rib+tools: adapt to Controller::CommandFailCallback with ControlResponse
refs #3739
Change-Id: Icf5b3ed0bd997730a024bad2ccd258c8168b4ccb
diff --git a/tools/nfdc/channel-module.cpp b/tools/nfdc/channel-module.cpp
index af55d7b..15cffb4 100644
--- a/tools/nfdc/channel-module.cpp
+++ b/tools/nfdc/channel-module.cpp
@@ -33,7 +33,7 @@
void
ChannelModule::fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options)
{
controller.fetch<ndn::nfd::ChannelDataset>(
diff --git a/tools/nfdc/channel-module.hpp b/tools/nfdc/channel-module.hpp
index e3486a1..6225a27 100644
--- a/tools/nfdc/channel-module.hpp
+++ b/tools/nfdc/channel-module.hpp
@@ -43,7 +43,7 @@
virtual void
fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options) override;
virtual void
diff --git a/tools/nfdc/face-id-fetcher.cpp b/tools/nfdc/face-id-fetcher.cpp
index da09c11..08bc9ff 100644
--- a/tools/nfdc/face-id-fetcher.cpp
+++ b/tools/nfdc/face-id-fetcher.cpp
@@ -164,12 +164,11 @@
}
void
-FaceIdFetcher::onFaceCreateError(uint32_t code,
- const std::string& error,
+FaceIdFetcher::onFaceCreateError(const ndn::nfd::ControlResponse& response,
const std::string& message)
{
std::stringstream ss;
- ss << message << " : " << error << " (code " << code << ")";
+ ss << message << " : " << response.getText() << " (code " << response.getCode() << ")";
fail(ss.str());
}
@@ -181,7 +180,7 @@
m_controller.start<ndn::nfd::FaceCreateCommand>(parameters,
[this] (const ndn::nfd::ControlParameters& result) { succeed(result.getFaceId()); },
- bind(&FaceIdFetcher::onFaceCreateError, this, _1, _2, "Face creation failed"));
+ bind(&FaceIdFetcher::onFaceCreateError, this, _1, "Face creation failed"));
}
void
diff --git a/tools/nfdc/face-id-fetcher.hpp b/tools/nfdc/face-id-fetcher.hpp
index 50e0083..cf0eb6f 100644
--- a/tools/nfdc/face-id-fetcher.hpp
+++ b/tools/nfdc/face-id-fetcher.hpp
@@ -88,8 +88,7 @@
startFaceCreate(const FaceUri& canonicalUri);
void
- onFaceCreateError(uint32_t code,
- const std::string& error,
+ onFaceCreateError(const ndn::nfd::ControlResponse& response,
const std::string& message);
void
diff --git a/tools/nfdc/face-module.cpp b/tools/nfdc/face-module.cpp
index 9c5e74c..97e836c 100644
--- a/tools/nfdc/face-module.cpp
+++ b/tools/nfdc/face-module.cpp
@@ -53,7 +53,7 @@
void
FaceModule::fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options)
{
controller.fetch<ndn::nfd::FaceDataset>(
diff --git a/tools/nfdc/face-module.hpp b/tools/nfdc/face-module.hpp
index 3f8020f..27c089b 100644
--- a/tools/nfdc/face-module.hpp
+++ b/tools/nfdc/face-module.hpp
@@ -43,7 +43,7 @@
virtual void
fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options) override;
virtual void
diff --git a/tools/nfdc/fib-module.cpp b/tools/nfdc/fib-module.cpp
index 27d3922..3da24ee 100644
--- a/tools/nfdc/fib-module.cpp
+++ b/tools/nfdc/fib-module.cpp
@@ -33,7 +33,7 @@
void
FibModule::fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options)
{
controller.fetch<ndn::nfd::FibDataset>(
diff --git a/tools/nfdc/fib-module.hpp b/tools/nfdc/fib-module.hpp
index 2472bd5..6c33d64 100644
--- a/tools/nfdc/fib-module.hpp
+++ b/tools/nfdc/fib-module.hpp
@@ -44,7 +44,7 @@
virtual void
fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options) override;
virtual void
diff --git a/tools/nfdc/forwarder-general-module.cpp b/tools/nfdc/forwarder-general-module.cpp
index 481fd40..dc12e96 100644
--- a/tools/nfdc/forwarder-general-module.cpp
+++ b/tools/nfdc/forwarder-general-module.cpp
@@ -38,7 +38,7 @@
void
ForwarderGeneralModule::fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options)
{
controller.fetch<ndn::nfd::ForwarderGeneralStatusDataset>(
diff --git a/tools/nfdc/forwarder-general-module.hpp b/tools/nfdc/forwarder-general-module.hpp
index 9bcf929..f8c30d8 100644
--- a/tools/nfdc/forwarder-general-module.hpp
+++ b/tools/nfdc/forwarder-general-module.hpp
@@ -48,7 +48,7 @@
virtual void
fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options) override;
void
diff --git a/tools/nfdc/legacy-nfdc.cpp b/tools/nfdc/legacy-nfdc.cpp
index 83a3db8..3e4c0e6 100644
--- a/tools/nfdc/legacy-nfdc.cpp
+++ b/tools/nfdc/legacy-nfdc.cpp
@@ -113,7 +113,7 @@
m_controller.start<ndn::nfd::FibAddNextHopCommand>(parameters,
bind(&LegacyNfdc::onSuccess, this, _1, "Nexthop insertion succeeded"),
- bind(&LegacyNfdc::onError, this, _1, _2, "Nexthop insertion failed"));
+ bind(&LegacyNfdc::onError, this, _1, "Nexthop insertion failed"));
},
bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
}
@@ -133,7 +133,7 @@
m_controller.start<ndn::nfd::FibRemoveNextHopCommand>(parameters,
bind(&LegacyNfdc::onSuccess, this, _1, "Nexthop removal succeeded"),
- bind(&LegacyNfdc::onError, this, _1, _2, "Nexthop removal failed"));
+ bind(&LegacyNfdc::onError, this, _1, "Nexthop removal failed"));
},
bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
}
@@ -159,7 +159,7 @@
m_controller.start<ndn::nfd::RibRegisterCommand>(parameters,
bind(&LegacyNfdc::onSuccess, this, _1, "Successful in name registration"),
- bind(&LegacyNfdc::onError, this, _1, _2, "Failed in name registration"));
+ bind(&LegacyNfdc::onError, this, _1, "Failed in name registration"));
},
bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
}
@@ -180,7 +180,7 @@
m_controller.start<ndn::nfd::RibUnregisterCommand>(parameters,
bind(&LegacyNfdc::onSuccess, this, _1, "Successful in unregistering name"),
- bind(&LegacyNfdc::onError, this, _1, _2, "Failed in unregistering name"));
+ bind(&LegacyNfdc::onError, this, _1, "Failed in unregistering name"));
},
bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
}
@@ -221,7 +221,7 @@
m_controller.start<ndn::nfd::FaceCreateCommand>(parameters,
bind(&LegacyNfdc::onSuccess, this, _1, "Face creation succeeded"),
- bind(&LegacyNfdc::onError, this, _1, _2, "Face creation failed"));
+ bind(&LegacyNfdc::onError, this, _1, "Face creation failed"));
}
void
@@ -237,7 +237,7 @@
m_controller.start<ndn::nfd::FaceDestroyCommand>(faceParameters,
bind(&LegacyNfdc::onSuccess, this, _1, "Face destroy succeeded"),
- bind(&LegacyNfdc::onError, this, _1, _2, "Face destroy failed"));
+ bind(&LegacyNfdc::onError, this, _1, "Face destroy failed"));
},
bind(&LegacyNfdc::onObtainFaceIdFailure, this, _1));
}
@@ -255,7 +255,7 @@
m_controller.start<ndn::nfd::StrategyChoiceSetCommand>(parameters,
bind(&LegacyNfdc::onSuccess, this, _1, "Successfully set strategy choice"),
- bind(&LegacyNfdc::onError, this, _1, _2, "Failed to set strategy choice"));
+ bind(&LegacyNfdc::onError, this, _1, "Failed to set strategy choice"));
}
void
@@ -268,7 +268,7 @@
m_controller.start<ndn::nfd::StrategyChoiceUnsetCommand>(parameters,
bind(&LegacyNfdc::onSuccess, this, _1, "Successfully unset strategy choice"),
- bind(&LegacyNfdc::onError, this, _1, _2, "Failed to unset strategy choice"));
+ bind(&LegacyNfdc::onError, this, _1, "Failed to unset strategy choice"));
}
void
@@ -278,10 +278,10 @@
}
void
-LegacyNfdc::onError(uint32_t code, const std::string& error, const std::string& message)
+LegacyNfdc::onError(const ndn::nfd::ControlResponse& response, const std::string& message)
{
std::ostringstream os;
- os << message << ": " << error << " (code: " << code << ")";
+ os << message << ": " << response.getText() << " (code: " << response.getCode() << ")";
BOOST_THROW_EXCEPTION(Error(os.str()));
}
diff --git a/tools/nfdc/legacy-nfdc.hpp b/tools/nfdc/legacy-nfdc.hpp
index 01ed7b9..5a804a1 100644
--- a/tools/nfdc/legacy-nfdc.hpp
+++ b/tools/nfdc/legacy-nfdc.hpp
@@ -142,13 +142,12 @@
strategyChoiceUnset();
private:
-
void
onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
const std::string& message);
void
- onError(uint32_t code, const std::string& error, const std::string& message);
+ onError(const ndn::nfd::ControlResponse& response, const std::string& message);
void
onCanonizeFailure(const std::string& reason);
diff --git a/tools/nfdc/module.hpp b/tools/nfdc/module.hpp
index f33afac..fae4ce7 100644
--- a/tools/nfdc/module.hpp
+++ b/tools/nfdc/module.hpp
@@ -55,7 +55,7 @@
virtual void
fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options) = 0;
/** \brief format collected status as XML
diff --git a/tools/nfdc/rib-module.cpp b/tools/nfdc/rib-module.cpp
index bf2da3d..266a550 100644
--- a/tools/nfdc/rib-module.cpp
+++ b/tools/nfdc/rib-module.cpp
@@ -33,7 +33,7 @@
void
RibModule::fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options)
{
controller.fetch<ndn::nfd::RibDataset>(
diff --git a/tools/nfdc/rib-module.hpp b/tools/nfdc/rib-module.hpp
index 20e2144..85230aa 100644
--- a/tools/nfdc/rib-module.hpp
+++ b/tools/nfdc/rib-module.hpp
@@ -44,7 +44,7 @@
virtual void
fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options) override;
virtual void
diff --git a/tools/nfdc/strategy-choice-module.cpp b/tools/nfdc/strategy-choice-module.cpp
index c32b5aa..4a6b36f 100644
--- a/tools/nfdc/strategy-choice-module.cpp
+++ b/tools/nfdc/strategy-choice-module.cpp
@@ -33,7 +33,7 @@
void
StrategyChoiceModule::fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options)
{
controller.fetch<ndn::nfd::StrategyChoiceDataset>(
diff --git a/tools/nfdc/strategy-choice-module.hpp b/tools/nfdc/strategy-choice-module.hpp
index 9c78eb7..4d26896 100644
--- a/tools/nfdc/strategy-choice-module.hpp
+++ b/tools/nfdc/strategy-choice-module.hpp
@@ -43,7 +43,7 @@
virtual void
fetchStatus(Controller& controller,
const function<void()>& onSuccess,
- const Controller::CommandFailCallback& onFailure,
+ const Controller::DatasetFailCallback& onFailure,
const CommandOptions& options) override;
virtual void