face: replace EventEmitter usage with Signal
refs #2300 Change-Id: I17d0d65d2c474b17dd9f23f271a6144b0b4fbc07
This commit is contained in:
1 parent
a22a217261
commit
c099ddb587
35 files changed
+344
-353
No files matched your search
@@ -129,7 +129,7 @@ template<class T, class U>
|
||||
inline void
|
||||
DatagramFace<T, U>::sendInterest(const Interest& interest)
|
||||
{
|
||||
this->onSendInterest(interest);
|
||||
this->emitSignal(onSendInterest, interest);
|
||||
const Block& payload = interest.wireEncode();
|
||||
m_socket->async_send(boost::asio::buffer(payload.wire(), payload.size()),
|
||||
bind(&DatagramFace<T, U>::handleSend, this, _1, _2, payload));
|
||||
@@ -141,7 +141,7 @@ template<class T, class U>
|
||||
inline void
|
||||
DatagramFace<T, U>::sendData(const Data& data)
|
||||
{
|
||||
this->onSendData(data);
|
||||
this->emitSignal(onSendData, data);
|
||||
const Block& payload = data.wireEncode();
|
||||
m_socket->async_send(boost::asio::buffer(payload.wire(), payload.size()),
|
||||
bind(&DatagramFace<T, U>::handleSend, this, _1, _2, payload));
|
||||
@@ -176,8 +176,7 @@ DatagramFace<T, U>::handleSend(const boost::system::error_code& error,
|
||||
fail("Tunnel closed");
|
||||
}
|
||||
else {
|
||||
fail("Send operation failed, closing socket: " +
|
||||
error.category().message(error.value()));
|
||||
fail("Send operation failed, closing socket: " + error.message());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ EthernetFace::~EthernetFace()
|
||||
void
|
||||
EthernetFace::sendInterest(const Interest& interest)
|
||||
{
|
||||
onSendInterest(interest);
|
||||
this->emitSignal(onSendInterest, interest);
|
||||
ndnlp::PacketArray pa = m_slicer->slice(interest.wireEncode());
|
||||
for (const auto& packet : *pa) {
|
||||
sendPacket(packet);
|
||||
@@ -133,7 +133,7 @@ EthernetFace::sendInterest(const Interest& interest)
|
||||
void
|
||||
EthernetFace::sendData(const Data& data)
|
||||
{
|
||||
onSendData(data);
|
||||
this->emitSignal(onSendData, data);
|
||||
ndnlp::PacketArray pa = m_slicer->slice(data.wireEncode());
|
||||
for (const auto& packet : *pa) {
|
||||
sendPacket(packet);
|
||||
@@ -387,7 +387,7 @@ EthernetFace::processIncomingPacket(const pcap_pkthdr* header, const uint8_t* pa
|
||||
{
|
||||
// new sender, setup a PartialMessageStore for it
|
||||
reassembler.pms.reset(new ndnlp::PartialMessageStore);
|
||||
reassembler.pms->onReceive +=
|
||||
reassembler.pms->onReceive.connect(
|
||||
[this, sourceAddress] (const Block& block) {
|
||||
NFD_LOG_TRACE("[id:" << getId() << ",endpoint:" << m_interfaceName
|
||||
<< "] All fragments received from " << sourceAddress.toString());
|
||||
@@ -395,7 +395,7 @@ EthernetFace::processIncomingPacket(const pcap_pkthdr* header, const uint8_t* pa
|
||||
NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName
|
||||
<< "] Received unrecognized TLV block of type " << block.type()
|
||||
<< " from " << sourceAddress.toString());
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
scheduler::cancel(reassembler.expireEvent);
|
||||
|
||||
@@ -48,9 +48,9 @@ EthernetFactory::createMulticastFace(const NetworkInterfaceInfo& interface,
|
||||
face = make_shared<EthernetFace>(socket, interface, address);
|
||||
|
||||
auto key = std::make_pair(interface.name, address);
|
||||
face->onFail += [this, key] (const std::string& reason) {
|
||||
face->onFail.connectSingleShot([this, key] (const std::string& reason) {
|
||||
m_multicastFaces.erase(key);
|
||||
};
|
||||
});
|
||||
m_multicastFaces.insert({key, face});
|
||||
|
||||
return face;
|
||||
|
||||
@@ -36,10 +36,10 @@ Face::Face(const FaceUri& remoteUri, const FaceUri& localUri, bool isLocal)
|
||||
, m_isOnDemand(false)
|
||||
, m_isFailed(false)
|
||||
{
|
||||
onReceiveInterest += [this](const ndn::Interest&) { ++m_counters.getNInInterests(); };
|
||||
onReceiveData += [this](const ndn::Data&) { ++m_counters.getNInDatas(); };
|
||||
onSendInterest += [this](const ndn::Interest&) { ++m_counters.getNOutInterests(); };
|
||||
onSendData += [this](const ndn::Data&) { ++m_counters.getNOutDatas(); };
|
||||
onReceiveInterest.connect([this] (const ndn::Interest&) { ++m_counters.getNInInterests(); });
|
||||
onReceiveData .connect([this] (const ndn::Data&) { ++m_counters.getNInDatas(); });
|
||||
onSendInterest .connect([this] (const ndn::Interest&) { ++m_counters.getNOutInterests(); });
|
||||
onSendData .connect([this] (const ndn::Data&) { ++m_counters.getNOutDatas(); });
|
||||
}
|
||||
|
||||
Face::~Face()
|
||||
@@ -120,8 +120,6 @@ Face::fail(const std::string& reason)
|
||||
|
||||
m_isFailed = true;
|
||||
this->onFail(reason);
|
||||
|
||||
this->onFail.clear();
|
||||
}
|
||||
|
||||
template<typename FaceTraits>
|
||||
|
||||
+10
-5
@@ -78,19 +78,19 @@ public:
|
||||
~Face();
|
||||
|
||||
/// fires when an Interest is received
|
||||
EventEmitter<Interest> onReceiveInterest;
|
||||
signal::Signal<Face, Interest> onReceiveInterest;
|
||||
|
||||
/// fires when a Data is received
|
||||
EventEmitter<Data> onReceiveData;
|
||||
signal::Signal<Face, Data> onReceiveData;
|
||||
|
||||
/// fires when an Interest is sent out
|
||||
EventEmitter<Interest> onSendInterest;
|
||||
signal::Signal<Face, Interest> onSendInterest;
|
||||
|
||||
/// fires when a Data is sent out
|
||||
EventEmitter<Data> onSendData;
|
||||
signal::Signal<Face, Data> onSendData;
|
||||
|
||||
/// fires when face disconnects or fails to perform properly
|
||||
EventEmitter<std::string/*reason*/> onFail;
|
||||
signal::Signal<Face, std::string/*reason*/> onFail;
|
||||
|
||||
/// send an Interest
|
||||
virtual void
|
||||
@@ -187,6 +187,11 @@ protected:
|
||||
void
|
||||
fail(const std::string& reason);
|
||||
|
||||
DECLARE_SIGNAL_EMIT(onReceiveInterest)
|
||||
DECLARE_SIGNAL_EMIT(onReceiveData)
|
||||
DECLARE_SIGNAL_EMIT(onSendInterest)
|
||||
DECLARE_SIGNAL_EMIT(onSendData)
|
||||
|
||||
private:
|
||||
void
|
||||
setId(FaceId faceId);
|
||||
|
||||
@@ -156,7 +156,7 @@ LocalFace::decodeAndDispatchInput(const Block& element)
|
||||
this->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
|
||||
}
|
||||
|
||||
this->onReceiveInterest(*i);
|
||||
this->emitSignal(onReceiveInterest, *i);
|
||||
}
|
||||
else if (payload.type() == tlv::Data)
|
||||
{
|
||||
@@ -174,7 +174,7 @@ LocalFace::decodeAndDispatchInput(const Block& element)
|
||||
// false);
|
||||
// }
|
||||
|
||||
this->onReceiveData(*d);
|
||||
this->emitSignal(onReceiveData, *d);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -61,7 +61,7 @@ MulticastUdpFace::sendBlock(const Block& block)
|
||||
void
|
||||
MulticastUdpFace::sendInterest(const Interest& interest)
|
||||
{
|
||||
onSendInterest(interest);
|
||||
this->emitSignal(onSendInterest, interest);
|
||||
|
||||
NFD_LOG_DEBUG("Sending interest");
|
||||
sendBlock(interest.wireEncode());
|
||||
@@ -70,9 +70,9 @@ MulticastUdpFace::sendInterest(const Interest& interest)
|
||||
void
|
||||
MulticastUdpFace::sendData(const Data& data)
|
||||
{
|
||||
/// \todo After this method implements duplicate suppression, onSendData event should
|
||||
/// be triggered only when data is actually sent out
|
||||
onSendData(data);
|
||||
/// \todo After this method implements duplicate suppression, onSendData signal should
|
||||
/// be emitted only when data is actually sent out
|
||||
this->emitSignal(onSendData, data);
|
||||
|
||||
NFD_LOG_DEBUG("Sending data");
|
||||
sendBlock(data.wireEncode());
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
* Washington University in St. Louis,
|
||||
* Beijing Institute of Technology
|
||||
* Copyright (c) 2014, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
* Washington University in St. Louis,
|
||||
* Beijing Institute of Technology,
|
||||
* The University of Memphis
|
||||
*
|
||||
* This file is part of NFD (Named Data Networking Forwarding Daemon).
|
||||
* See AUTHORS.md for complete list of NFD authors and contributors.
|
||||
@@ -20,7 +21,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
*/
|
||||
|
||||
#ifndef NFD_DAEMON_FACE_NDNLP_PARTIAL_MESSAGE_STORE_HPP
|
||||
#define NFD_DAEMON_FACE_NDNLP_PARTIAL_MESSAGE_STORE_HPP
|
||||
@@ -84,7 +85,7 @@ public:
|
||||
receiveNdnlpData(const Block& pkt);
|
||||
|
||||
/// fires when network layer packet is received
|
||||
EventEmitter<Block> onReceive;
|
||||
signal::Signal<PartialMessageStore, Block> onReceive;
|
||||
|
||||
private:
|
||||
void
|
||||
|
||||
@@ -178,7 +178,7 @@ template<class T, class U>
|
||||
inline void
|
||||
StreamFace<T, U>::sendInterest(const Interest& interest)
|
||||
{
|
||||
this->onSendInterest(interest);
|
||||
this->emitSignal(onSendInterest, interest);
|
||||
StreamFaceSenderImpl<T, U, Interest>::send(*this, interest);
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ template<class T, class U>
|
||||
inline void
|
||||
StreamFace<T, U>::sendData(const Data& data)
|
||||
{
|
||||
this->onSendData(data);
|
||||
this->emitSignal(onSendData, data);
|
||||
StreamFaceSenderImpl<T, U, Data>::send(*this, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ TcpChannel::createFace(const shared_ptr<ip::tcp::socket>& socket,
|
||||
else
|
||||
face = make_shared<TcpFace>(socket, isOnDemand);
|
||||
|
||||
face->onFail += bind(&TcpChannel::afterFaceFailed, this, remoteEndpoint);
|
||||
face->onFail.connectSingleShot(bind(&TcpChannel::afterFaceFailed, this, remoteEndpoint));
|
||||
|
||||
m_channelFaces[remoteEndpoint] = face;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,8 @@ UdpChannel::createFace(const shared_ptr<ip::udp::socket>& socket,
|
||||
if (faceMapPos == m_channelFaces.end())
|
||||
{
|
||||
face = make_shared<UdpFace>(socket, isOnDemand, m_idleFaceTimeout);
|
||||
face->onFail += bind(&UdpChannel::afterFaceFailed, this, remoteEndpoint);
|
||||
|
||||
face->onFail.connectSingleShot(bind(&UdpChannel::afterFaceFailed, this, remoteEndpoint));
|
||||
|
||||
m_channelFaces[remoteEndpoint] = face;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include "udp-face.hpp"
|
||||
// #include "core/global-io.hpp" // for #1718 manual test below
|
||||
|
||||
#ifdef __linux__
|
||||
#include <netinet/in.h> // for IP_MTU_DISCOVER and IP_PMTUDISC_DONT
|
||||
@@ -112,6 +113,12 @@ UdpFace::closeIfIdle()
|
||||
<< ",uri:" << this->getRemoteUri()
|
||||
<< "] Idle for more than " << m_idleTimeout << ", closing");
|
||||
close();
|
||||
|
||||
// #1718 manual test: uncomment, run NFD in valgrind, send in a UDP packet
|
||||
// expect read-after-free error and crash
|
||||
// getGlobalIoService().post([this] {
|
||||
// NFD_LOG_ERROR("Remaining references: " << this->shared_from_this().use_count());
|
||||
// });
|
||||
}
|
||||
else {
|
||||
resetRecentUsage();
|
||||
|
||||
@@ -237,7 +237,8 @@ UdpFactory::createMulticastFace(const udp::Endpoint& localEndpoint,
|
||||
|
||||
multicastFace = make_shared<MulticastUdpFace>(receiveSocket, sendSocket,
|
||||
localEndpoint, multicastEndpoint);
|
||||
multicastFace->onFail += bind(&UdpFactory::afterFaceFailed, this, localEndpoint);
|
||||
|
||||
multicastFace->onFail.connectSingleShot(bind(&UdpFactory::afterFaceFailed, this, localEndpoint));
|
||||
|
||||
m_multicastFaces[localEndpoint] = multicastFace;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ WebSocketFace::sendInterest(const Interest& interest)
|
||||
if (m_closed)
|
||||
return;
|
||||
|
||||
this->onSendInterest(interest);
|
||||
this->emitSignal(onSendInterest, interest);
|
||||
const Block& payload = interest.wireEncode();
|
||||
this->getMutableCounters().getNOutBytes() += payload.size();
|
||||
|
||||
@@ -67,7 +67,7 @@ WebSocketFace::sendData(const Data& data)
|
||||
if (m_closed)
|
||||
return;
|
||||
|
||||
this->onSendData(data);
|
||||
this->emitSignal(onSendData, data);
|
||||
const Block& payload = data.wireEncode();
|
||||
this->getMutableCounters().getNOutBytes() += payload.size();
|
||||
|
||||
|
||||
@@ -85,12 +85,9 @@ FaceTable::addImpl(shared_ptr<Face> face, FaceId faceId)
|
||||
NFD_LOG_INFO("Added face id=" << faceId << " remote=" << face->getRemoteUri()
|
||||
<< " local=" << face->getLocalUri());
|
||||
|
||||
face->onReceiveInterest += bind(&Forwarder::onInterest,
|
||||
&m_forwarder, ref(*face), _1);
|
||||
face->onReceiveData += bind(&Forwarder::onData,
|
||||
&m_forwarder, ref(*face), _1);
|
||||
face->onFail += bind(&FaceTable::remove,
|
||||
this, face);
|
||||
face->onReceiveInterest.connect(bind(&Forwarder::onInterest, &m_forwarder, ref(*face), _1));
|
||||
face->onReceiveData.connect(bind(&Forwarder::onData, &m_forwarder, ref(*face), _1));
|
||||
face->onFail.connectSingleShot(bind(&FaceTable::remove, this, face));
|
||||
|
||||
this->onAdd(face);
|
||||
}
|
||||
@@ -104,15 +101,7 @@ FaceTable::remove(shared_ptr<Face> face)
|
||||
m_faces.erase(faceId);
|
||||
face->setId(INVALID_FACEID);
|
||||
NFD_LOG_INFO("Removed face id=" << faceId << " remote=" << face->getRemoteUri() <<
|
||||
" local=" << face->getLocalUri());
|
||||
|
||||
// XXX This clears all subscriptions, because EventEmitter
|
||||
// does not support only removing Forwarder's subscription
|
||||
face->onReceiveInterest.clear();
|
||||
face->onReceiveData .clear();
|
||||
face->onSendInterest .clear();
|
||||
face->onSendData .clear();
|
||||
// don't clear onFail because other functions may need to execute
|
||||
" local=" << face->getLocalUri());
|
||||
|
||||
m_forwarder.getFib().removeNextHopFromAllEntries(face);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ InternalFace::InternalFace()
|
||||
void
|
||||
InternalFace::sendInterest(const Interest& interest)
|
||||
{
|
||||
onSendInterest(interest);
|
||||
this->emitSignal(onSendInterest, interest);
|
||||
|
||||
// Invoke .processInterest a bit later,
|
||||
// to avoid potential problems in forwarding pipelines.
|
||||
@@ -122,7 +122,7 @@ InternalFace::processInterest(const shared_ptr<const Interest>& interest)
|
||||
void
|
||||
InternalFace::sendData(const Data& data)
|
||||
{
|
||||
onSendData(data);
|
||||
this->emitSignal(onSendData, data);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -142,7 +142,7 @@ InternalFace::setInterestFilter(const Name& filter,
|
||||
void
|
||||
InternalFace::put(const Data& data)
|
||||
{
|
||||
onReceiveData(data);
|
||||
this->emitSignal(onReceiveData, data);
|
||||
}
|
||||
|
||||
InternalFace::~InternalFace()
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
virtual void
|
||||
sendInterest(const Interest& interest)
|
||||
{
|
||||
this->onSendInterest(interest);
|
||||
this->emitSignal(onSendInterest, interest);
|
||||
m_sentInterests.push_back(interest);
|
||||
this->afterSend();
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
virtual void
|
||||
sendData(const Data& data)
|
||||
{
|
||||
this->onSendData(data);
|
||||
this->emitSignal(onSendData, data);
|
||||
m_sentDatas.push_back(data);
|
||||
this->afterSend();
|
||||
}
|
||||
@@ -68,22 +68,22 @@ public:
|
||||
virtual void
|
||||
close()
|
||||
{
|
||||
this->onFail("close");
|
||||
this->fail("close");
|
||||
}
|
||||
|
||||
void
|
||||
receiveInterest(const Interest& interest)
|
||||
{
|
||||
this->onReceiveInterest(interest);
|
||||
this->emitSignal(onReceiveInterest, interest);
|
||||
}
|
||||
|
||||
void
|
||||
receiveData(const Data& data)
|
||||
{
|
||||
this->onReceiveData(data);
|
||||
this->emitSignal(onReceiveData, data);
|
||||
}
|
||||
|
||||
EventEmitter<> afterSend;
|
||||
signal::Signal<DummyFaceImpl<FaceBase>> afterSend;
|
||||
|
||||
public:
|
||||
std::vector<Interest> m_sentInterests;
|
||||
|
||||
@@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(SendPacket)
|
||||
BOOST_CHECK_EQUAL(face->getCounters().getNInBytes(), 0);
|
||||
BOOST_CHECK_EQUAL(face->getCounters().getNOutBytes(), 0);
|
||||
|
||||
face->onFail += [] (const std::string& reason) { BOOST_FAIL(reason); };
|
||||
face->onFail.connect([] (const std::string& reason) { BOOST_FAIL(reason); });
|
||||
|
||||
shared_ptr<Interest> interest1 = makeInterest("ndn:/TpnzGvW9R");
|
||||
shared_ptr<Data> data1 = makeData("ndn:/KfczhUqVix");
|
||||
@@ -171,9 +171,10 @@ BOOST_AUTO_TEST_CASE(ProcessIncomingPacket)
|
||||
std::vector<Interest> recInterests;
|
||||
std::vector<Data> recDatas;
|
||||
|
||||
face->onFail += [] (const std::string& reason) { BOOST_FAIL(reason); };
|
||||
face->onReceiveInterest += [&recInterests] (const Interest& i) { recInterests.push_back(i); };
|
||||
face->onReceiveData += [&recDatas] (const Data& d) { recDatas.push_back(d); };
|
||||
face->onFail.connect([] (const std::string& reason) { BOOST_FAIL(reason); });
|
||||
face->onReceiveInterest.connect(
|
||||
[&recInterests] (const Interest& i) { recInterests.push_back(i); });
|
||||
face->onReceiveData.connect([&recDatas] (const Data& d) { recDatas.push_back(d); });
|
||||
|
||||
// check that packet data is not accessed if pcap didn't capture anything (caplen == 0)
|
||||
static const pcap_pkthdr header1{};
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
FaceFailTestFace()
|
||||
: failCount(0)
|
||||
{
|
||||
this->onFail += bind(&FaceFailTestFace::failHandler, this, _1);
|
||||
this->onFail.connect(bind(&FaceFailTestFace::failHandler, this, _1));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+11
-11
@@ -1,11 +1,12 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
* Washington University in St. Louis,
|
||||
* Beijing Institute of Technology
|
||||
* Copyright (c) 2014, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
* Washington University in St. Louis,
|
||||
* Beijing Institute of Technology,
|
||||
* The University of Memphis
|
||||
*
|
||||
* This file is part of NFD (Named Data Networking Forwarding Daemon).
|
||||
* See AUTHORS.md for complete list of NFD authors and contributors.
|
||||
@@ -20,7 +21,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
*/
|
||||
|
||||
#include "face/ndnlp-sequence-generator.hpp"
|
||||
#include "face/ndnlp-slicer.hpp"
|
||||
@@ -156,10 +157,9 @@ protected:
|
||||
ReassembleFixture()
|
||||
: m_slicer(1500)
|
||||
{
|
||||
m_partialMessageStore.onReceive +=
|
||||
// push_back in C++11 has 2 overloads, and specific version needs to be selected
|
||||
bind(static_cast<void (std::vector<Block>::*)(const Block&)>(&std::vector<Block>::push_back),
|
||||
&m_received, _1);
|
||||
m_partialMessageStore.onReceive.connect([this] (const Block& block) {
|
||||
m_received.push_back(block);
|
||||
});
|
||||
}
|
||||
|
||||
Block
|
||||
|
||||
@@ -119,12 +119,9 @@ public:
|
||||
{
|
||||
BOOST_CHECK(!static_cast<bool>(face1));
|
||||
face1 = newFace;
|
||||
face1->onReceiveInterest +=
|
||||
bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
|
||||
face1->onReceiveData +=
|
||||
bind(&EndToEndFixture::face1_onReceiveData, this, _1);
|
||||
face1->onFail +=
|
||||
bind(&EndToEndFixture::face1_onFail, this);
|
||||
face1->onReceiveInterest.connect(bind(&EndToEndFixture::face1_onReceiveInterest, this, _1));
|
||||
face1->onReceiveData.connect(bind(&EndToEndFixture::face1_onReceiveData, this, _1));
|
||||
face1->onFail.connect(bind(&EndToEndFixture::face1_onFail, this));
|
||||
|
||||
limitedIo.afterOp();
|
||||
}
|
||||
@@ -165,12 +162,9 @@ public:
|
||||
{
|
||||
BOOST_CHECK(!static_cast<bool>(face2));
|
||||
face2 = newFace;
|
||||
face2->onReceiveInterest +=
|
||||
bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
|
||||
face2->onReceiveData +=
|
||||
bind(&EndToEndFixture::face2_onReceiveData, this, _1);
|
||||
face2->onFail +=
|
||||
bind(&EndToEndFixture::face2_onFail, this);
|
||||
face2->onReceiveInterest.connect(bind(&EndToEndFixture::face2_onReceiveInterest, this, _1));
|
||||
face2->onReceiveData.connect(bind(&EndToEndFixture::face2_onReceiveData, this, _1));
|
||||
face2->onFail.connect(bind(&EndToEndFixture::face2_onFail, this));
|
||||
|
||||
limitedIo.afterOp();
|
||||
}
|
||||
@@ -492,12 +486,9 @@ public:
|
||||
void
|
||||
onFaceCreated(const shared_ptr<Face>& face)
|
||||
{
|
||||
face->onReceiveInterest +=
|
||||
bind(&SimpleEndToEndFixture::onReceiveInterest, this, _1);
|
||||
face->onReceiveData +=
|
||||
bind(&SimpleEndToEndFixture::onReceiveData, this, _1);
|
||||
face->onFail +=
|
||||
bind(&SimpleEndToEndFixture::onFail, this, face);
|
||||
face->onReceiveInterest.connect(bind(&SimpleEndToEndFixture::onReceiveInterest, this, _1));
|
||||
face->onReceiveData.connect(bind(&SimpleEndToEndFixture::onReceiveData, this, _1));
|
||||
face->onFail.connect(bind(&SimpleEndToEndFixture::onFail, this, face));
|
||||
|
||||
if (static_cast<bool>(dynamic_pointer_cast<LocalFace>(face))) {
|
||||
static_pointer_cast<LocalFace>(face)->setLocalControlHeaderFeature(
|
||||
|
||||
@@ -259,12 +259,9 @@ public:
|
||||
channel1_onFaceCreatedNoCheck(const shared_ptr<Face>& newFace)
|
||||
{
|
||||
face1 = newFace;
|
||||
face1->onReceiveInterest +=
|
||||
bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
|
||||
face1->onReceiveData +=
|
||||
bind(&EndToEndFixture::face1_onReceiveData, this, _1);
|
||||
face1->onFail +=
|
||||
bind(&EndToEndFixture::face1_onFail, this);
|
||||
face1->onReceiveInterest.connect(bind(&EndToEndFixture::face1_onReceiveInterest, this, _1));
|
||||
face1->onReceiveData.connect(bind(&EndToEndFixture::face1_onReceiveData, this, _1));
|
||||
face1->onFail.connect(bind(&EndToEndFixture::face1_onFail, this));
|
||||
BOOST_CHECK_MESSAGE(true, "channel 1 face created");
|
||||
|
||||
faces.push_back(face1);
|
||||
@@ -308,12 +305,9 @@ public:
|
||||
{
|
||||
BOOST_CHECK(!static_cast<bool>(face2));
|
||||
face2 = newFace;
|
||||
face2->onReceiveInterest +=
|
||||
bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
|
||||
face2->onReceiveData +=
|
||||
bind(&EndToEndFixture::face2_onReceiveData, this, _1);
|
||||
face2->onFail +=
|
||||
bind(&EndToEndFixture::face2_onFail, this);
|
||||
face2->onReceiveInterest.connect(bind(&EndToEndFixture::face2_onReceiveInterest, this, _1));
|
||||
face2->onReceiveData.connect(bind(&EndToEndFixture::face2_onReceiveData, this, _1));
|
||||
face2->onFail.connect(bind(&EndToEndFixture::face2_onFail, this));
|
||||
|
||||
faces.push_back(face2);
|
||||
|
||||
|
||||
@@ -96,10 +96,8 @@ public:
|
||||
{
|
||||
BOOST_CHECK(!static_cast<bool>(face1));
|
||||
face1 = static_pointer_cast<UnixStreamFace>(newFace);
|
||||
face1->onReceiveInterest +=
|
||||
bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
|
||||
face1->onReceiveData +=
|
||||
bind(&EndToEndFixture::face1_onReceiveData, this, _1);
|
||||
face1->onReceiveInterest.connect(bind(&EndToEndFixture::face1_onReceiveInterest, this, _1));
|
||||
face1->onReceiveData.connect(bind(&EndToEndFixture::face1_onReceiveData, this, _1));
|
||||
|
||||
limitedIo.afterOp();
|
||||
}
|
||||
@@ -199,10 +197,8 @@ BOOST_FIXTURE_TEST_CASE(EndToEnd, EndToEndFixture)
|
||||
face1localUri.size() - std::string(CHANNEL_PATH1).size());
|
||||
|
||||
face2 = make_shared<UnixStreamFace>(client);
|
||||
face2->onReceiveInterest +=
|
||||
bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
|
||||
face2->onReceiveData +=
|
||||
bind(&EndToEndFixture::face2_onReceiveData, this, _1);
|
||||
face2->onReceiveInterest.connect(bind(&EndToEndFixture::face2_onReceiveInterest, this, _1));
|
||||
face2->onReceiveData.connect(bind(&EndToEndFixture::face2_onReceiveData, this, _1));
|
||||
|
||||
shared_ptr<Interest> interest1 = makeInterest("ndn:/TpnzGvW9R");
|
||||
shared_ptr<Data> data1 = makeData("ndn:/KfczhUqVix");
|
||||
@@ -282,12 +278,12 @@ BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture)
|
||||
|
||||
// we should still be able to send/receive with the other one
|
||||
face1 = faces.back();
|
||||
face1->onReceiveInterest += bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
|
||||
face1->onReceiveData += bind(&EndToEndFixture::face1_onReceiveData, this, _1);
|
||||
face1->onReceiveInterest.connect(bind(&EndToEndFixture::face1_onReceiveInterest, this, _1));
|
||||
face1->onReceiveData.connect(bind(&EndToEndFixture::face1_onReceiveData, this, _1));
|
||||
|
||||
face2 = make_shared<UnixStreamFace>(client2);
|
||||
face2->onReceiveInterest += bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
|
||||
face2->onReceiveData += bind(&EndToEndFixture::face2_onReceiveData, this, _1);
|
||||
face2->onReceiveInterest.connect(bind(&EndToEndFixture::face2_onReceiveInterest, this, _1));
|
||||
face2->onReceiveData.connect(bind(&EndToEndFixture::face2_onReceiveData, this, _1));
|
||||
|
||||
shared_ptr<Interest> interest1 = makeInterest("ndn:/TpnzGvW9R");
|
||||
shared_ptr<Data> data1 = makeData("ndn:/KfczhUqVix");
|
||||
@@ -336,10 +332,8 @@ BOOST_FIXTURE_TEST_CASE(UnixStreamFaceLocalControlHeader, EndToEndFixture)
|
||||
BOOST_REQUIRE(static_cast<bool>(face1));
|
||||
|
||||
face2 = make_shared<UnixStreamFace>(client);
|
||||
face2->onReceiveInterest +=
|
||||
bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
|
||||
face2->onReceiveData +=
|
||||
bind(&EndToEndFixture::face2_onReceiveData, this, _1);
|
||||
face2->onReceiveInterest.connect(bind(&EndToEndFixture::face2_onReceiveInterest, this, _1));
|
||||
face2->onReceiveData.connect(bind(&EndToEndFixture::face2_onReceiveData, this, _1));
|
||||
|
||||
shared_ptr<Interest> interest1 = makeInterest("ndn:/TpnzGvW9R");
|
||||
shared_ptr<Data> data1 = makeData("ndn:/KfczhUqVix");
|
||||
@@ -425,12 +419,9 @@ public:
|
||||
void
|
||||
onFaceCreated(const shared_ptr<Face>& face)
|
||||
{
|
||||
face->onReceiveInterest +=
|
||||
bind(&SimpleEndToEndFixture::onReceiveInterest, this, _1);
|
||||
face->onReceiveData +=
|
||||
bind(&SimpleEndToEndFixture::onReceiveData, this, _1);
|
||||
face->onFail +=
|
||||
bind(&SimpleEndToEndFixture::onFail, this, face);
|
||||
face->onReceiveInterest.connect(bind(&SimpleEndToEndFixture::onReceiveInterest, this, _1));
|
||||
face->onReceiveData.connect(bind(&SimpleEndToEndFixture::onReceiveData, this, _1));
|
||||
face->onFail.connect(bind(&SimpleEndToEndFixture::onFail, this, face));
|
||||
|
||||
if (static_cast<bool>(dynamic_pointer_cast<LocalFace>(face))) {
|
||||
static_pointer_cast<LocalFace>(face)->setLocalControlHeaderFeature(
|
||||
|
||||
@@ -70,12 +70,9 @@ public:
|
||||
{
|
||||
BOOST_CHECK(!static_cast<bool>(face1));
|
||||
face1 = newFace;
|
||||
face1->onReceiveInterest +=
|
||||
bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
|
||||
face1->onReceiveData +=
|
||||
bind(&EndToEndFixture::face1_onReceiveData, this, _1);
|
||||
face1->onFail +=
|
||||
bind(&EndToEndFixture::face1_onFail, this);
|
||||
face1->onReceiveInterest.connect(bind(&EndToEndFixture::face1_onReceiveInterest, this, _1));
|
||||
face1->onReceiveData.connect(bind(&EndToEndFixture::face1_onReceiveData, this, _1));
|
||||
face1->onFail.connect(bind(&EndToEndFixture::face1_onFail, this));
|
||||
|
||||
limitedIo.afterOp();
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ BOOST_AUTO_TEST_CASE(SimpleExchange)
|
||||
|
||||
shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
|
||||
shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
|
||||
face1->afterSend += afterOp;
|
||||
face2->afterSend += afterOp;
|
||||
face1->afterSend.connect(afterOp);
|
||||
face2->afterSend.connect(afterOp);
|
||||
forwarder.addFace(face1);
|
||||
forwarder.addFace(face2);
|
||||
|
||||
@@ -433,9 +433,9 @@ BOOST_FIXTURE_TEST_CASE(InterestLoopWithShortLifetime, UnitTestTimeFixture) // B
|
||||
forwarder.addFace(face2);
|
||||
|
||||
// cause an Interest sent out of face2 to loop back into face1 after a delay
|
||||
face2->onSendInterest += [&face1] (const Interest& interest) {
|
||||
face2->onSendInterest.connect([&face1] (const Interest& interest) {
|
||||
scheduler::schedule(time::milliseconds(170), [&] { face1->receiveInterest(interest); });
|
||||
};
|
||||
});
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
shared_ptr<fib::Entry> fibEntry = fib.insert(Name("ndn:/A")).first;
|
||||
|
||||
@@ -144,8 +144,7 @@ BOOST_AUTO_TEST_CASE(Publish)
|
||||
m_expectedEntries[expectedEntry.getLocalUri()] = expectedEntry;
|
||||
}
|
||||
|
||||
m_face->onReceiveData +=
|
||||
bind(&ChannelStatusPublisherFixture::validatePublish, this, _1);
|
||||
m_face->onReceiveData.connect(bind(&ChannelStatusPublisherFixture::validatePublish, this, _1));
|
||||
|
||||
m_publisher.publish();
|
||||
BOOST_REQUIRE(m_finished);
|
||||
@@ -171,8 +170,7 @@ BOOST_AUTO_TEST_CASE(DuplicateFactories)
|
||||
m_expectedEntries[expectedEntry.getLocalUri()] = expectedEntry;
|
||||
}
|
||||
|
||||
m_face->onReceiveData +=
|
||||
bind(&ChannelStatusPublisherFixture::validatePublish, this, _1);
|
||||
m_face->onReceiveData.connect(bind(&ChannelStatusPublisherFixture::validatePublish, this, _1));
|
||||
|
||||
m_publisher.publish();
|
||||
BOOST_REQUIRE(m_finished);
|
||||
|
||||
+116
-100
@@ -797,9 +797,9 @@ BOOST_AUTO_TEST_CASE(ShortName)
|
||||
{
|
||||
shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/faces"));
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getFace()->sendInterest(*command);
|
||||
g_io.run_one();
|
||||
@@ -811,9 +811,9 @@ BOOST_AUTO_TEST_CASE(MalformedCommmand)
|
||||
{
|
||||
shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/faces"));
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onFaceRequest(*command);
|
||||
|
||||
@@ -833,9 +833,9 @@ BOOST_AUTO_TEST_CASE(UnsignedCommand)
|
||||
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 401, "Signature required");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onFaceRequest(*command);
|
||||
|
||||
@@ -856,9 +856,9 @@ BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand, UnauthorizedCommandFixture<FaceMana
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 403, "Unauthorized command");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onFaceRequest(*command);
|
||||
|
||||
@@ -894,9 +894,9 @@ BOOST_FIXTURE_TEST_CASE(UnsupportedCommand, AuthorizedCommandFixture<FaceManager
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 501, "Unsupported command");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onFaceRequest(*command);
|
||||
|
||||
@@ -910,7 +910,7 @@ class ValidatedFaceRequestFixture : public TestFaceTableFixture,
|
||||
public:
|
||||
|
||||
ValidatedFaceRequestFixture()
|
||||
: FaceManager(TestFaceTableFixture::m_faceTable, TestFaceManagerCommon::m_face, m_testKeyChain),
|
||||
: FaceManager(TestFaceTableFixture::m_faceTable, getFace(), m_testKeyChain),
|
||||
m_createFaceFired(false),
|
||||
m_destroyFaceFired(false)
|
||||
{
|
||||
@@ -964,9 +964,9 @@ BOOST_FIXTURE_TEST_CASE(ValidatedFaceRequestBadOptionParse,
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(command);
|
||||
|
||||
@@ -1035,7 +1035,7 @@ class LocalControlFixture : public FaceTableFixture,
|
||||
{
|
||||
public:
|
||||
LocalControlFixture()
|
||||
: FaceManager(FaceTableFixture::m_faceTable, TestFaceManagerCommon::m_face, m_testKeyChain)
|
||||
: FaceManager(FaceTableFixture::m_faceTable, getFace(), m_testKeyChain)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -1060,11 +1060,11 @@ BOOST_FIXTURE_TEST_CASE(LocalControlInFaceId,
|
||||
|
||||
generateCommand(*enableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData +=
|
||||
[this, enableCommand, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
signal::Connection conn = getFace()->onReceiveData.connect(
|
||||
[this, enableCommand, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(enableCommand);
|
||||
|
||||
@@ -1072,7 +1072,7 @@ BOOST_FIXTURE_TEST_CASE(LocalControlInFaceId,
|
||||
BOOST_REQUIRE(dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
|
||||
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData.clear();
|
||||
conn.disconnect();
|
||||
resetCallbackFired();
|
||||
|
||||
Name disable("/localhost/nfd/faces/disable-local-control");
|
||||
@@ -1083,11 +1083,11 @@ BOOST_FIXTURE_TEST_CASE(LocalControlInFaceId,
|
||||
|
||||
generateCommand(*disableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData +=
|
||||
[this, disableCommand, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
getFace()->onReceiveData.connect(
|
||||
[this, disableCommand, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(disableCommand);
|
||||
|
||||
@@ -1116,9 +1116,10 @@ BOOST_FIXTURE_TEST_CASE(LocalControlInFaceIdFaceNotFound,
|
||||
|
||||
generateCommand(*enableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData += [this, enableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(), 410, "Face not found");
|
||||
};
|
||||
signal::Connection conn = getFace()->onReceiveData.connect(
|
||||
[this, enableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(), 410, "Face not found");
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(enableCommand);
|
||||
|
||||
@@ -1126,7 +1127,7 @@ BOOST_FIXTURE_TEST_CASE(LocalControlInFaceIdFaceNotFound,
|
||||
BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
|
||||
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData.clear();
|
||||
conn.disconnect();
|
||||
resetCallbackFired();
|
||||
|
||||
Name disable("/localhost/nfd/faces/disable-local-control");
|
||||
@@ -1137,9 +1138,10 @@ BOOST_FIXTURE_TEST_CASE(LocalControlInFaceIdFaceNotFound,
|
||||
|
||||
generateCommand(*disableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData += [this, disableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(), 410, "Face not found");
|
||||
};
|
||||
getFace()->onReceiveData.connect(
|
||||
[this, disableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(), 410, "Face not found");
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(disableCommand);
|
||||
|
||||
@@ -1167,9 +1169,11 @@ BOOST_FIXTURE_TEST_CASE(LocalControlMissingFeature,
|
||||
|
||||
generateCommand(*enableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData += [this, enableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(), 400, "Malformed command");
|
||||
};
|
||||
signal::Connection conn = getFace()->onReceiveData.connect(
|
||||
[this, enableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(),
|
||||
400, "Malformed command");
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(enableCommand);
|
||||
|
||||
@@ -1177,7 +1181,7 @@ BOOST_FIXTURE_TEST_CASE(LocalControlMissingFeature,
|
||||
BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
|
||||
BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData.clear();
|
||||
conn.disconnect();
|
||||
resetCallbackFired();
|
||||
|
||||
Name disable("/localhost/nfd/faces/disable-local-control");
|
||||
@@ -1188,9 +1192,11 @@ BOOST_FIXTURE_TEST_CASE(LocalControlMissingFeature,
|
||||
|
||||
generateCommand(*disableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData += [this, disableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(), 400, "Malformed command");
|
||||
};
|
||||
getFace()->onReceiveData.connect(
|
||||
[this, disableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(),
|
||||
400, "Malformed command");
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(disableCommand);
|
||||
|
||||
@@ -1219,15 +1225,17 @@ BOOST_FIXTURE_TEST_CASE(LocalControlInFaceIdNonLocal,
|
||||
|
||||
generateCommand(*enableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData += [this, enableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(), 412, "Face is non-local");
|
||||
};
|
||||
signal::Connection conn = getFace()->onReceiveData.connect(
|
||||
[this, enableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(),
|
||||
412, "Face is non-local");
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(enableCommand);
|
||||
|
||||
BOOST_REQUIRE(didCallbackFire());
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData.clear();
|
||||
conn.disconnect();
|
||||
resetCallbackFired();
|
||||
|
||||
Name disable("/localhost/nfd/faces/disable-local-control");
|
||||
@@ -1238,9 +1246,11 @@ BOOST_FIXTURE_TEST_CASE(LocalControlInFaceIdNonLocal,
|
||||
|
||||
generateCommand(*disableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData += [this, disableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(), 412, "Face is non-local");
|
||||
};
|
||||
getFace()->onReceiveData.connect(
|
||||
[this, disableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(),
|
||||
412, "Face is non-local");
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(disableCommand);
|
||||
|
||||
@@ -1267,11 +1277,11 @@ BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceId,
|
||||
|
||||
generateCommand(*enableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData +=
|
||||
[this, enableCommand, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
signal::Connection conn = getFace()->onReceiveData.connect(
|
||||
[this, enableCommand, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(enableCommand);
|
||||
|
||||
@@ -1280,7 +1290,7 @@ BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceId,
|
||||
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
|
||||
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData.clear();
|
||||
conn.disconnect();
|
||||
resetCallbackFired();
|
||||
|
||||
Name disable("/localhost/nfd/faces/disable-local-control");
|
||||
@@ -1291,11 +1301,11 @@ BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceId,
|
||||
|
||||
generateCommand(*disableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData +=
|
||||
[this, disableCommand, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
getFace()->onReceiveData.connect(
|
||||
[this, disableCommand, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(disableCommand);
|
||||
|
||||
@@ -1324,9 +1334,10 @@ BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceIdFaceNotFound,
|
||||
|
||||
generateCommand(*enableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData += [this, enableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(), 410, "Face not found");
|
||||
};
|
||||
signal::Connection conn = getFace()->onReceiveData.connect(
|
||||
[this, enableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(), 410, "Face not found");
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(enableCommand);
|
||||
|
||||
@@ -1335,7 +1346,7 @@ BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceIdFaceNotFound,
|
||||
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
|
||||
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData.clear();
|
||||
conn.disconnect();
|
||||
resetCallbackFired();
|
||||
|
||||
Name disable("/localhost/nfd/faces/disable-local-control");
|
||||
@@ -1346,9 +1357,11 @@ BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceIdFaceNotFound,
|
||||
|
||||
generateCommand(*disableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData += [this, disableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(), 410, "Face not found");
|
||||
};
|
||||
getFace()->onReceiveData.connect(
|
||||
[this, disableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(),
|
||||
410, "Face not found");
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(disableCommand);
|
||||
|
||||
@@ -1377,15 +1390,17 @@ BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceIdNonLocal,
|
||||
|
||||
generateCommand(*enableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData += [this, enableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(), 412, "Face is non-local");
|
||||
};
|
||||
signal::Connection conn = getFace()->onReceiveData.connect(
|
||||
[this, enableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, enableCommand->getName(),
|
||||
412, "Face is non-local");
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(enableCommand);
|
||||
|
||||
BOOST_REQUIRE(didCallbackFire());
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData.clear();
|
||||
conn.disconnect();
|
||||
resetCallbackFired();
|
||||
|
||||
Name disable("/localhost/nfd/faces/disable-local-control");
|
||||
@@ -1396,9 +1411,11 @@ BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceIdNonLocal,
|
||||
|
||||
generateCommand(*disableCommand);
|
||||
|
||||
TestFaceManagerCommon::m_face->onReceiveData += [this, disableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(), 412, "Face is non-local");
|
||||
};
|
||||
getFace()->onReceiveData.connect(
|
||||
[this, disableCommand] (const Data& response) {
|
||||
this->validateControlResponse(response, disableCommand->getName(),
|
||||
412, "Face is non-local");
|
||||
});
|
||||
|
||||
onValidatedFaceRequest(disableCommand);
|
||||
|
||||
@@ -1412,7 +1429,7 @@ class FaceFixture : public FaceTableFixture,
|
||||
public:
|
||||
FaceFixture()
|
||||
: FaceManager(FaceTableFixture::m_faceTable,
|
||||
TestFaceManagerCommon::m_face,
|
||||
getFace(),
|
||||
m_testKeyChain)
|
||||
, m_receivedNotification(false)
|
||||
{
|
||||
@@ -1514,9 +1531,9 @@ BOOST_FIXTURE_TEST_CASE(CreateFaceBadUri, AuthorizedCommandFixture<FaceFixture>)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
createFace(*command, parameters);
|
||||
|
||||
@@ -1536,9 +1553,9 @@ BOOST_FIXTURE_TEST_CASE(CreateFaceNoncanonicalUri, AuthorizedCommandFixture<Face
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Non-canonical URI");
|
||||
};
|
||||
});
|
||||
|
||||
createFace(*command, parameters);
|
||||
|
||||
@@ -1558,9 +1575,9 @@ BOOST_FIXTURE_TEST_CASE(CreateFaceMissingUri, AuthorizedCommandFixture<FaceFixtu
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
createFace(*command, parameters);
|
||||
|
||||
@@ -1583,9 +1600,9 @@ BOOST_FIXTURE_TEST_CASE(CreateFaceUnknownScheme, AuthorizedCommandFixture<FaceFi
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 501, "Unsupported protocol");
|
||||
};
|
||||
});
|
||||
|
||||
createFace(*command, parameters);
|
||||
|
||||
@@ -1622,11 +1639,11 @@ BOOST_FIXTURE_TEST_CASE(OnCreated, AuthorizedCommandFixture<FaceFixture>)
|
||||
|
||||
Block encodedResultParameters(resultParameters.wireEncode());
|
||||
|
||||
getFace()->onReceiveData +=
|
||||
[this, command, encodedResultParameters, expectedFaceEvent] (const Data& response) {
|
||||
this->callbackDispatch(response,command->getName(), 200, "Success",
|
||||
encodedResultParameters, expectedFaceEvent);
|
||||
};
|
||||
getFace()->onReceiveData.connect(
|
||||
[this, command, encodedResultParameters, expectedFaceEvent] (const Data& response) {
|
||||
this->callbackDispatch(response,command->getName(), 200, "Success",
|
||||
encodedResultParameters, expectedFaceEvent);
|
||||
});
|
||||
|
||||
onCreated(command->getName(), parameters, dummy);
|
||||
|
||||
@@ -1648,9 +1665,9 @@ BOOST_FIXTURE_TEST_CASE(OnConnectFailed, AuthorizedCommandFixture<FaceFixture>)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 408, "unit-test-reason");
|
||||
};
|
||||
});
|
||||
|
||||
onConnectFailed(command->getName(), "unit-test-reason");
|
||||
|
||||
@@ -1684,11 +1701,11 @@ BOOST_FIXTURE_TEST_CASE(DestroyFace, AuthorizedCommandFixture<FaceFixture>)
|
||||
.setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL)
|
||||
.setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
|
||||
|
||||
getFace()->onReceiveData +=
|
||||
[this, command, encodedParameters, expectedFaceEvent] (const Data& response) {
|
||||
this->callbackDispatch(response,command->getName(), 200, "Success",
|
||||
encodedParameters, expectedFaceEvent);
|
||||
};
|
||||
getFace()->onReceiveData.connect(
|
||||
[this, command, encodedParameters, expectedFaceEvent] (const Data& response) {
|
||||
this->callbackDispatch(response,command->getName(), 200, "Success",
|
||||
encodedParameters, expectedFaceEvent);
|
||||
});
|
||||
|
||||
destroyFace(*command, parameters);
|
||||
|
||||
@@ -1737,8 +1754,8 @@ BOOST_FIXTURE_TEST_CASE(TestFaceList, FaceListFixture)
|
||||
|
||||
ndn::EncodingBuffer buffer;
|
||||
|
||||
m_face->onReceiveData +=
|
||||
bind(&FaceStatusPublisherFixture::decodeFaceStatusBlock, this, _1);
|
||||
m_face->onReceiveData.connect(bind(&FaceStatusPublisherFixture::decodeFaceStatusBlock,
|
||||
this, _1));
|
||||
|
||||
m_manager.listFaces(*command);
|
||||
BOOST_REQUIRE(m_finished);
|
||||
@@ -1777,8 +1794,8 @@ BOOST_FIXTURE_TEST_CASE(TestChannelStatus, ChannelStatusFixture)
|
||||
ndn::nfd::ChannelStatus expectedEntry;
|
||||
expectedEntry.setLocalUri(DummyChannel("dummy://").getUri().toString());
|
||||
|
||||
m_face->onReceiveData +=
|
||||
bind(&ChannelStatusFixture::validatePublish, this, _1, expectedEntry);
|
||||
m_face->onReceiveData.connect(bind(&ChannelStatusFixture::validatePublish,
|
||||
this, _1, expectedEntry));
|
||||
|
||||
m_manager.listChannels(*request);
|
||||
BOOST_REQUIRE(m_callbackFired);
|
||||
@@ -1828,8 +1845,8 @@ BOOST_FIXTURE_TEST_CASE(TestValidQueryFilter, FaceQueryListFixture)
|
||||
shared_ptr<DummyLocalFace> face2(make_shared<DummyLocalFace>("tcp://", "tcp://"));
|
||||
add(face2);
|
||||
|
||||
m_face->onReceiveData +=
|
||||
bind(&FaceQueryStatusPublisherFixture::decodeFaceStatusBlock, this, _1);
|
||||
m_face->onReceiveData.connect(bind(&FaceQueryStatusPublisherFixture::decodeFaceStatusBlock,
|
||||
this, _1));
|
||||
|
||||
m_manager.listQueriedFaces(*query);
|
||||
BOOST_REQUIRE(m_finished);
|
||||
@@ -1846,8 +1863,7 @@ BOOST_FIXTURE_TEST_CASE(TestInvalidQueryFilter, FaceQueryListFixture)
|
||||
shared_ptr<DummyLocalFace> face(make_shared<DummyLocalFace>());
|
||||
add(face);
|
||||
|
||||
m_face->onReceiveData +=
|
||||
bind(&FaceQueryStatusPublisherFixture::decodeNackBlock, this, _1);
|
||||
m_face->onReceiveData.connect(bind(&FaceQueryStatusPublisherFixture::decodeNackBlock, this, _1));
|
||||
|
||||
m_manager.listQueriedFaces(*query);
|
||||
BOOST_REQUIRE(m_finished);
|
||||
|
||||
@@ -53,8 +53,8 @@ BOOST_AUTO_TEST_CASE(EncodingDecoding)
|
||||
|
||||
ndn::EncodingBuffer buffer;
|
||||
|
||||
m_face->onReceiveData +=
|
||||
bind(&FaceStatusPublisherFixture::decodeFaceStatusBlock, this, _1);
|
||||
m_face->onReceiveData.connect(
|
||||
bind(&FaceStatusPublisherFixture::decodeFaceStatusBlock, this, _1));
|
||||
|
||||
m_publisher.publish();
|
||||
BOOST_REQUIRE(m_finished);
|
||||
|
||||
@@ -77,8 +77,8 @@ BOOST_AUTO_TEST_CASE(TestFibEnumerationPublisher)
|
||||
|
||||
ndn::EncodingBuffer buffer;
|
||||
|
||||
m_face->onReceiveData +=
|
||||
bind(&FibEnumerationPublisherFixture::decodeFibEntryBlock, this, _1);
|
||||
m_face->onReceiveData.connect(
|
||||
bind(&FibEnumerationPublisherFixture::decodeFibEntryBlock, this, _1));
|
||||
|
||||
m_publisher.publish();
|
||||
BOOST_REQUIRE(m_finished);
|
||||
|
||||
@@ -241,9 +241,9 @@ BOOST_AUTO_TEST_CASE(ShortName)
|
||||
|
||||
shared_ptr<Interest> command = makeInterest("/localhost/nfd/fib");
|
||||
|
||||
face->onReceiveData += [this, command] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
face->sendInterest(*command);
|
||||
g_io.run_one();
|
||||
@@ -259,9 +259,9 @@ BOOST_AUTO_TEST_CASE(MalformedCommmand)
|
||||
|
||||
Interest command("/localhost/nfd/fib");
|
||||
|
||||
face->onReceiveData += [this, command] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command.getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(command);
|
||||
|
||||
@@ -286,9 +286,9 @@ BOOST_AUTO_TEST_CASE(UnsupportedVerb)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 501, "Unsupported command");
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
@@ -314,9 +314,9 @@ BOOST_AUTO_TEST_CASE(UnsignedCommand)
|
||||
|
||||
Interest command(commandName);
|
||||
|
||||
face->onReceiveData += [this, command] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command.getName(), 401, "Signature required");
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(command);
|
||||
|
||||
@@ -344,9 +344,9 @@ BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand, UnauthorizedCommandFixture<FibManag
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 403, "Unauthorized command");
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
@@ -367,9 +367,9 @@ BOOST_AUTO_TEST_CASE(BadOptionParse)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
@@ -396,9 +396,9 @@ BOOST_AUTO_TEST_CASE(UnknownFaceId)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 410, "Face not found");
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
@@ -436,17 +436,18 @@ BOOST_AUTO_TEST_CASE(AddNextHopVerbImplicitFaceId)
|
||||
command->setIncomingFaceId(1);
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command, encodedExpectedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedExpectedParameters);
|
||||
};
|
||||
signal::Connection conn = face->onReceiveData.connect(
|
||||
[this, command, encodedExpectedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedExpectedParameters);
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
BOOST_REQUIRE(didCallbackFire());
|
||||
BOOST_REQUIRE(addedNextHopWithFace(getFib(), "/hello", 0, 101, getFace(1)));
|
||||
|
||||
face->onReceiveData.clear();
|
||||
conn.disconnect();
|
||||
getFib().erase("/hello");
|
||||
BOOST_REQUIRE_EQUAL(getFib().size(), 0);
|
||||
}
|
||||
@@ -472,10 +473,10 @@ BOOST_AUTO_TEST_CASE(AddNextHopVerbInitialAdd)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
@@ -507,10 +508,10 @@ BOOST_AUTO_TEST_CASE(AddNextHopVerbImplicitCost)
|
||||
resultParameters.setFaceId(1);
|
||||
resultParameters.setCost(0);
|
||||
|
||||
face->onReceiveData += [this, command, resultParameters] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command, resultParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", resultParameters.wireEncode());
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
@@ -540,10 +541,11 @@ BOOST_AUTO_TEST_CASE(AddNextHopVerbAddToExisting)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
signal::Connection conn = face->onReceiveData.connect(
|
||||
[this, command, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
BOOST_REQUIRE(didCallbackFire());
|
||||
@@ -564,7 +566,7 @@ BOOST_AUTO_TEST_CASE(AddNextHopVerbAddToExisting)
|
||||
BOOST_FAIL("Failed to find expected fib entry");
|
||||
}
|
||||
|
||||
face->onReceiveData.clear();
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,18 +591,19 @@ BOOST_AUTO_TEST_CASE(AddNextHopVerbUpdateFaceCost)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
signal::Connection conn = face->onReceiveData.connect(
|
||||
[this, command, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
BOOST_REQUIRE(didCallbackFire());
|
||||
}
|
||||
|
||||
resetCallbackFired();
|
||||
face->onReceiveData.clear();
|
||||
resetCallbackFired();
|
||||
conn.disconnect();
|
||||
}
|
||||
|
||||
{
|
||||
parameters.setCost(102);
|
||||
@@ -614,10 +617,10 @@ BOOST_AUTO_TEST_CASE(AddNextHopVerbUpdateFaceCost)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
@@ -661,9 +664,9 @@ BOOST_AUTO_TEST_CASE(AddNextHopVerbMissingPrefix)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
@@ -705,17 +708,18 @@ testRemoveNextHop(CommandFixture<FibManagerFixture>* fixture,
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
fixture->generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [fixture, command, encodedParameters] (const Data& response) {
|
||||
fixture->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
signal::Connection conn = face->onReceiveData.connect(
|
||||
[fixture, command, encodedParameters] (const Data& response) {
|
||||
fixture->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
});
|
||||
|
||||
manager.onFibRequest(*command);
|
||||
|
||||
BOOST_REQUIRE(fixture->didCallbackFire());
|
||||
|
||||
fixture->resetCallbackFired();
|
||||
face->onReceiveData.clear();
|
||||
conn.disconnect();
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RemoveNextHop)
|
||||
@@ -767,10 +771,10 @@ BOOST_AUTO_TEST_CASE(RemoveFaceNotFound)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
@@ -796,10 +800,10 @@ BOOST_AUTO_TEST_CASE(RemovePrefixNotFound)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
@@ -824,9 +828,9 @@ BOOST_AUTO_TEST_CASE(RemoveMissingPrefix)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
face->onReceiveData += [this, command] (const Data& response) {
|
||||
face->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
@@ -859,16 +863,17 @@ BOOST_AUTO_TEST_CASE(RemoveImplicitFaceId)
|
||||
resultParameters.setFaceId(1);
|
||||
resultParameters.setName("/hello");
|
||||
|
||||
face->onReceiveData += [this, command, resultParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", resultParameters.wireEncode());
|
||||
};
|
||||
signal::Connection conn = face->onReceiveData.connect(
|
||||
[this, command, resultParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", resultParameters.wireEncode());
|
||||
});
|
||||
|
||||
getFibManager().onFibRequest(*command);
|
||||
|
||||
BOOST_REQUIRE(didCallbackFire());
|
||||
|
||||
face->onReceiveData.clear();
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -905,8 +910,8 @@ BOOST_FIXTURE_TEST_CASE(TestFibEnumerationRequest, FibManagerFixture)
|
||||
|
||||
ndn::EncodingBuffer buffer;
|
||||
|
||||
m_face->onReceiveData +=
|
||||
bind(&FibEnumerationPublisherFixture::decodeFibEntryBlock, this, _1);
|
||||
m_face->onReceiveData.connect(bind(&FibEnumerationPublisherFixture::decodeFibEntryBlock,
|
||||
this, _1));
|
||||
|
||||
shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/fib/list"));
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
namespace nfd {
|
||||
namespace tests {
|
||||
|
||||
NFD_LOG_INIT("InternalFaceTest");
|
||||
|
||||
class InternalFaceFixture : protected BaseFixture
|
||||
{
|
||||
public:
|
||||
@@ -112,7 +110,7 @@ BOOST_AUTO_TEST_CASE(PutData)
|
||||
|
||||
bool didPutData = false;
|
||||
Name dataName("/hello");
|
||||
face->onReceiveData += bind(&validatePutData, ref(didPutData), dataName, _1);
|
||||
face->onReceiveData.connect(bind(&validatePutData, ref(didPutData), dataName, _1));
|
||||
|
||||
Data testData(dataName);
|
||||
m_keyChain.sign(testData);
|
||||
|
||||
@@ -166,9 +166,9 @@ BOOST_AUTO_TEST_CASE(SendResponse4Arg)
|
||||
ndn::nfd::ControlParameters parameters;
|
||||
parameters.setName("/test/body");
|
||||
|
||||
getInternalFace()->onReceiveData += [this, parameters] (const Data& response) {
|
||||
getInternalFace()->onReceiveData.connect([this, parameters] (const Data& response) {
|
||||
this->validateControlResponse(response, "/response", 100, "test", parameters.wireEncode());
|
||||
};
|
||||
});
|
||||
|
||||
testSendResponse("/response", 100, "test", parameters.wireEncode());
|
||||
BOOST_REQUIRE(didCallbackFire());
|
||||
@@ -177,9 +177,9 @@ BOOST_AUTO_TEST_CASE(SendResponse4Arg)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SendResponse3Arg)
|
||||
{
|
||||
getInternalFace()->onReceiveData += [this] (const Data& response) {
|
||||
getInternalFace()->onReceiveData.connect([this] (const Data& response) {
|
||||
this->validateControlResponse(response, "/response", 100, "test");
|
||||
};
|
||||
});
|
||||
|
||||
testSendResponse("/response", 100, "test");
|
||||
BOOST_REQUIRE(didCallbackFire());
|
||||
@@ -187,9 +187,9 @@ BOOST_AUTO_TEST_CASE(SendResponse3Arg)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SendResponse2Arg)
|
||||
{
|
||||
getInternalFace()->onReceiveData += [this] (const Data& response) {
|
||||
getInternalFace()->onReceiveData.connect([this] (const Data& response) {
|
||||
this->validateControlResponse(response, "/response", 100, "test");
|
||||
};
|
||||
});
|
||||
|
||||
ControlResponse response(100, "test");
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(Status)
|
||||
time::system_clock::TimePoint t1 = time::system_clock::now();
|
||||
Forwarder forwarder;
|
||||
shared_ptr<InternalFace> internalFace = make_shared<InternalFace>();
|
||||
internalFace->onReceiveData += &interceptResponse;
|
||||
internalFace->onReceiveData.connect(&interceptResponse);
|
||||
ndn::KeyChain keyChain;
|
||||
StatusServer statusServer(internalFace, ref(forwarder), keyChain);
|
||||
time::system_clock::TimePoint t2 = time::system_clock::now();
|
||||
|
||||
@@ -225,9 +225,9 @@ BOOST_FIXTURE_TEST_CASE(ShortName, AllStrategiesFixture)
|
||||
{
|
||||
shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/strategy-choice"));
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getFace()->sendInterest(*command);
|
||||
g_io.run_one();
|
||||
@@ -239,9 +239,9 @@ BOOST_FIXTURE_TEST_CASE(MalformedCommmand, AllStrategiesFixture)
|
||||
{
|
||||
shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/strategy-choice"));
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onStrategyChoiceRequest(*command);
|
||||
|
||||
@@ -262,9 +262,9 @@ BOOST_FIXTURE_TEST_CASE(UnsignedCommand, AllStrategiesFixture)
|
||||
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 401, "Signature required");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onStrategyChoiceRequest(*command);
|
||||
|
||||
@@ -287,9 +287,9 @@ BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand,
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 403, "Unauthorized command");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onStrategyChoiceRequest(*command);
|
||||
|
||||
@@ -311,9 +311,9 @@ BOOST_AUTO_TEST_CASE(UnsupportedVerb)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 501, "Unsupported command");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onValidatedStrategyChoiceRequest(command);
|
||||
|
||||
@@ -329,9 +329,9 @@ BOOST_AUTO_TEST_CASE(BadOptionParse)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onValidatedStrategyChoiceRequest(command);
|
||||
|
||||
@@ -352,10 +352,10 @@ BOOST_AUTO_TEST_CASE(SetStrategies)
|
||||
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
|
||||
getFace()->onReceiveData += [this, command, encodedParameters] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onValidatedStrategyChoiceRequest(command);
|
||||
|
||||
@@ -378,10 +378,10 @@ BOOST_AUTO_TEST_CASE(SetStrategySpecifiedVersion)
|
||||
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
|
||||
getFace()->onReceiveData += [this, command, encodedParameters] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onValidatedStrategyChoiceRequest(command);
|
||||
|
||||
@@ -408,10 +408,10 @@ BOOST_AUTO_TEST_CASE(SetStrategyLatestVersion)
|
||||
responseParameters.setName("/test");
|
||||
responseParameters.setStrategy("/localhost/nfd/strategy/test-strategy-c/%FD%02");
|
||||
|
||||
getFace()->onReceiveData += [this, command, responseParameters] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command, responseParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", responseParameters.wireEncode());
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onValidatedStrategyChoiceRequest(command);
|
||||
|
||||
@@ -433,9 +433,9 @@ BOOST_AUTO_TEST_CASE(SetStrategiesMissingName)
|
||||
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onValidatedStrategyChoiceRequest(command);
|
||||
|
||||
@@ -455,9 +455,9 @@ BOOST_AUTO_TEST_CASE(SetStrategiesMissingStrategy)
|
||||
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onValidatedStrategyChoiceRequest(command);
|
||||
|
||||
@@ -481,9 +481,9 @@ BOOST_AUTO_TEST_CASE(SetUnsupportedStrategy)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 504, "Unsupported strategy");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onValidatedStrategyChoiceRequest(command);
|
||||
|
||||
@@ -555,10 +555,10 @@ BOOST_AUTO_TEST_CASE(Unset)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command, encodedParameters] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command, encodedParameters] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
200, "Success", encodedParameters);
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onValidatedStrategyChoiceRequest(command);
|
||||
|
||||
@@ -582,10 +582,10 @@ BOOST_AUTO_TEST_CASE(UnsetRoot)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(),
|
||||
403, "Cannot unset root prefix strategy");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onValidatedStrategyChoiceRequest(command);
|
||||
|
||||
@@ -612,9 +612,9 @@ BOOST_AUTO_TEST_CASE(UnsetMissingName)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
getFace()->onReceiveData += [this, command] (const Data& response) {
|
||||
getFace()->onReceiveData.connect([this, command] (const Data& response) {
|
||||
this->validateControlResponse(response, command->getName(), 400, "Malformed command");
|
||||
};
|
||||
});
|
||||
|
||||
getManager().onValidatedStrategyChoiceRequest(command);
|
||||
|
||||
@@ -633,8 +633,8 @@ BOOST_AUTO_TEST_CASE(Publish)
|
||||
expectedChoice.setStrategy("/localhost/nfd/strategy/test-strategy-a");
|
||||
expectedChoice.setName("/");
|
||||
|
||||
getFace()->onReceiveData +=
|
||||
bind(&StrategyChoiceManagerFixture::validateList, this, _1, expectedChoice);
|
||||
getFace()->onReceiveData.connect(bind(&StrategyChoiceManagerFixture::validateList,
|
||||
this, _1, expectedChoice));
|
||||
|
||||
m_manager.onStrategyChoiceRequest(*command);
|
||||
BOOST_REQUIRE(didCallbackFire());
|
||||
|
||||
@@ -153,8 +153,7 @@ BOOST_AUTO_TEST_CASE(Publish)
|
||||
m_expectedEntries["/test/a"] = expectedEntryA;
|
||||
m_expectedEntries["/test/b"] = expectedEntryB;
|
||||
|
||||
m_face->onReceiveData +=
|
||||
bind(&StrategyChoicePublisherFixture::validatePublish, this, _1);
|
||||
m_face->onReceiveData.connect(bind(&StrategyChoicePublisherFixture::validatePublish, this, _1));
|
||||
|
||||
m_publisher.publish();
|
||||
BOOST_REQUIRE(m_finished);
|
||||
|
||||
Reference in new issue
Block a user