rib+tools: adapt to Controller::CommandFailCallback with ControlResponse
refs #3739
Change-Id: Icf5b3ed0bd997730a024bad2ccd258c8168b4ccb
diff --git a/tools/ndn-autoconfig/base.cpp b/tools/ndn-autoconfig/base.cpp
index c896e67..a796f4c 100644
--- a/tools/ndn-autoconfig/base.cpp
+++ b/tools/ndn-autoconfig/base.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -57,7 +57,7 @@
m_controller.start<nfd::FaceCreateCommand>(nfd::ControlParameters()
.setUri(canonicalUri.toString()),
bind(&Base::onHubConnectSuccess, this, _1),
- bind(&Base::onHubConnectError, this, _1, _2));
+ bind(&Base::onHubConnectError, this, _1));
}
void
@@ -81,10 +81,10 @@
}
void
-Base::onHubConnectError(uint32_t code, const std::string& error)
+Base::onHubConnectError(const nfd::ControlResponse& response)
{
std::ostringstream os;
- os << "Failed to create face: " << error << " (code: " << code << ")";
+ os << "Failed to create face: " << response.getText() << " (code: " << response.getCode() << ")";
BOOST_THROW_EXCEPTION(Error(os.str()));
}
@@ -99,7 +99,7 @@
.setCost(100)
.setExpirationPeriod(time::milliseconds::max()),
bind(&Base::onPrefixRegistrationSuccess, this, _1),
- bind(&Base::onPrefixRegistrationError, this, _1, _2));
+ bind(&Base::onPrefixRegistrationError, this, _1));
}
void
@@ -109,10 +109,10 @@
}
void
-Base::onPrefixRegistrationError(uint32_t code, const std::string& error)
+Base::onPrefixRegistrationError(const nfd::ControlResponse& response)
{
std::ostringstream os;
- os << "Failed in name registration, " << error << " (code: " << code << ")";
+ os << "Failed in name registration, " << response.getText() << " (code: " << response.getCode() << ")";
BOOST_THROW_EXCEPTION(Error(os.str()));
}
diff --git a/tools/ndn-autoconfig/base.hpp b/tools/ndn-autoconfig/base.hpp
index d69f49c..c4c3a9b 100644
--- a/tools/ndn-autoconfig/base.hpp
+++ b/tools/ndn-autoconfig/base.hpp
@@ -93,7 +93,7 @@
onHubConnectSuccess(const nfd::ControlParameters& resp);
void
- onHubConnectError(uint32_t code, const std::string& error);
+ onHubConnectError(const nfd::ControlResponse& response);
void
registerPrefix(const Name& prefix, uint64_t faceId);
@@ -102,7 +102,7 @@
onPrefixRegistrationSuccess(const nfd::ControlParameters& commandSuccessResult);
void
- onPrefixRegistrationError(uint32_t code, const std::string& error);
+ onPrefixRegistrationError(const nfd::ControlResponse& response);
protected:
Face& m_face;
diff --git a/tools/ndn-autoconfig/multicast-discovery.cpp b/tools/ndn-autoconfig/multicast-discovery.cpp
index 2e3f8a2..a474899 100644
--- a/tools/ndn-autoconfig/multicast-discovery.cpp
+++ b/tools/ndn-autoconfig/multicast-discovery.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -108,7 +108,7 @@
bind(&MulticastDiscovery::onRegisterSuccess,
this),
bind(&MulticastDiscovery::onRegisterFailure,
- this, _1, _2));
+ this, _1));
}
}
}
@@ -124,9 +124,9 @@
}
void
-MulticastDiscovery::onRegisterFailure(uint32_t code, const std::string& error)
+MulticastDiscovery::onRegisterFailure(const nfd::ControlResponse& response)
{
- std::cerr << "ERROR: " << error << " (code: " << code << ")" << std::endl;
+ std::cerr << "ERROR: " << response.getText() << " (code: " << response.getCode() << ")" << std::endl;
--nRequestedRegs;
if (nRequestedRegs == nFinishedRegs) {
@@ -150,14 +150,14 @@
m_controller.start<nfd::StrategyChoiceSetCommand>(parameters,
bind(&MulticastDiscovery::requestHubData, this),
bind(&MulticastDiscovery::onSetStrategyFailure,
- this, _2));
+ this, _1));
}
void
-MulticastDiscovery::onSetStrategyFailure(const std::string& error)
+MulticastDiscovery::onSetStrategyFailure(const nfd::ControlResponse& response)
{
m_nextStageOnFailure("Failed to set multicast strategy for " +
- LOCALHOP_HUB_DISCOVERY_PREFIX.toUri() + " namespace (" + error + "). "
+ LOCALHOP_HUB_DISCOVERY_PREFIX.toUri() + " namespace (" + response.getText() + "). "
"Skipping multicast discovery stage");
}
diff --git a/tools/ndn-autoconfig/multicast-discovery.hpp b/tools/ndn-autoconfig/multicast-discovery.hpp
index 8047926..32f7133 100644
--- a/tools/ndn-autoconfig/multicast-discovery.hpp
+++ b/tools/ndn-autoconfig/multicast-discovery.hpp
@@ -69,13 +69,13 @@
onRegisterSuccess();
void
- onRegisterFailure(uint32_t code, const std::string& error);
+ onRegisterFailure(const nfd::ControlResponse& response);
void
setStrategy();
void
- onSetStrategyFailure(const std::string& error);
+ onSetStrategyFailure(const nfd::ControlResponse& response);
// Start to look for a hub (NDN hub discovery first stage)
void