face: Face::getLocalUri
refs #1396
Change-Id: Icf02ae0a4136b6da3f6388cdce2f861bec44e940
diff --git a/daemon/face/datagram-face.hpp b/daemon/face/datagram-face.hpp
index f59374f..0da339c 100644
--- a/daemon/face/datagram-face.hpp
+++ b/daemon/face/datagram-face.hpp
@@ -20,12 +20,11 @@
/** \brief Construct datagram face
*
- * \param uri FaceUri for the face
* \param socket Protocol-specific socket for the created face
* \param isOnDemand If true, the face can be closed after it remains
* unused for a certain amount of time
*/
- DatagramFace(const FaceUri& uri,
+ DatagramFace(const FaceUri& remoteUri, const FaceUri& localUri,
const shared_ptr<typename protocol::socket>& socket,
bool isOnDemand);
@@ -85,10 +84,10 @@
template <class T>
inline
-DatagramFace<T>::DatagramFace(const FaceUri& uri,
+DatagramFace<T>::DatagramFace(const FaceUri& remoteUri, const FaceUri& localUri,
const shared_ptr<typename DatagramFace::protocol::socket>& socket,
bool isOnDemand)
- : Face(uri)
+ : Face(remoteUri, localUri)
, m_socket(socket)
{
setOnDemand(isOnDemand);
diff --git a/daemon/face/ethernet-face.cpp b/daemon/face/ethernet-face.cpp
index 66dcf08..4f70e43 100644
--- a/daemon/face/ethernet-face.cpp
+++ b/daemon/face/ethernet-face.cpp
@@ -25,7 +25,7 @@
EthernetFace::EthernetFace(const shared_ptr<boost::asio::posix::stream_descriptor>& socket,
const shared_ptr<NetworkInterfaceInfo>& interface,
const ethernet::Address& address)
- : Face(FaceUri("ether://" + interface->name + "/" + address.toString(':')))
+ : Face(FaceUri(address), FaceUri::fromDev(interface->name))
, m_socket(socket)
, m_interfaceName(interface->name)
, m_srcAddress(interface->etherAddress)
diff --git a/daemon/face/face.cpp b/daemon/face/face.cpp
index 08853aa..c0241fc 100644
--- a/daemon/face/face.cpp
+++ b/daemon/face/face.cpp
@@ -11,23 +11,23 @@
NFD_LOG_INIT("Face")
-template<class Packet>
static inline void
-increaseCounter(const Packet& packet, FaceCounter& counter)
+increaseCounter(FaceCounter& counter)
{
++counter;
}
-Face::Face(const FaceUri& uri, bool isLocal)
+Face::Face(const FaceUri& remoteUri, const FaceUri& localUri, bool isLocal)
: m_id(INVALID_FACEID)
, m_isLocal(isLocal)
- , m_uri(uri)
+ , m_remoteUri(remoteUri)
+ , m_localUri(localUri)
, m_isOnDemand(false)
{
- onReceiveInterest += bind(&increaseCounter<Interest>, _1, boost::ref(m_counters.getInInterest()));
- onReceiveData += bind(&increaseCounter<Data>, _1, boost::ref(m_counters.getInData()));
- onSendInterest += bind(&increaseCounter<Interest>, _1, boost::ref(m_counters.getOutInterest()));
- onSendData += bind(&increaseCounter<Data>, _1, boost::ref(m_counters.getOutData()));
+ onReceiveInterest += bind(&increaseCounter, boost::ref(m_counters.getInInterest()));
+ onReceiveData += bind(&increaseCounter, boost::ref(m_counters.getInData()));
+ onSendInterest += bind(&increaseCounter, boost::ref(m_counters.getOutInterest()));
+ onSendData += bind(&increaseCounter, boost::ref(m_counters.getOutData()));
}
Face::~Face()
diff --git a/daemon/face/face.hpp b/daemon/face/face.hpp
index e1ef2f8..3cb7160 100644
--- a/daemon/face/face.hpp
+++ b/daemon/face/face.hpp
@@ -32,19 +32,21 @@
/**
* \brief Face-related error
*/
- struct Error : public std::runtime_error
+ class Error : public std::runtime_error
{
- Error(const std::string& what) : std::runtime_error(what) {}
+ public:
+ explicit
+ Error(const std::string& what)
+ : std::runtime_error(what)
+ {
+ }
};
- Face(const FaceUri& uri, bool isLocal = false);
+ Face(const FaceUri& remoteUri, const FaceUri& localUri, bool isLocal = false);
virtual
~Face();
- FaceId
- getId() const;
-
/// fires when an Interest is received
EventEmitter<Interest> onReceiveInterest;
@@ -76,6 +78,10 @@
virtual void
close() = 0;
+public: // attributes
+ FaceId
+ getId() const;
+
/** \brief Set the description
*
* This is typically invoked by mgmt on set description command
@@ -114,9 +120,21 @@
const FaceCounters&
getCounters() const;
+ /** \deprecated use getRemoteUri instead
+ */
const FaceUri&
getUri() const;
+ /** \return a FaceUri that represents the remote endpoint
+ */
+ const FaceUri&
+ getRemoteUri() const;
+
+ /** \return a FaceUri that represents the local endpoint (NFD side)
+ */
+ const FaceUri&
+ getLocalUri() const;
+
protected:
// this is a non-virtual method
bool
@@ -137,7 +155,8 @@
std::string m_description;
bool m_isLocal; // for scoping purposes
FaceCounters m_counters;
- FaceUri m_uri;
+ FaceUri m_remoteUri;
+ FaceUri m_localUri;
bool m_isOnDemand;
// allow setting FaceId
@@ -166,7 +185,19 @@
inline const FaceUri&
Face::getUri() const
{
- return m_uri;
+ return this->getRemoteUri();
+}
+
+inline const FaceUri&
+Face::getRemoteUri() const
+{
+ return m_remoteUri;
+}
+
+inline const FaceUri&
+Face::getLocalUri() const
+{
+ return m_localUri;
}
inline void
diff --git a/daemon/face/local-face.hpp b/daemon/face/local-face.hpp
index d16a64f..b3ccc43 100644
--- a/daemon/face/local-face.hpp
+++ b/daemon/face/local-face.hpp
@@ -21,9 +21,7 @@
class LocalFace : public Face
{
public:
-
- explicit
- LocalFace(const FaceUri& uri);
+ LocalFace(const FaceUri& remoteUri, const FaceUri& localUri);
/** \brief get whether any LocalControlHeader feature is enabled
*
@@ -84,8 +82,8 @@
};
inline
-LocalFace::LocalFace(const FaceUri& uri)
- : Face(uri, true)
+LocalFace::LocalFace(const FaceUri& remoteUri, const FaceUri& localUri)
+ : Face(remoteUri, localUri, true)
, m_localControlHeaderFeatures(LocalFace::LOCAL_CONTROL_FEATURE_MAX)
{
}
diff --git a/daemon/face/multicast-udp-face.cpp b/daemon/face/multicast-udp-face.cpp
index 34d40f0..7866603 100644
--- a/daemon/face/multicast-udp-face.cpp
+++ b/daemon/face/multicast-udp-face.cpp
@@ -10,8 +10,11 @@
NFD_LOG_INIT("MulticastUdpFace");
-MulticastUdpFace::MulticastUdpFace(const shared_ptr<MulticastUdpFace::protocol::socket>& socket)
- : DatagramFace<protocol>(FaceUri(socket->local_endpoint()), socket, false)
+MulticastUdpFace::MulticastUdpFace(const shared_ptr<protocol::socket>& socket,
+ const protocol::endpoint& localEndpoint)
+ : DatagramFace<protocol>(FaceUri(socket->local_endpoint()),
+ FaceUri(localEndpoint),
+ socket, false)
, m_multicastGroup(m_socket->local_endpoint())
{
NFD_LOG_INFO("Creating multicast UDP face for group " << m_multicastGroup);
diff --git a/daemon/face/multicast-udp-face.hpp b/daemon/face/multicast-udp-face.hpp
index 774c567..f2245e5 100644
--- a/daemon/face/multicast-udp-face.hpp
+++ b/daemon/face/multicast-udp-face.hpp
@@ -21,8 +21,8 @@
/**
* \brief Creates a UDP-based face for multicast communication
*/
- explicit
- MulticastUdpFace(const shared_ptr<protocol::socket>& socket);
+ MulticastUdpFace(const shared_ptr<protocol::socket>& socket,
+ const protocol::endpoint& localEndpoint);
const protocol::endpoint&
getMulticastGroup() const;
diff --git a/daemon/face/stream-face.hpp b/daemon/face/stream-face.hpp
index 1b5b124..f60e87a 100644
--- a/daemon/face/stream-face.hpp
+++ b/daemon/face/stream-face.hpp
@@ -25,8 +25,7 @@
/**
* \brief Create instance of StreamFace
*/
- explicit
- StreamFace(const FaceUri& uri,
+ StreamFace(const FaceUri& remoteUri, const FaceUri& localUri,
const shared_ptr<typename protocol::socket>& socket,
bool isOnDemand);
@@ -100,10 +99,10 @@
template<class T, class FaceBase>
inline
-StreamFace<T, FaceBase>::StreamFace(const FaceUri& uri,
- const shared_ptr<typename StreamFace::protocol::socket>& socket,
- bool isOnDemand)
- : FaceBase(uri)
+StreamFace<T, FaceBase>::StreamFace(const FaceUri& remoteUri, const FaceUri& localUri,
+ const shared_ptr<typename StreamFace::protocol::socket>& socket,
+ bool isOnDemand)
+ : FaceBase(remoteUri, localUri)
, m_socket(socket)
, m_inputBufferSize(0)
{
diff --git a/daemon/face/tcp-face.cpp b/daemon/face/tcp-face.cpp
index 4655641..7462030 100644
--- a/daemon/face/tcp-face.cpp
+++ b/daemon/face/tcp-face.cpp
@@ -8,9 +8,6 @@
namespace nfd {
-// The whole purpose of this file is to specialize the logger,
-// otherwise, everything could be put into the header file.
-
NFD_LOG_INCLASS_TEMPLATE_SPECIALIZATION_DEFINE(StreamFace, TcpFace::protocol, "TcpFace");
NFD_LOG_INCLASS_2TEMPLATE_SPECIALIZATION_DEFINE(StreamFace,
@@ -18,14 +15,17 @@
"TcpLocalFace");
TcpFace::TcpFace(const shared_ptr<TcpFace::protocol::socket>& socket, bool isOnDemand)
- : StreamFace<protocol>(FaceUri(socket->remote_endpoint()), socket, isOnDemand)
+ : StreamFace<protocol>(FaceUri(socket->remote_endpoint()),
+ FaceUri(socket->local_endpoint()),
+ socket, isOnDemand)
{
}
-//
-
-TcpLocalFace::TcpLocalFace(const shared_ptr<TcpLocalFace::protocol::socket>& socket, bool isOnDemand)
- : StreamFace<protocol, LocalFace>(FaceUri(socket->remote_endpoint()), socket, isOnDemand)
+TcpLocalFace::TcpLocalFace(const shared_ptr<TcpLocalFace::protocol::socket>& socket,
+ bool isOnDemand)
+ : StreamFace<protocol, LocalFace>(FaceUri(socket->remote_endpoint()),
+ FaceUri(socket->local_endpoint()),
+ socket, isOnDemand)
{
}
diff --git a/daemon/face/udp-face.cpp b/daemon/face/udp-face.cpp
index 1cc0bc8..1a4eb9c 100644
--- a/daemon/face/udp-face.cpp
+++ b/daemon/face/udp-face.cpp
@@ -11,7 +11,9 @@
NFD_LOG_INCLASS_TEMPLATE_SPECIALIZATION_DEFINE(DatagramFace, UdpFace::protocol, "UdpFace");
UdpFace::UdpFace(const shared_ptr<UdpFace::protocol::socket>& socket, bool isOnDemand)
- : DatagramFace<protocol>(FaceUri(socket->remote_endpoint()), socket, isOnDemand)
+ : DatagramFace<protocol>(FaceUri(socket->remote_endpoint()),
+ FaceUri(socket->local_endpoint()),
+ socket, isOnDemand)
{
}
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index 7352a99..36b1fcd 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -11,7 +11,7 @@
namespace nfd {
using namespace boost::asio;
-
+
NFD_LOG_INIT("UdpFactory");
UdpFactory::UdpFactory(const std::string& defaultPort/* = "6363"*/)
@@ -24,18 +24,18 @@
const time::seconds& timeout)
{
NFD_LOG_DEBUG("Creating unicast " << endpoint);
-
+
shared_ptr<UdpChannel> channel = findChannel(endpoint);
if (static_cast<bool>(channel))
return channel;
-
- //checking if the endpoint is already in use for multicast face
+
+ //checking if the endpoint is already in use for multicast face
shared_ptr<MulticastUdpFace> multicast = findMulticastFace(endpoint);
if (static_cast<bool>(multicast))
throw Error("Cannot create the requested UDP unicast channel, local "
"endpoint is already allocated for a UDP multicast face");
-
+
if (endpoint.address().is_multicast()) {
throw Error("This method is only for unicast channel. The provided "
"endpoint is multicast. Use createMulticastFace to "
@@ -72,7 +72,7 @@
"endpoint is already allocated for a UDP multicast face "
"on a different multicast group");
}
-
+
//checking if the local endpoint is already in use for an unicast channel
shared_ptr<UdpChannel> unicast = findChannel(localEndpoint);
if (static_cast<bool>(unicast)) {
@@ -83,7 +83,7 @@
if (localEndpoint.address().is_v6() || multicastEndpoint.address().is_v6()) {
throw Error("IPv6 multicast is not supported yet. Please provide an IPv4 address");
}
-
+
if (localEndpoint.port() != multicastEndpoint.port()) {
throw Error("Cannot create the requested UDP multicast face, "
"both endpoints should have the same port number. ");
@@ -96,7 +96,7 @@
shared_ptr<ip::udp::socket> clientSocket =
make_shared<ip::udp::socket>(boost::ref(getGlobalIoService()));
-
+
clientSocket->open(multicastEndpoint.protocol());
clientSocket->set_option(ip::udp::socket::reuse_address(true));
@@ -118,7 +118,7 @@
clientSocket->set_option(ip::multicast::enable_loopback(false));
- multicastFace = make_shared<MulticastUdpFace>(boost::cref(clientSocket));
+ multicastFace = make_shared<MulticastUdpFace>(boost::cref(clientSocket), localEndpoint);
multicastFace->onFail += bind(&UdpFactory::afterFaceFailed, this, localEndpoint);
m_multicastFaces[localEndpoint] = multicastFace;
@@ -131,7 +131,7 @@
const std::string& multicastIp,
const std::string& multicastPort)
{
-
+
return createMulticastFace(UdpResolver::syncResolve(localIp,
multicastPort),
UdpResolver::syncResolve(multicastIp,
@@ -148,7 +148,7 @@
addressSelector = resolver::Ipv4Address();
else if (uri.getScheme() == "udp6")
addressSelector = resolver::Ipv6Address();
-
+
UdpResolver::asyncResolve(uri.getHost(),
uri.getPort().empty() ? m_defaultPort : uri.getPort(),
bind(&UdpFactory::continueCreateFaceAfterResolve, this, _1,
@@ -167,9 +167,9 @@
onConnectFailed("The provided address is multicast. Please use createMulticastFace method");
return;
}
-
+
// very simple logic for now
-
+
for (ChannelMap::iterator channel = m_channels.begin();
channel != m_channels.end();
++channel)
diff --git a/daemon/face/unix-stream-face.cpp b/daemon/face/unix-stream-face.cpp
index 2753f57..1343729 100644
--- a/daemon/face/unix-stream-face.cpp
+++ b/daemon/face/unix-stream-face.cpp
@@ -15,8 +15,13 @@
UnixStreamFace::protocol, LocalFace,
"UnixStreamFace");
+BOOST_STATIC_ASSERT((boost::is_same<UnixStreamFace::protocol::socket::native_handle_type,
+ int>::value));
+
UnixStreamFace::UnixStreamFace(const shared_ptr<UnixStreamFace::protocol::socket>& socket)
- : StreamFace<protocol, LocalFace>(FaceUri(socket->local_endpoint()), socket, true)
+ : StreamFace<protocol, LocalFace>(FaceUri::fromFd(socket->native_handle()),
+ FaceUri(socket->local_endpoint()),
+ socket, true)
{
}
diff --git a/daemon/mgmt/internal-face.cpp b/daemon/mgmt/internal-face.cpp
index a5bcf5a..e04afaf 100644
--- a/daemon/mgmt/internal-face.cpp
+++ b/daemon/mgmt/internal-face.cpp
@@ -13,7 +13,7 @@
NFD_LOG_INIT("InternalFace");
InternalFace::InternalFace()
- : Face(FaceUri("internal://"), true)
+ : Face(FaceUri("internal://"), FaceUri("internal://"), true)
{
}
diff --git a/tests/face/dummy-face.hpp b/tests/face/dummy-face.hpp
index 4e4bb57..9c7252c 100644
--- a/tests/face/dummy-face.hpp
+++ b/tests/face/dummy-face.hpp
@@ -21,7 +21,7 @@
{
public:
DummyFaceImpl()
- : FaceBase(FaceUri("dummy://"))
+ : FaceBase(FaceUri("dummy://"), FaceUri("dummy://"))
{
}
diff --git a/tests/face/ethernet.cpp b/tests/face/ethernet.cpp
index 12eef0f..1224ee0 100644
--- a/tests/face/ethernet.cpp
+++ b/tests/face/ethernet.cpp
@@ -99,9 +99,10 @@
BOOST_CHECK(!face->isOnDemand());
BOOST_CHECK_EQUAL(face->isLocal(), false);
- BOOST_CHECK_EQUAL(face->getUri().toString(),
- "ether://" + m_interfaces.front()->name + "/" +
- ethernet::getDefaultMulticastAddress().toString(':'));
+ BOOST_CHECK_EQUAL(face->getRemoteUri().toString(),
+ "ether://" + ethernet::getDefaultMulticastAddress().toString(':'));
+ BOOST_CHECK_EQUAL(face->getLocalUri().toString(),
+ "dev://" + m_interfaces.front()->name);
Interest interest1("ndn:/TpnzGvW9R");
Data data1 ("ndn:/KfczhUqVix");
diff --git a/tests/face/tcp.cpp b/tests/face/tcp.cpp
index 6fe74e4..b98107e 100644
--- a/tests/face/tcp.cpp
+++ b/tests/face/tcp.cpp
@@ -38,16 +38,16 @@
void
channel1_onFaceCreated(const shared_ptr<Face>& newFace)
{
- BOOST_CHECK(!static_cast<bool>(m_face1));
- m_face1 = newFace;
- m_face1->onReceiveInterest +=
+ BOOST_CHECK(!static_cast<bool>(face1));
+ face1 = newFace;
+ face1->onReceiveInterest +=
bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
- m_face1->onReceiveData +=
+ face1->onReceiveData +=
bind(&EndToEndFixture::face1_onReceiveData, this, _1);
- m_face1->onFail +=
+ face1->onFail +=
bind(&EndToEndFixture::face1_onFail, this);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
@@ -55,45 +55,45 @@
{
BOOST_CHECK_MESSAGE(false, reason);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face1_onReceiveInterest(const Interest& interest)
{
- m_face1_receivedInterests.push_back(interest);
+ face1_receivedInterests.push_back(interest);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face1_onReceiveData(const Data& data)
{
- m_face1_receivedDatas.push_back(data);
+ face1_receivedDatas.push_back(data);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face1_onFail()
{
- m_face1.reset();
- m_limitedIo.afterOp();
+ face1.reset();
+ limitedIo.afterOp();
}
void
channel2_onFaceCreated(const shared_ptr<Face>& newFace)
{
- BOOST_CHECK(!static_cast<bool>(m_face2));
- m_face2 = newFace;
- m_face2->onReceiveInterest +=
+ BOOST_CHECK(!static_cast<bool>(face2));
+ face2 = newFace;
+ face2->onReceiveInterest +=
bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
- m_face2->onReceiveData +=
+ face2->onReceiveData +=
bind(&EndToEndFixture::face2_onReceiveData, this, _1);
- m_face2->onFail +=
+ face2->onFail +=
bind(&EndToEndFixture::face2_onFail, this);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
@@ -101,37 +101,37 @@
{
BOOST_CHECK_MESSAGE(false, reason);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face2_onReceiveInterest(const Interest& interest)
{
- m_face2_receivedInterests.push_back(interest);
+ face2_receivedInterests.push_back(interest);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face2_onReceiveData(const Data& data)
{
- m_face2_receivedDatas.push_back(data);
+ face2_receivedDatas.push_back(data);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face2_onFail()
{
- m_face2.reset();
- m_limitedIo.afterOp();
+ face2.reset();
+ limitedIo.afterOp();
}
void
channel_onFaceCreated(const shared_ptr<Face>& newFace)
{
- m_faces.push_back(newFace);
- m_limitedIo.afterOp();
+ faces.push_back(newFace);
+ limitedIo.afterOp();
}
void
@@ -139,26 +139,26 @@
{
BOOST_CHECK_MESSAGE(false, reason);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
checkFaceList(size_t shouldBe)
{
- BOOST_CHECK_EQUAL(m_faces.size(), shouldBe);
+ BOOST_CHECK_EQUAL(faces.size(), shouldBe);
}
public:
- LimitedIo m_limitedIo;
+ LimitedIo limitedIo;
- shared_ptr<Face> m_face1;
- std::vector<Interest> m_face1_receivedInterests;
- std::vector<Data> m_face1_receivedDatas;
- shared_ptr<Face> m_face2;
- std::vector<Interest> m_face2_receivedInterests;
- std::vector<Data> m_face2_receivedDatas;
+ shared_ptr<Face> face1;
+ std::vector<Interest> face1_receivedInterests;
+ std::vector<Data> face1_receivedDatas;
+ shared_ptr<Face> face2;
+ std::vector<Interest> face2_receivedInterests;
+ std::vector<Data> face2_receivedDatas;
- std::list< shared_ptr<Face> > m_faces;
+ std::list< shared_ptr<Face> > faces;
};
@@ -180,23 +180,24 @@
bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
"TcpChannel error: cannot connect or cannot accept connection");
- BOOST_REQUIRE(static_cast<bool>(m_face1));
- BOOST_REQUIRE(static_cast<bool>(m_face2));
+ BOOST_REQUIRE(static_cast<bool>(face1));
+ BOOST_REQUIRE(static_cast<bool>(face2));
- BOOST_CHECK(m_face1->isOnDemand());
- BOOST_CHECK(!m_face2->isOnDemand());
+ BOOST_CHECK(face1->isOnDemand());
+ BOOST_CHECK(!face2->isOnDemand());
- BOOST_CHECK_EQUAL(m_face2->getUri().toString(), "tcp4://127.0.0.1:20070");
- // face1 has an unknown URI, since the source port is automatically chosen by OS
+ BOOST_CHECK_EQUAL(face2->getRemoteUri().toString(), "tcp4://127.0.0.1:20070");
+ BOOST_CHECK_EQUAL(face1->getLocalUri().toString(), "tcp4://127.0.0.1:20070");
+ // face1 has an unknown remoteUri, since the source port is automatically chosen by OS
- BOOST_CHECK_EQUAL(m_face1->isLocal(), true);
- BOOST_CHECK_EQUAL(m_face2->isLocal(), true);
+ BOOST_CHECK_EQUAL(face1->isLocal(), true);
+ BOOST_CHECK_EQUAL(face2->isLocal(), true);
- BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(m_face1)), true);
- BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(m_face2)), true);
+ BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(face1)), true);
+ BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(face2)), true);
// integrated tests needs to check that TcpFace for non-loopback fails these tests...
@@ -214,36 +215,36 @@
data1.setSignature(fakeSignature);
data2.setSignature(fakeSignature);
- m_face1->sendInterest(interest1);
- m_face1->sendInterest(interest1);
- m_face1->sendInterest(interest1);
- m_face1->sendData (data1 );
- m_face2->sendInterest(interest2);
- m_face2->sendData (data2 );
- m_face2->sendData (data2 );
- m_face2->sendData (data2 );
+ face1->sendInterest(interest1);
+ face1->sendInterest(interest1);
+ face1->sendInterest(interest1);
+ face1->sendData (data1 );
+ face2->sendInterest(interest2);
+ face2->sendData (data2 );
+ face2->sendData (data2 );
+ face2->sendData (data2 );
- BOOST_CHECK_MESSAGE(m_limitedIo.run(8, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(8, time::seconds(10)) == LimitedIo::EXCEED_OPS,
"TcpChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
- BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 3);
- BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 3);
- BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 3);
+ BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 3);
+ BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1);
- BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
- BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
+ BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2.getName());
+ BOOST_CHECK_EQUAL(face1_receivedDatas [0].getName(), data2.getName());
+ BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1.getName());
+ BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1.getName());
- const FaceCounters& counters1 = m_face1->getCounters();
+ const FaceCounters& counters1 = face1->getCounters();
BOOST_CHECK_EQUAL(counters1.getInInterest() , 1);
BOOST_CHECK_EQUAL(counters1.getInData() , 3);
BOOST_CHECK_EQUAL(counters1.getOutInterest(), 3);
BOOST_CHECK_EQUAL(counters1.getOutData() , 1);
- const FaceCounters& counters2 = m_face2->getCounters();
+ const FaceCounters& counters2 = face2->getCounters();
BOOST_CHECK_EQUAL(counters2.getInInterest() , 3);
BOOST_CHECK_EQUAL(counters2.getInData() , 1);
BOOST_CHECK_EQUAL(counters2.getOutInterest(), 1);
@@ -264,20 +265,21 @@
bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
"TcpChannel error: cannot connect or cannot accept connection");
- BOOST_REQUIRE(static_cast<bool>(m_face1));
- BOOST_REQUIRE(static_cast<bool>(m_face2));
+ BOOST_REQUIRE(static_cast<bool>(face1));
+ BOOST_REQUIRE(static_cast<bool>(face2));
- BOOST_CHECK_EQUAL(m_face2->getUri().toString(), "tcp6://[::1]:20070");
- // face1 has an unknown URI, since the source port is automatically chosen by OS
+ BOOST_CHECK_EQUAL(face2->getRemoteUri().toString(), "tcp6://[::1]:20070");
+ BOOST_CHECK_EQUAL(face1->getLocalUri().toString(), "tcp6://[::1]:20070");
+ // face1 has an unknown remoteUri, since the source port is automatically chosen by OS
- BOOST_CHECK_EQUAL(m_face1->isLocal(), true);
- BOOST_CHECK_EQUAL(m_face2->isLocal(), true);
+ BOOST_CHECK_EQUAL(face1->isLocal(), true);
+ BOOST_CHECK_EQUAL(face2->isLocal(), true);
- BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(m_face1)), true);
- BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(m_face2)), true);
+ BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(face1)), true);
+ BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(face2)), true);
// integrated tests needs to check that TcpFace for non-loopback fails these tests...
@@ -295,24 +297,24 @@
data1.setSignature(fakeSignature);
data2.setSignature(fakeSignature);
- m_face1->sendInterest(interest1);
- m_face1->sendData (data1 );
- m_face2->sendInterest(interest2);
- m_face2->sendData (data2 );
+ face1->sendInterest(interest1);
+ face1->sendData (data1 );
+ face2->sendInterest(interest2);
+ face2->sendData (data2 );
- BOOST_CHECK_MESSAGE(m_limitedIo.run(4, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(4, time::seconds(10)) == LimitedIo::EXCEED_OPS,
"TcpChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
- BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
- BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
- BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 1);
+ BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 1);
+ BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1);
- BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
- BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
+ BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2.getName());
+ BOOST_CHECK_EQUAL(face1_receivedDatas [0].getName(), data2.getName());
+ BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1.getName());
+ BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1.getName());
}
BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture)
@@ -330,11 +332,11 @@
bind(&EndToEndFixture::channel_onConnectFailed, this, _1),
time::seconds(4)); // very short timeout
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
"TcpChannel error: cannot connect or cannot accept connection");
- BOOST_CHECK_EQUAL(m_faces.size(), 2);
+ BOOST_CHECK_EQUAL(faces.size(), 2);
shared_ptr<TcpChannel> channel3 = factory.createChannel("127.0.0.1", "20072");
channel3->connect("127.0.0.1", "20070",
@@ -359,11 +361,11 @@
scheduler::schedule(time::milliseconds(500),
bind(&EndToEndFixture::checkFaceList, this, 4));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(4,// 2 connects and 2 accepts
+ BOOST_CHECK_MESSAGE(limitedIo.run(4,// 2 connects and 2 accepts
time::seconds(10)) == LimitedIo::EXCEED_OPS,
"TcpChannel error: cannot connect or cannot accept multiple connections");
- BOOST_CHECK_EQUAL(m_faces.size(), 6);
+ BOOST_CHECK_EQUAL(faces.size(), 6);
}
@@ -382,24 +384,24 @@
bind(&EndToEndFixture::channel2_onConnectFailed, this, _1),
time::seconds(4)); // very short timeout
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
"TcpChannel error: cannot connect or cannot accept connection");
BOOST_CHECK_EQUAL(channel1->size(), 1);
BOOST_CHECK_EQUAL(channel2->size(), 1);
- BOOST_REQUIRE(static_cast<bool>(m_face1));
- BOOST_CHECK(static_cast<bool>(m_face2));
+ BOOST_REQUIRE(static_cast<bool>(face1));
+ BOOST_CHECK(static_cast<bool>(face2));
// Face::close must be invoked during io run to be counted as an op
- scheduler::schedule(time::milliseconds(100), bind(&Face::close, m_face1));
+ scheduler::schedule(time::milliseconds(100), bind(&Face::close, face1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
"FaceClosing error: cannot properly close faces");
// both faces should get closed
- BOOST_CHECK(!static_cast<bool>(m_face1));
- BOOST_CHECK(!static_cast<bool>(m_face2));
+ BOOST_CHECK(!static_cast<bool>(face1));
+ BOOST_CHECK(!static_cast<bool>(face2));
BOOST_CHECK_EQUAL(channel1->size(), 0);
BOOST_CHECK_EQUAL(channel2->size(), 0);
diff --git a/tests/face/udp.cpp b/tests/face/udp.cpp
index ea9d1cc..157602d 100644
--- a/tests/face/udp.cpp
+++ b/tests/face/udp.cpp
@@ -5,8 +5,6 @@
*/
#include "face/udp-factory.hpp"
-#include "core/face-uri.hpp"
-#include <ndn-cpp-dev/security/key-chain.hpp>
#include "tests/test-common.hpp"
#include "tests/core/limited-io.hpp"
@@ -165,25 +163,25 @@
void
channel1_onFaceCreated(const shared_ptr<Face>& newFace)
{
- BOOST_CHECK(!static_cast<bool>(m_face1));
+ BOOST_CHECK(!static_cast<bool>(face1));
channel1_onFaceCreatedNoCheck(newFace);
}
-
+
void
channel1_onFaceCreatedNoCheck(const shared_ptr<Face>& newFace)
{
- m_face1 = newFace;
- m_face1->onReceiveInterest +=
+ face1 = newFace;
+ face1->onReceiveInterest +=
bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
- m_face1->onReceiveData +=
+ face1->onReceiveData +=
bind(&EndToEndFixture::face1_onReceiveData, this, _1);
- m_face1->onFail +=
+ face1->onFail +=
bind(&EndToEndFixture::face1_onFail, this);
BOOST_CHECK_MESSAGE(true, "channel 1 face created");
- m_faces.push_back(m_face1);
+ faces.push_back(face1);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
@@ -191,48 +189,48 @@
{
BOOST_CHECK_MESSAGE(false, reason);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face1_onReceiveInterest(const Interest& interest)
{
- m_face1_receivedInterests.push_back(interest);
+ face1_receivedInterests.push_back(interest);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face1_onReceiveData(const Data& data)
{
- m_face1_receivedDatas.push_back(data);
+ face1_receivedDatas.push_back(data);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face1_onFail()
{
- m_face1.reset();
- m_limitedIo.afterOp();
+ face1.reset();
+ limitedIo.afterOp();
}
void
channel2_onFaceCreated(const shared_ptr<Face>& newFace)
{
- BOOST_CHECK(!static_cast<bool>(m_face2));
- m_face2 = newFace;
- m_face2->onReceiveInterest +=
+ BOOST_CHECK(!static_cast<bool>(face2));
+ face2 = newFace;
+ face2->onReceiveInterest +=
bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
- m_face2->onReceiveData +=
+ face2->onReceiveData +=
bind(&EndToEndFixture::face2_onReceiveData, this, _1);
- m_face2->onFail +=
+ face2->onFail +=
bind(&EndToEndFixture::face2_onFail, this);
- m_faces.push_back(m_face2);
+ faces.push_back(face2);
BOOST_CHECK_MESSAGE(true, "channel 2 face created");
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
@@ -240,47 +238,47 @@
{
BOOST_CHECK_MESSAGE(false, reason);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face2_onReceiveInterest(const Interest& interest)
{
- m_face2_receivedInterests.push_back(interest);
+ face2_receivedInterests.push_back(interest);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face2_onReceiveData(const Data& data)
{
- m_face2_receivedDatas.push_back(data);
+ face2_receivedDatas.push_back(data);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face2_onFail()
{
- m_face2.reset();
- m_limitedIo.afterOp();
+ face2.reset();
+ limitedIo.afterOp();
}
void
channel3_onFaceCreated(const shared_ptr<Face>& newFace)
{
- BOOST_CHECK(!static_cast<bool>(m_face1));
- m_face3 = newFace;
- m_faces.push_back(newFace);
+ BOOST_CHECK(!static_cast<bool>(face1));
+ face3 = newFace;
+ faces.push_back(newFace);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
channel_onFaceCreated(const shared_ptr<Face>& newFace)
{
- m_faces.push_back(newFace);
- m_limitedIo.afterOp();
+ faces.push_back(newFace);
+ limitedIo.afterOp();
}
void
@@ -288,34 +286,34 @@
{
BOOST_CHECK_MESSAGE(false, reason);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
channel_onConnectFailedOk(const std::string& reason)
{
//it's ok, it was supposed to fail
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
checkFaceList(size_t shouldBe)
{
- BOOST_CHECK_EQUAL(m_faces.size(), shouldBe);
+ BOOST_CHECK_EQUAL(faces.size(), shouldBe);
}
public:
- LimitedIo m_limitedIo;
+ LimitedIo limitedIo;
- shared_ptr<Face> m_face1;
- std::vector<Interest> m_face1_receivedInterests;
- std::vector<Data> m_face1_receivedDatas;
- shared_ptr<Face> m_face2;
- std::vector<Interest> m_face2_receivedInterests;
- std::vector<Data> m_face2_receivedDatas;
- shared_ptr<Face> m_face3;
+ shared_ptr<Face> face1;
+ std::vector<Interest> face1_receivedInterests;
+ std::vector<Data> face1_receivedDatas;
+ shared_ptr<Face> face2;
+ std::vector<Interest> face2_receivedInterests;
+ std::vector<Data> face2_receivedDatas;
+ shared_ptr<Face> face3;
- std::list< shared_ptr<Face> > m_faces;
+ std::list< shared_ptr<Face> > faces;
};
@@ -330,13 +328,14 @@
bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot connect or cannot accept connection");
- BOOST_REQUIRE(static_cast<bool>(m_face2));
- BOOST_CHECK_EQUAL(m_face2->getUri().toString(), "udp4://127.0.0.1:20070");
- BOOST_CHECK_EQUAL(m_face2->isLocal(), false);
- // m_face1 is not created yet
+ BOOST_REQUIRE(static_cast<bool>(face2));
+ BOOST_CHECK_EQUAL(face2->getRemoteUri().toString(), "udp4://127.0.0.1:20070");
+ BOOST_CHECK_EQUAL(face2->getLocalUri().toString(), "udp4://127.0.0.1:20071");
+ BOOST_CHECK_EQUAL(face2->isLocal(), false);
+ // face1 is not created yet
shared_ptr<UdpChannel> channel1 = factory.createChannel("127.0.0.1", "20070");
channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
@@ -363,61 +362,62 @@
data2.setSignature(fakeSignature);
data3.setSignature(fakeSignature);
- m_face2->sendInterest(interest2);
- m_face2->sendData (data2 );
- m_face2->sendData (data2 );
- m_face2->sendData (data2 );
+ face2->sendInterest(interest2);
+ face2->sendData (data2 );
+ face2->sendData (data2 );
+ face2->sendData (data2 );
- BOOST_CHECK_MESSAGE(m_limitedIo.run(5,//4 send + 1 listen return
+ BOOST_CHECK_MESSAGE(limitedIo.run(5,//4 send + 1 listen return
time::seconds(4)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE(static_cast<bool>(m_face1));
- BOOST_CHECK_EQUAL(m_face1->getUri().toString(), "udp4://127.0.0.1:20071");
- BOOST_CHECK_EQUAL(m_face1->isLocal(), false);
+ BOOST_REQUIRE(static_cast<bool>(face1));
+ BOOST_CHECK_EQUAL(face1->getRemoteUri().toString(), "udp4://127.0.0.1:20071");
+ BOOST_CHECK_EQUAL(face1->getLocalUri().toString(), "udp4://127.0.0.1:20070");
+ BOOST_CHECK_EQUAL(face1->isLocal(), false);
- m_face1->sendInterest(interest1);
- m_face1->sendInterest(interest1);
- m_face1->sendInterest(interest1);
- m_face1->sendData (data1 );
+ face1->sendInterest(interest1);
+ face1->sendInterest(interest1);
+ face1->sendInterest(interest1);
+ face1->sendData (data1 );
- BOOST_CHECK_MESSAGE(m_limitedIo.run(4, time::seconds(4)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(4, time::seconds(4)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
- BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 3);
- BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 3);
- BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 3);
+ BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 3);
+ BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1);
- BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
- BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
+ BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2.getName());
+ BOOST_CHECK_EQUAL(face1_receivedDatas [0].getName(), data2.getName());
+ BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1.getName());
+ BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1.getName());
//checking if the connection accepting mechanism works properly.
- m_face2->sendData (data3 );
- m_face2->sendInterest(interest3);
+ face2->sendData (data3 );
+ face2->sendInterest(interest3);
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 2);
- BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 4);
+ BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 2);
+ BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 4);
- BOOST_CHECK_EQUAL(m_face1_receivedInterests[1].getName(), interest3.getName());
- BOOST_CHECK_EQUAL(m_face1_receivedDatas [3].getName(), data3.getName());
+ BOOST_CHECK_EQUAL(face1_receivedInterests[1].getName(), interest3.getName());
+ BOOST_CHECK_EQUAL(face1_receivedDatas [3].getName(), data3.getName());
- const FaceCounters& counters1 = m_face1->getCounters();
+ const FaceCounters& counters1 = face1->getCounters();
BOOST_CHECK_EQUAL(counters1.getInInterest() , 2);
BOOST_CHECK_EQUAL(counters1.getInData() , 4);
BOOST_CHECK_EQUAL(counters1.getOutInterest(), 3);
BOOST_CHECK_EQUAL(counters1.getOutData() , 1);
- const FaceCounters& counters2 = m_face2->getCounters();
+ const FaceCounters& counters2 = face2->getCounters();
BOOST_CHECK_EQUAL(counters2.getInInterest() , 3);
BOOST_CHECK_EQUAL(counters2.getInData() , 1);
BOOST_CHECK_EQUAL(counters2.getOutInterest(), 2);
@@ -435,13 +435,14 @@
bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot connect or cannot accept connection");
- BOOST_REQUIRE(static_cast<bool>(m_face2));
- BOOST_CHECK_EQUAL(m_face2->getUri().toString(), "udp6://[::1]:20070");
- BOOST_CHECK_EQUAL(m_face2->isLocal(), false);
- // m_face1 is not created yet
+ BOOST_REQUIRE(static_cast<bool>(face2));
+ BOOST_CHECK_EQUAL(face2->getRemoteUri().toString(), "udp6://[::1]:20070");
+ BOOST_CHECK_EQUAL(face2->getLocalUri().toString(), "udp6://[::1]:20071");
+ BOOST_CHECK_EQUAL(face2->isLocal(), false);
+ // face1 is not created yet
shared_ptr<UdpChannel> channel1 = factory.createChannel("::1", "20070");
channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
@@ -468,49 +469,50 @@
data2.setSignature(fakeSignature);
data3.setSignature(fakeSignature);
- m_face2->sendInterest(interest2);
- m_face2->sendData (data2 );
+ face2->sendInterest(interest2);
+ face2->sendData (data2 );
- BOOST_CHECK_MESSAGE(m_limitedIo.run(3,//2 send + 1 listen return
+ BOOST_CHECK_MESSAGE(limitedIo.run(3,//2 send + 1 listen return
time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE(static_cast<bool>(m_face1));
- BOOST_CHECK_EQUAL(m_face1->getUri().toString(), "udp6://[::1]:20071");
- BOOST_CHECK_EQUAL(m_face1->isLocal(), false);
+ BOOST_REQUIRE(static_cast<bool>(face1));
+ BOOST_CHECK_EQUAL(face1->getRemoteUri().toString(), "udp6://[::1]:20071");
+ BOOST_CHECK_EQUAL(face1->getLocalUri().toString(), "udp6://[::1]:20070");
+ BOOST_CHECK_EQUAL(face1->isLocal(), false);
- m_face1->sendInterest(interest1);
- m_face1->sendData (data1 );
+ face1->sendInterest(interest1);
+ face1->sendData (data1 );
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
- BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
- BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
- BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 1);
+ BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 1);
+ BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1);
- BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
- BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
+ BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2.getName());
+ BOOST_CHECK_EQUAL(face1_receivedDatas [0].getName(), data2.getName());
+ BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1.getName());
+ BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1.getName());
//checking if the connection accepting mechanism works properly.
- m_face2->sendData (data3 );
- m_face2->sendInterest(interest3);
+ face2->sendData (data3 );
+ face2->sendInterest(interest3);
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 2);
- BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 2);
+ BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 2);
+ BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 2);
- BOOST_CHECK_EQUAL(m_face1_receivedInterests[1].getName(), interest3.getName());
- BOOST_CHECK_EQUAL(m_face1_receivedDatas [1].getName(), data3.getName());
+ BOOST_CHECK_EQUAL(face1_receivedInterests[1].getName(), interest3.getName());
+ BOOST_CHECK_EQUAL(face1_receivedDatas [1].getName(), data3.getName());
}
BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture)
@@ -531,10 +533,10 @@
bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot connect or cannot accept connection");
- BOOST_CHECK_EQUAL(m_faces.size(), 1);
+ BOOST_CHECK_EQUAL(faces.size(), 1);
shared_ptr<UdpChannel> channel3 = factory.createChannel("127.0.0.1", "20072");
channel3->connect("127.0.0.1", "20070",
@@ -555,25 +557,25 @@
scheduler::schedule(time::milliseconds(400), bind(&EndToEndFixture::checkFaceList, this, 2));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2,// 2 connects
+ BOOST_CHECK_MESSAGE(limitedIo.run(2,// 2 connects
time::seconds(4)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot connect or cannot accept multiple connections");
- BOOST_CHECK_EQUAL(m_faces.size(), 3);
+ BOOST_CHECK_EQUAL(faces.size(), 3);
- m_face2->sendInterest(interest1);
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ face2->sendInterest(interest1);
+ BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
- BOOST_CHECK_EQUAL(m_faces.size(), 4);
+ BOOST_CHECK_EQUAL(faces.size(), 4);
- m_face3->sendInterest(interest2);
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ face3->sendInterest(interest2);
+ BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
- //channel1 should have created 2 faces, one when m_face2 sent an interest, one when m_face3 sent an interest
- BOOST_CHECK_EQUAL(m_faces.size(), 5);
+ //channel1 should have created 2 faces, one when face2 sent an interest, one when face3 sent an interest
+ BOOST_CHECK_EQUAL(faces.size(), 5);
BOOST_CHECK_THROW(channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel_onConnectFailedOk, this, _1)),
UdpChannel::Error);
@@ -590,7 +592,7 @@
// bind(&EndToEndFixture::abortTestCase, this,
// "UdpChannel error: cannot connect or cannot accept connection"));
//
-// m_limitedIoRemaining = 1;
+// limitedIoRemaining = 1;
//
// shared_ptr<UdpChannel> channel1 = factory.createChannel("::1", "20070");
// shared_ptr<UdpChannel> channel2 = factory.createChannel("::1", "20071");
@@ -605,7 +607,7 @@
// g_io.reset();
// scheduler.cancelEvent(abortEvent);
//
-// BOOST_REQUIRE(static_cast<bool>(m_face2));
+// BOOST_REQUIRE(static_cast<bool>(face2));
//
// abortEvent =
// scheduler.scheduleEvent(time::seconds(1),
@@ -630,57 +632,57 @@
// data2.setSignature(fakeSignature);
// data3.setSignature(fakeSignature);
//
-// m_face2->sendInterest(interest2);
-// m_face2->sendData (data2 );
+// face2->sendInterest(interest2);
+// face2->sendData (data2 );
//
-// m_limitedIoRemaining = 3; //2 send + 1 listen return
+// limitedIoRemaining = 3; //2 send + 1 listen return
// g_io.run();
// g_io.reset();
// scheduler.cancelEvent(abortEvent);
//
-// BOOST_REQUIRE(static_cast<bool>(m_face1));
+// BOOST_REQUIRE(static_cast<bool>(face1));
//
-// m_face1->sendInterest(interest1);
-// m_face1->sendData (data1 );
+// face1->sendInterest(interest1);
+// face1->sendData (data1 );
//
// abortEvent =
// scheduler.scheduleEvent(time::seconds(1),
// bind(&EndToEndFixture::abortTestCase, this,
// "UdpChannel error: cannot send or receive Interest/Data packets"));
-// m_limitedIoRemaining = 2;
+// limitedIoRemaining = 2;
// g_io.run();
// g_io.reset();
// scheduler.cancelEvent(abortEvent);
//
-// BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
-// BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
-// BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
-// BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
+// BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
+// BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 1);
+// BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 1);
+// BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1);
//
-// BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
-// BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
-// BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
-// BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
+// BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2.getName());
+// BOOST_CHECK_EQUAL(face1_receivedDatas [0].getName(), data2.getName());
+// BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1.getName());
+// BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1.getName());
//
// //checking if the connection accepting mechanism works properly.
//
-// m_face2->sendData (data3 );
-// m_face2->sendInterest(interest3);
+// face2->sendData (data3 );
+// face2->sendInterest(interest3);
//
// abortEvent =
// scheduler.scheduleEvent(time::seconds(1),
// bind(&EndToEndFixture::abortTestCase, this,
// "UdpChannel error: cannot send or receive Interest/Data packets"));
-// m_limitedIoRemaining = 2;
+// limitedIoRemaining = 2;
// g_io.run();
// g_io.reset();
// scheduler.cancelEvent(abortEvent);
//
-// BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 2);
-// BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 2);
+// BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 2);
+// BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 2);
//
-// BOOST_CHECK_EQUAL(m_face1_receivedInterests[1].getName(), interest3.getName());
-// BOOST_CHECK_EQUAL(m_face1_receivedDatas [1].getName(), data3.getName());
+// BOOST_CHECK_EQUAL(face1_receivedInterests[1].getName(), interest3.getName());
+// BOOST_CHECK_EQUAL(face1_receivedDatas [1].getName(), data3.getName());
//
//}
@@ -710,12 +712,12 @@
// bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
// bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
//
-// m_limitedIoRemaining = 1;
+// limitedIoRemaining = 1;
// g_io.run();
// g_io.reset();
// scheduler.cancelEvent(abortEvent);
//
-// BOOST_CHECK_EQUAL(m_faces.size(), 1);
+// BOOST_CHECK_EQUAL(faces.size(), 1);
//
// shared_ptr<UdpChannel> channel3 = factory.createChannel("::1", "20072");
// channel3->connect("::1", "20070",
@@ -735,7 +737,7 @@
// static_cast<UdpChannel::ConnectFailedCallback>(bind(&EndToEndFixture::
// channel_onConnectFailed, this, _1))));
//
-// m_limitedIoRemaining = 2; // 2 connects
+// limitedIoRemaining = 2; // 2 connects
// abortEvent =
// scheduler.scheduleEvent(time::seconds(4),
// bind(&EndToEndFixture::abortTestCase, this,
@@ -747,33 +749,33 @@
// g_io.run();
// g_io.reset();
//
-// BOOST_CHECK_EQUAL(m_faces.size(), 3);
+// BOOST_CHECK_EQUAL(faces.size(), 3);
//
//
-// m_face2->sendInterest(interest1);
+// face2->sendInterest(interest1);
// abortEvent =
// scheduler.scheduleEvent(time::seconds(1),
// bind(&EndToEndFixture::abortTestCase, this,
// "UdpChannel error: cannot send or receive Interest/Data packets"));
-// m_limitedIoRemaining = 1;
+// limitedIoRemaining = 1;
// g_io.run();
// g_io.reset();
// scheduler.cancelEvent(abortEvent);
//
-// BOOST_CHECK_EQUAL(m_faces.size(), 4);
+// BOOST_CHECK_EQUAL(faces.size(), 4);
//
-// m_face3->sendInterest(interest2);
+// face3->sendInterest(interest2);
// abortEvent =
// scheduler.scheduleEvent(time::seconds(1),
// bind(&EndToEndFixture::abortTestCase, this,
// "UdpChannel error: cannot send or receive Interest/Data packets"));
-// m_limitedIoRemaining = 1;
+// limitedIoRemaining = 1;
// g_io.run();
// g_io.reset();
// scheduler.cancelEvent(abortEvent);
//
-// //channel1 should have created 2 faces, one when m_face2 sent an interest, one when m_face3 sent an interest
-// BOOST_CHECK_EQUAL(m_faces.size(), 5);
+// //channel1 should have created 2 faces, one when face2 sent an interest, one when face3 sent an interest
+// BOOST_CHECK_EQUAL(faces.size(), 5);
// BOOST_CHECK_THROW(channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated,
// this,
// _1),
@@ -798,24 +800,24 @@
bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot connect or cannot accept connection");
BOOST_CHECK_EQUAL(channel2->size(), 1);
- BOOST_CHECK(static_cast<bool>(m_face2));
+ BOOST_CHECK(static_cast<bool>(face2));
// Face::close must be invoked during io run to be counted as an op
- scheduler::schedule(time::milliseconds(100), bind(&Face::close, m_face2));
+ scheduler::schedule(time::milliseconds(100), bind(&Face::close, face2));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
"FaceClosing error: cannot properly close faces");
- BOOST_CHECK(!static_cast<bool>(m_face2));
+ BOOST_CHECK(!static_cast<bool>(face2));
BOOST_CHECK_EQUAL(channel2->size(), 0);
}
-
+
BOOST_FIXTURE_TEST_CASE(ClosingIdleFace, EndToEndFixture)
{
Interest interest1("ndn:/TpnzGvW9R");
@@ -834,55 +836,55 @@
channel2->connect("127.0.0.1", "20070",
bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
-
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
+
+ BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot connect or cannot accept connection");
- m_face2->sendInterest(interest1);
- BOOST_CHECK(!m_face2->isOnDemand());
+ face2->sendInterest(interest1);
+ BOOST_CHECK(!face2->isOnDemand());
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2,//1 send + 1 listen return
+ BOOST_CHECK_MESSAGE(limitedIo.run(2,//1 send + 1 listen return
time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
-
- BOOST_CHECK_EQUAL(m_faces.size(), 2);
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(2)) == LimitedIo::EXCEED_TIME,
+
+ BOOST_CHECK_EQUAL(faces.size(), 2);
+ BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(2)) == LimitedIo::EXCEED_TIME,
"Idle face should be still open because has been used recently");
- BOOST_CHECK_EQUAL(m_faces.size(), 2);
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_EQUAL(faces.size(), 2);
+ BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS,
"Closing idle face error: face should be closed by now");
-
+
//the face on listen should be closed now
BOOST_CHECK_EQUAL(channel1->size(), 0);
- //checking that m_face2 has not been closed
+ //checking that face2 has not been closed
BOOST_CHECK_EQUAL(channel2->size(), 1);
- BOOST_REQUIRE(static_cast<bool>(m_face2));
-
- m_face2->sendInterest(interest2);
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2,//1 send + 1 listen return
+ BOOST_REQUIRE(static_cast<bool>(face2));
+
+ face2->sendInterest(interest2);
+ BOOST_CHECK_MESSAGE(limitedIo.run(2,//1 send + 1 listen return
time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
//channel1 should have created a new face by now
BOOST_CHECK_EQUAL(channel1->size(), 1);
BOOST_CHECK_EQUAL(channel2->size(), 1);
- BOOST_REQUIRE(static_cast<bool>(m_face1));
- BOOST_CHECK(m_face1->isOnDemand());
-
+ BOOST_REQUIRE(static_cast<bool>(face1));
+ BOOST_CHECK(face1->isOnDemand());
+
channel1->connect("127.0.0.1", "20071",
bind(&EndToEndFixture::channel1_onFaceCreatedNoCheck, this, _1),
bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1,//1 connect
+ BOOST_CHECK_MESSAGE(limitedIo.run(1,//1 connect
time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot connect");
- BOOST_CHECK(!m_face1->isOnDemand());
-
- //the connect should have set m_face1 as permanent face,
+ BOOST_CHECK(!face1->isOnDemand());
+
+ //the connect should have set face1 as permanent face,
//but it shouln't have created any additional faces
BOOST_CHECK_EQUAL(channel1->size(), 1);
BOOST_CHECK_EQUAL(channel2->size(), 1);
- BOOST_CHECK_MESSAGE(m_limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_TIME,
+ BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_TIME,
"Idle face should be still open because it's permanent now");
//both faces are permanent, nothing should have changed
BOOST_CHECK_EQUAL(channel1->size(), 1);
diff --git a/tests/face/unix-stream.cpp b/tests/face/unix-stream.cpp
index da474f6..2c7c177 100644
--- a/tests/face/unix-stream.cpp
+++ b/tests/face/unix-stream.cpp
@@ -5,7 +5,6 @@
*/
#include "face/unix-stream-factory.hpp"
-#include <ndn-cpp-dev/security/key-chain.hpp>
#include "tests/test-common.hpp"
#include "tests/core/limited-io.hpp"
@@ -44,20 +43,20 @@
{
BOOST_CHECK_MESSAGE(!error, error.message());
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
channel1_onFaceCreated(const shared_ptr<Face>& newFace)
{
- BOOST_CHECK(!static_cast<bool>(m_face1));
- m_face1 = static_pointer_cast<UnixStreamFace>(newFace);
- m_face1->onReceiveInterest +=
+ BOOST_CHECK(!static_cast<bool>(face1));
+ face1 = static_pointer_cast<UnixStreamFace>(newFace);
+ face1->onReceiveInterest +=
bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
- m_face1->onReceiveData +=
+ face1->onReceiveData +=
bind(&EndToEndFixture::face1_onReceiveData, this, _1);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
@@ -65,47 +64,47 @@
{
BOOST_CHECK_MESSAGE(false, reason);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face1_onReceiveInterest(const Interest& interest)
{
- m_face1_receivedInterests.push_back(interest);
+ face1_receivedInterests.push_back(interest);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face1_onReceiveData(const Data& data)
{
- m_face1_receivedDatas.push_back(data);
+ face1_receivedDatas.push_back(data);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face2_onReceiveInterest(const Interest& interest)
{
- m_face2_receivedInterests.push_back(interest);
+ face2_receivedInterests.push_back(interest);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
face2_onReceiveData(const Data& data)
{
- m_face2_receivedDatas.push_back(data);
+ face2_receivedDatas.push_back(data);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
channel_onFaceCreated(const shared_ptr<Face>& newFace)
{
- m_faces.push_back(static_pointer_cast<UnixStreamFace>(newFace));
+ faces.push_back(static_pointer_cast<UnixStreamFace>(newFace));
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
void
@@ -113,20 +112,20 @@
{
BOOST_CHECK_MESSAGE(false, reason);
- m_limitedIo.afterOp();
+ limitedIo.afterOp();
}
protected:
- LimitedIo m_limitedIo;
+ LimitedIo limitedIo;
- shared_ptr<UnixStreamFace> m_face1;
- std::vector<Interest> m_face1_receivedInterests;
- std::vector<Data> m_face1_receivedDatas;
- shared_ptr<UnixStreamFace> m_face2;
- std::vector<Interest> m_face2_receivedInterests;
- std::vector<Data> m_face2_receivedDatas;
+ shared_ptr<UnixStreamFace> face1;
+ std::vector<Interest> face1_receivedInterests;
+ std::vector<Data> face1_receivedDatas;
+ shared_ptr<UnixStreamFace> face2;
+ std::vector<Interest> face2_receivedInterests;
+ std::vector<Data> face2_receivedDatas;
- std::list< shared_ptr<UnixStreamFace> > m_faces;
+ std::list< shared_ptr<UnixStreamFace> > faces;
};
@@ -143,20 +142,22 @@
client->async_connect(stream_protocol::endpoint(CHANNEL_PATH1),
bind(&EndToEndFixture::client_onConnect, this, _1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UnixStreamChannel error: cannot connect or cannot accept connection");
- BOOST_REQUIRE(static_cast<bool>(m_face1));
+ BOOST_REQUIRE(static_cast<bool>(face1));
- std::string face1uri = m_face1->getUri().toString();
- BOOST_CHECK_EQUAL(face1uri.find("unix:///"), 0); // third '/' is the path separator
- BOOST_CHECK_EQUAL(face1uri.rfind(CHANNEL_PATH1),
- face1uri.size() - std::string(CHANNEL_PATH1).size());
+ BOOST_CHECK_EQUAL(face1->getRemoteUri().getScheme(), "fd");
+ BOOST_CHECK_NO_THROW(boost::lexical_cast<int>(face1->getRemoteUri().getHost()));
+ std::string face1localUri = face1->getLocalUri().toString();
+ BOOST_CHECK_EQUAL(face1localUri.find("unix:///"), 0); // third '/' is the path separator
+ BOOST_CHECK_EQUAL(face1localUri.rfind(CHANNEL_PATH1),
+ face1localUri.size() - std::string(CHANNEL_PATH1).size());
- m_face2 = make_shared<UnixStreamFace>(client);
- m_face2->onReceiveInterest +=
+ face2 = make_shared<UnixStreamFace>(client);
+ face2->onReceiveInterest +=
bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
- m_face2->onReceiveData +=
+ face2->onReceiveData +=
bind(&EndToEndFixture::face2_onReceiveData, this, _1);
Interest interest1("ndn:/TpnzGvW9R");
@@ -173,35 +174,35 @@
data1.setSignature(fakeSignature);
data2.setSignature(fakeSignature);
- m_face1->sendInterest(interest1);
- m_face1->sendInterest(interest1);
- m_face1->sendInterest(interest1);
- m_face1->sendData (data1 );
- m_face2->sendInterest(interest2);
- m_face2->sendData (data2 );
- m_face2->sendData (data2 );
- m_face2->sendData (data2 );
+ face1->sendInterest(interest1);
+ face1->sendInterest(interest1);
+ face1->sendInterest(interest1);
+ face1->sendData (data1 );
+ face2->sendInterest(interest2);
+ face2->sendData (data2 );
+ face2->sendData (data2 );
+ face2->sendData (data2 );
- BOOST_CHECK_MESSAGE(m_limitedIo.run(8, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(8, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UnixStreamChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
- BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 3);
- BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 3);
- BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 3);
+ BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 3);
+ BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1);
- BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
- BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
+ BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2.getName());
+ BOOST_CHECK_EQUAL(face1_receivedDatas [0].getName(), data2.getName());
+ BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1.getName());
+ BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1.getName());
- const FaceCounters& counters1 = m_face1->getCounters();
+ const FaceCounters& counters1 = face1->getCounters();
BOOST_CHECK_EQUAL(counters1.getInInterest() , 1);
BOOST_CHECK_EQUAL(counters1.getInData() , 3);
BOOST_CHECK_EQUAL(counters1.getOutInterest(), 3);
BOOST_CHECK_EQUAL(counters1.getOutData() , 1);
- const FaceCounters& counters2 = m_face2->getCounters();
+ const FaceCounters& counters2 = face2->getCounters();
BOOST_CHECK_EQUAL(counters2.getInInterest() , 3);
BOOST_CHECK_EQUAL(counters2.getInData() , 1);
BOOST_CHECK_EQUAL(counters2.getOutInterest(), 1);
@@ -221,36 +222,32 @@
client1->async_connect(stream_protocol::endpoint(CHANNEL_PATH1),
bind(&EndToEndFixture::client_onConnect, this, _1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UnixStreamChannel error: cannot connect or cannot accept connection");
- BOOST_CHECK_EQUAL(m_faces.size(), 1);
+ BOOST_CHECK_EQUAL(faces.size(), 1);
shared_ptr<stream_protocol::socket> client2 =
make_shared<stream_protocol::socket>(boost::ref(g_io));
client2->async_connect(stream_protocol::endpoint(CHANNEL_PATH1),
bind(&EndToEndFixture::client_onConnect, this, _1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UnixStreamChannel error: cannot accept multiple connections");
- BOOST_CHECK_EQUAL(m_faces.size(), 2);
+ BOOST_CHECK_EQUAL(faces.size(), 2);
// now close one of the faces
- m_faces.front()->close();
+ faces.front()->close();
// we should still be able to send/receive with the other one
- m_face1 = m_faces.back();
- m_face1->onReceiveInterest +=
- bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
- m_face1->onReceiveData +=
- bind(&EndToEndFixture::face1_onReceiveData, this, _1);
+ face1 = faces.back();
+ face1->onReceiveInterest += bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
+ face1->onReceiveData += bind(&EndToEndFixture::face1_onReceiveData, this, _1);
- m_face2 = make_shared<UnixStreamFace>(client2);
- m_face2->onReceiveInterest +=
- bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
- m_face2->onReceiveData +=
- bind(&EndToEndFixture::face2_onReceiveData, this, _1);
+ face2 = make_shared<UnixStreamFace>(client2);
+ face2->onReceiveInterest += bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
+ face2->onReceiveData += bind(&EndToEndFixture::face2_onReceiveData, this, _1);
Interest interest1("ndn:/TpnzGvW9R");
Data data1 ("ndn:/KfczhUqVix");
@@ -266,23 +263,23 @@
data1.setSignature(fakeSignature);
data2.setSignature(fakeSignature);
- m_face1->sendInterest(interest1);
- m_face1->sendData (data1 );
- m_face2->sendInterest(interest2);
- m_face2->sendData (data2 );
+ face1->sendInterest(interest1);
+ face1->sendData (data1 );
+ face2->sendInterest(interest2);
+ face2->sendData (data2 );
- BOOST_CHECK_MESSAGE(m_limitedIo.run(4, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(4, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UnixStreamChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
- BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
- BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
- BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 1);
+ BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 1);
+ BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1);
- BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
- BOOST_CHECK_EQUAL(m_face1_receivedDatas [0].getName(), data2.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
- BOOST_CHECK_EQUAL(m_face2_receivedDatas [0].getName(), data1.getName());
+ BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2.getName());
+ BOOST_CHECK_EQUAL(face1_receivedDatas [0].getName(), data2.getName());
+ BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1.getName());
+ BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1.getName());
}
static inline void
@@ -303,15 +300,15 @@
client->async_connect(stream_protocol::endpoint(CHANNEL_PATH1),
bind(&EndToEndFixture::client_onConnect, this, _1));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UnixStreamChannel error: cannot connect or cannot accept connection");
- BOOST_REQUIRE(static_cast<bool>(m_face1));
+ BOOST_REQUIRE(static_cast<bool>(face1));
- m_face2 = make_shared<UnixStreamFace>(client);
- m_face2->onReceiveInterest +=
+ face2 = make_shared<UnixStreamFace>(client);
+ face2->onReceiveInterest +=
bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
- m_face2->onReceiveData +=
+ face2->onReceiveData +=
bind(&EndToEndFixture::face2_onReceiveData, this, _1);
Interest interest1("ndn:/TpnzGvW9R");
@@ -328,44 +325,44 @@
data1.setSignature(fakeSignature);
data2.setSignature(fakeSignature);
- m_face1->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
- m_face1->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID);
+ face1->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
+ face1->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID);
- BOOST_CHECK(m_face1->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
- BOOST_CHECK(m_face1->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+ BOOST_CHECK(face1->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+ BOOST_CHECK(face1->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
- m_face2->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
- m_face2->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID);
+ face2->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
+ face2->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID);
- BOOST_CHECK(m_face2->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
- BOOST_CHECK(m_face2->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+ BOOST_CHECK(face2->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+ BOOST_CHECK(face2->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
////////////////////////////////////////////////////////
interest1.setIncomingFaceId(11);
interest1.setNextHopFaceId(111);
- m_face1->sendInterest(interest1);
+ face1->sendInterest(interest1);
data1.setIncomingFaceId(22);
data1.getLocalControlHeader().setNextHopFaceId(222);
- m_face1->sendData (data1);
+ face1->sendData (data1);
//
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UnixStreamChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
- BOOST_REQUIRE_EQUAL(m_face2_receivedDatas .size(), 1);
+ BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 1);
+ BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1);
// sending allows only IncomingFaceId, receiving allows only NextHopFaceId
- BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getLocalControlHeader().hasIncomingFaceId(), false);
- BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getLocalControlHeader().hasNextHopFaceId(), false);
+ BOOST_CHECK_EQUAL(face2_receivedInterests[0].getLocalControlHeader().hasIncomingFaceId(), false);
+ BOOST_CHECK_EQUAL(face2_receivedInterests[0].getLocalControlHeader().hasNextHopFaceId(), false);
- BOOST_CHECK_EQUAL(m_face2_receivedDatas[0].getLocalControlHeader().hasIncomingFaceId(), false);
- BOOST_CHECK_EQUAL(m_face2_receivedDatas[0].getLocalControlHeader().hasNextHopFaceId(), false);
+ BOOST_CHECK_EQUAL(face2_receivedDatas[0].getLocalControlHeader().hasIncomingFaceId(), false);
+ BOOST_CHECK_EQUAL(face2_receivedDatas[0].getLocalControlHeader().hasNextHopFaceId(), false);
////////////////////////////////////////////////////////
@@ -388,18 +385,18 @@
client->async_send(interestWithHeader, bind(&noOp));
client->async_send(dataWithHeader, bind(&noOp));
- BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
+ BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UnixStreamChannel error: cannot send or receive Interest/Data packets");
- BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
- BOOST_REQUIRE_EQUAL(m_face1_receivedDatas .size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
+ BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 1);
- BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getLocalControlHeader().hasIncomingFaceId(), false);
- BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getLocalControlHeader().hasNextHopFaceId(), true);
- BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getNextHopFaceId(), 111);
+ BOOST_CHECK_EQUAL(face1_receivedInterests[0].getLocalControlHeader().hasIncomingFaceId(), false);
+ BOOST_CHECK_EQUAL(face1_receivedInterests[0].getLocalControlHeader().hasNextHopFaceId(), true);
+ BOOST_CHECK_EQUAL(face1_receivedInterests[0].getNextHopFaceId(), 111);
- BOOST_CHECK_EQUAL(m_face1_receivedDatas[0].getLocalControlHeader().hasIncomingFaceId(), false);
- BOOST_CHECK_EQUAL(m_face1_receivedDatas[0].getLocalControlHeader().hasNextHopFaceId(), false);
+ BOOST_CHECK_EQUAL(face1_receivedDatas[0].getLocalControlHeader().hasIncomingFaceId(), false);
+ BOOST_CHECK_EQUAL(face1_receivedDatas[0].getLocalControlHeader().hasNextHopFaceId(), false);
}
BOOST_AUTO_TEST_SUITE_END()