tests: fix UDP multicast transport tests with IPv6
A valid scope id is always required on the multicast address Change-Id: Ic676fcde0ee50daf75eb38c137e3cb917f43699f
This commit is contained in:
1 parent
d94b7b3b24
commit
279af1ceac
30 files changed
+110
-92
No files matched your search
@@ -134,7 +134,7 @@ void
|
||||
MulticastUdpTransport::openRxSocket(protocol::socket& sock,
|
||||
const protocol::endpoint& multicastGroup,
|
||||
const boost::asio::ip::address& localAddress,
|
||||
const shared_ptr<const ndn::net::NetworkInterface>& netif)
|
||||
const ndn::net::NetworkInterface* netif)
|
||||
{
|
||||
BOOST_ASSERT(!sock.is_open());
|
||||
|
||||
@@ -148,16 +148,9 @@ MulticastUdpTransport::openRxSocket(protocol::socket& sock,
|
||||
localAddress.to_v4()));
|
||||
}
|
||||
else {
|
||||
BOOST_ASSERT(localAddress.is_v6());
|
||||
BOOST_ASSERT(multicastGroup.address().to_v6().scope_id() != 0);
|
||||
sock.set_option(boost::asio::ip::v6_only(true));
|
||||
#ifdef NFD_WITH_TESTS
|
||||
// To simplify unit tests, we bind to the "any" IPv6 address if the supplied multicast
|
||||
// address lacks a scope id. Calling bind() without a scope id would otherwise fail.
|
||||
if (multicastGroup.address().to_v6().scope_id() == 0)
|
||||
sock.bind(protocol::endpoint(boost::asio::ip::address_v6::any(), multicastGroup.port()));
|
||||
else
|
||||
#endif
|
||||
sock.bind(multicastGroup);
|
||||
sock.bind(multicastGroup);
|
||||
sock.set_option(boost::asio::ip::multicast::join_group(multicastGroup.address().to_v6()));
|
||||
}
|
||||
|
||||
@@ -168,7 +161,7 @@ MulticastUdpTransport::openRxSocket(protocol::socket& sock,
|
||||
void
|
||||
MulticastUdpTransport::openTxSocket(protocol::socket& sock,
|
||||
const protocol::endpoint& localEndpoint,
|
||||
const shared_ptr<const ndn::net::NetworkInterface>& netif,
|
||||
const ndn::net::NetworkInterface* netif,
|
||||
bool enableLoopback)
|
||||
{
|
||||
BOOST_ASSERT(!sock.is_open());
|
||||
|
||||
@@ -62,16 +62,22 @@ public:
|
||||
ssize_t
|
||||
getSendQueueLength() final;
|
||||
|
||||
/**
|
||||
* \brief Opens and configures the receive-side socket
|
||||
*/
|
||||
static void
|
||||
openRxSocket(protocol::socket& sock,
|
||||
const protocol::endpoint& multicastGroup,
|
||||
const boost::asio::ip::address& localAddress,
|
||||
const shared_ptr<const ndn::net::NetworkInterface>& netif = nullptr);
|
||||
const boost::asio::ip::address& localAddress = {},
|
||||
const ndn::net::NetworkInterface* netif = nullptr);
|
||||
|
||||
/**
|
||||
* \brief Opens and configures the transmit-side socket
|
||||
*/
|
||||
static void
|
||||
openTxSocket(protocol::socket& sock,
|
||||
const protocol::endpoint& localEndpoint,
|
||||
const shared_ptr<const ndn::net::NetworkInterface>& netif = nullptr,
|
||||
const ndn::net::NetworkInterface* netif = nullptr,
|
||||
bool enableLoopback = false);
|
||||
|
||||
private:
|
||||
|
||||
@@ -324,7 +324,7 @@ UdpFactory::doGetChannels() const
|
||||
}
|
||||
|
||||
shared_ptr<Face>
|
||||
UdpFactory::createMulticastFace(const shared_ptr<const net::NetworkInterface>& netif,
|
||||
UdpFactory::createMulticastFace(const net::NetworkInterface& netif,
|
||||
const ip::address& localAddress,
|
||||
const udp::Endpoint& multicastEndpoint)
|
||||
{
|
||||
@@ -337,7 +337,7 @@ UdpFactory::createMulticastFace(const shared_ptr<const net::NetworkInterface>& n
|
||||
if (mcastEp.address().is_v6()) {
|
||||
// in IPv6, a scope id on the multicast address is always required
|
||||
auto mcastAddress = mcastEp.address().to_v6();
|
||||
mcastAddress.scope_id(netif->getIndex());
|
||||
mcastAddress.scope_id(netif.getIndex());
|
||||
mcastEp.address(mcastAddress);
|
||||
}
|
||||
|
||||
@@ -358,9 +358,9 @@ UdpFactory::createMulticastFace(const shared_ptr<const net::NetworkInterface>& n
|
||||
}
|
||||
|
||||
ip::udp::socket rxSock(getGlobalIoService());
|
||||
MulticastUdpTransport::openRxSocket(rxSock, mcastEp, localAddress, netif);
|
||||
MulticastUdpTransport::openRxSocket(rxSock, mcastEp, localAddress, &netif);
|
||||
ip::udp::socket txSock(getGlobalIoService());
|
||||
MulticastUdpTransport::openTxSocket(txSock, udp::Endpoint(localAddress, 0), netif);
|
||||
MulticastUdpTransport::openTxSocket(txSock, udp::Endpoint(localAddress, 0), &netif);
|
||||
|
||||
GenericLinkService::Options options;
|
||||
options.allowCongestionMarking = m_wantCongestionMarking;
|
||||
@@ -442,7 +442,7 @@ UdpFactory::applyMcastConfigToNetif(const shared_ptr<const net::NetworkInterface
|
||||
|
||||
std::vector<shared_ptr<Face>> faces;
|
||||
for (const auto& addr : addrs) {
|
||||
auto face = this->createMulticastFace(netif, addr,
|
||||
auto face = this->createMulticastFace(*netif, addr,
|
||||
addr.is_v4() ? m_mcastConfig.group : m_mcastConfig.groupV6);
|
||||
if (face->getId() == INVALID_FACEID) {
|
||||
// new face: register with forwarding
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
* \throw UdpFactory::Error
|
||||
*/
|
||||
shared_ptr<Face>
|
||||
createMulticastFace(const shared_ptr<const ndn::net::NetworkInterface>& netif,
|
||||
createMulticastFace(const ndn::net::NetworkInterface& netif,
|
||||
const boost::asio::ip::address& localAddress,
|
||||
const udp::Endpoint& multicastEndpoint);
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#include "unicast-udp-transport-fixture.hpp"
|
||||
#include "multicast-udp-transport-fixture.hpp"
|
||||
|
||||
#include "transport-test-common.hpp"
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
|
||||
#include "face/internal-face.hpp"
|
||||
|
||||
#include "transport-test-common.hpp"
|
||||
#include "tests/key-chain-fixture.hpp"
|
||||
#include "tests/daemon/global-io-fixture.hpp"
|
||||
#include "tests/daemon/face/transport-test-common.hpp"
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "transport-test-common.hpp"
|
||||
|
||||
#include "ethernet-fixture.hpp"
|
||||
|
||||
#include "common/global.hpp"
|
||||
|
||||
#include "tests/daemon/face/transport-test-common.hpp"
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
using namespace nfd::face;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "tests/test-common.hpp"
|
||||
#include "tests/daemon/limited-io.hpp"
|
||||
#include "tests/daemon/face/dummy-link-service.hpp"
|
||||
#include "tests/daemon/face/transport-test-common.hpp"
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
@@ -43,7 +44,7 @@ class MulticastUdpTransportFixture : public GlobalIoFixture
|
||||
{
|
||||
protected:
|
||||
void
|
||||
initialize(ip::address address)
|
||||
initialize(const shared_ptr<const ndn::net::NetworkInterface>& netif, const ip::address& address)
|
||||
{
|
||||
ip::address mcastAddr;
|
||||
if (address.is_v4()) {
|
||||
@@ -53,19 +54,19 @@ protected:
|
||||
else {
|
||||
// the group FF0X::114 is reserved for experimentation at all scope levels (RFC 4727)
|
||||
auto v6Addr = ip::address_v6::from_string("FF01::114");
|
||||
v6Addr.scope_id(address.to_v6().scope_id());
|
||||
v6Addr.scope_id(netif->getIndex());
|
||||
mcastAddr = v6Addr;
|
||||
}
|
||||
mcastEp = udp::endpoint(mcastAddr, 7373);
|
||||
remoteMcastEp = udp::endpoint(mcastAddr, 8383);
|
||||
|
||||
MulticastUdpTransport::openRxSocket(remoteSockRx, mcastEp, address);
|
||||
MulticastUdpTransport::openTxSocket(remoteSockTx, udp::endpoint(address, 0), nullptr, true);
|
||||
MulticastUdpTransport::openTxSocket(remoteSockTx, udp::endpoint(address, 0), &*netif, true);
|
||||
|
||||
udp::socket sockRx(g_io);
|
||||
udp::socket sockTx(g_io);
|
||||
MulticastUdpTransport::openRxSocket(sockRx, remoteMcastEp, address);
|
||||
MulticastUdpTransport::openTxSocket(sockTx, udp::endpoint(address, txPort), nullptr, true);
|
||||
MulticastUdpTransport::openTxSocket(sockTx, udp::endpoint(address, txPort), &*netif, true);
|
||||
|
||||
face = make_unique<Face>(make_unique<DummyLinkService>(),
|
||||
make_unique<MulticastUdpTransport>(mcastEp, std::move(sockRx), std::move(sockTx),
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "transport-test-common.hpp"
|
||||
|
||||
#include "multicast-udp-transport-fixture.hpp"
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
@@ -34,12 +32,7 @@ namespace nfd::tests {
|
||||
using namespace nfd::face;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Face)
|
||||
|
||||
using MulticastUdpTransportFixtureWithAddress =
|
||||
IpTransportFixture<MulticastUdpTransportFixture, AddressFamily::Any,
|
||||
AddressScope::Global, MulticastInterface::Yes>;
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestMulticastUdpTransport, MulticastUdpTransportFixtureWithAddress)
|
||||
BOOST_AUTO_TEST_SUITE(TestMulticastUdpTransport)
|
||||
|
||||
using MulticastUdpTransportFixtures = boost::mpl::vector<
|
||||
IpTransportFixture<MulticastUdpTransportFixture, AddressFamily::V4, AddressScope::Global, MulticastInterface::Yes>,
|
||||
@@ -63,7 +56,12 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(StaticProperties, T, MulticastUdpTransportFixtu
|
||||
BOOST_CHECK_GT(this->transport->getSendQueueCapacity(), 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(PersistencyChange)
|
||||
using MulticastUdpTransportFixtureWithAddress = IpTransportFixture<MulticastUdpTransportFixture,
|
||||
AddressFamily::Any,
|
||||
AddressScope::LinkLocal,
|
||||
MulticastInterface::Yes>;
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(PersistencyChange, MulticastUdpTransportFixtureWithAddress)
|
||||
{
|
||||
TRANSPORT_TEST_INIT();
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "face/null-transport.hpp"
|
||||
|
||||
#include "tests/daemon/global-io-fixture.hpp"
|
||||
#include "transport-test-common.hpp"
|
||||
#include "tests/daemon/face/transport-test-common.hpp"
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#include "tcp-transport-fixture.hpp"
|
||||
#include "unix-stream-transport-fixture.hpp"
|
||||
|
||||
#include "transport-test-common.hpp"
|
||||
|
||||
#include <boost/asio/read.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(ConnectTimeout, F, AddressFamilies)
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
// do not listen
|
||||
|
||||
auto channel = this->makeChannel(typename IpAddressFromFamily<F::value>::type());
|
||||
auto channel = this->makeChannel(IpAddressTypeFromFamily<F::value>());
|
||||
channel->connect(tcp::Endpoint(address, 7040), {},
|
||||
[this] (const shared_ptr<nfd::Face>&) {
|
||||
BOOST_FAIL("Connect succeeded when it should have failed");
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "tests/test-common.hpp"
|
||||
#include "tests/daemon/limited-io.hpp"
|
||||
#include "tests/daemon/face/dummy-link-service.hpp"
|
||||
#include "tests/daemon/face/transport-test-common.hpp"
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
@@ -64,7 +65,7 @@ protected:
|
||||
}
|
||||
|
||||
void
|
||||
initialize(ip::address address,
|
||||
initialize(const shared_ptr<const ndn::net::NetworkInterface>&, const ip::address& address,
|
||||
ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
|
||||
{
|
||||
tcp::endpoint remoteEp(address, 7070);
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "transport-test-common.hpp"
|
||||
|
||||
#include "tcp-transport-fixture.hpp"
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
@@ -40,7 +40,7 @@ struct FixtureAndAddress
|
||||
{
|
||||
using Fixture = F;
|
||||
static constexpr AddressFamily ADDRESS_FAMILY = AF;
|
||||
using Address = typename IpAddressFromFamily<AF>::type;
|
||||
using Address = IpAddressTypeFromFamily<AF>;
|
||||
};
|
||||
|
||||
using FixtureAndAddressList = boost::mpl::vector<
|
||||
|
||||
@@ -83,6 +83,12 @@ matchTristate(E e, bool b)
|
||||
|
||||
boost::asio::ip::address
|
||||
getTestIp(AddressFamily family, AddressScope scope, MulticastInterface mcast)
|
||||
{
|
||||
return std::get<boost::asio::ip::address>(getTestInterfaceAndIp(family, scope, mcast));
|
||||
}
|
||||
|
||||
std::tuple<shared_ptr<const ndn::net::NetworkInterface>, boost::asio::ip::address>
|
||||
getTestInterfaceAndIp(AddressFamily family, AddressScope scope, MulticastInterface mcast)
|
||||
{
|
||||
for (const auto& interface : collectNetworkInterfaces()) {
|
||||
if (!interface->isUp() ||
|
||||
@@ -97,7 +103,7 @@ getTestIp(AddressFamily family, AddressScope scope, MulticastInterface mcast)
|
||||
static_cast<int>(scope) == static_cast<int>(address.getScope())) &&
|
||||
(scope != AddressScope::Loopback ||
|
||||
address.getIp().is_loopback())) {
|
||||
return address.getIp();
|
||||
return {interface, address.getIp()};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
#include <ndn-cxx/net/network-address.hpp>
|
||||
#include <ndn-cxx/net/network-interface.hpp>
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
@@ -61,8 +62,6 @@ enum class MulticastInterface {
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, MulticastInterface mcast);
|
||||
|
||||
/** \brief Derives IP address type from AddressFamily
|
||||
*/
|
||||
template<AddressFamily AF>
|
||||
struct IpAddressFromFamily;
|
||||
|
||||
@@ -78,18 +77,36 @@ struct IpAddressFromFamily<AddressFamily::V6>
|
||||
using type = boost::asio::ip::address_v6;
|
||||
};
|
||||
|
||||
/** \brief Get an IP address from any available network interface
|
||||
* \param family the desired address family
|
||||
* \param scope the desired address scope
|
||||
* \param mcast specifies if the address can, must, or must not be chosen from a multicast-capable interface
|
||||
* \return an IP address, either boost::asio::ip::address_v4 or boost::asio::ip::address_v6
|
||||
* \retval unspecified address, if no appropriate address is available
|
||||
/**
|
||||
* \brief Derives IP address type from AddressFamily
|
||||
*/
|
||||
boost::asio::ip::address
|
||||
template<AddressFamily AF>
|
||||
using IpAddressTypeFromFamily = typename IpAddressFromFamily<AF>::type;
|
||||
|
||||
/**
|
||||
* \brief Get an IP address from any available network interface, satisfying the given requirements
|
||||
* \param family the desired address family
|
||||
* \param scope the desired address scope
|
||||
* \param mcast specifies if the address can, must, or must not be chosen from a multicast-capable interface
|
||||
* \return an IP address, either boost::asio::ip::address_v4 or boost::asio::ip::address_v6
|
||||
* \retval unspecified address, if no appropriate address is available
|
||||
*/
|
||||
[[nodiscard]] boost::asio::ip::address
|
||||
getTestIp(AddressFamily family = AddressFamily::Any,
|
||||
AddressScope scope = AddressScope::Any,
|
||||
MulticastInterface mcast = MulticastInterface::Any);
|
||||
|
||||
/**
|
||||
* \brief Get a network interface and an IP address on it that satisfy the given requirements
|
||||
* \param family the desired address family
|
||||
* \param scope the desired address scope
|
||||
* \param mcast specifies if the address can, must, or must not be chosen from a multicast-capable interface
|
||||
*/
|
||||
[[nodiscard]] std::tuple<shared_ptr<const ndn::net::NetworkInterface>, boost::asio::ip::address>
|
||||
getTestInterfaceAndIp(AddressFamily family = AddressFamily::Any,
|
||||
AddressScope scope = AddressScope::Any,
|
||||
MulticastInterface mcast = MulticastInterface::Any);
|
||||
|
||||
} // namespace nfd::tests
|
||||
|
||||
/** \brief Skip the rest of the test case if \p address is unavailable
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
using ndn::net::NetworkInterface;
|
||||
using ndn::net::NetworkMonitor;
|
||||
|
||||
std::vector<shared_ptr<const NetworkInterface>>
|
||||
enumerateNetworkInterfaces(NetworkMonitor& netmon)
|
||||
{
|
||||
|
||||
@@ -28,30 +28,25 @@
|
||||
|
||||
#include "core/common.hpp"
|
||||
|
||||
#include <ndn-cxx/net/network-address.hpp>
|
||||
#include <ndn-cxx/net/network-interface.hpp>
|
||||
#include <ndn-cxx/net/network-monitor.hpp>
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
using ndn::net::NetworkAddress;
|
||||
using ndn::net::NetworkInterface;
|
||||
using ndn::net::NetworkMonitor;
|
||||
|
||||
/** \brief Enumerate network interfaces using the given NetworkMonitor
|
||||
* \param netmon a NetworkMonitor constructed on the global io_service.
|
||||
* \note This function is blocking
|
||||
* \note Signals are supported if caller keeps \p netmon running
|
||||
*/
|
||||
std::vector<shared_ptr<const NetworkInterface>>
|
||||
enumerateNetworkInterfaces(NetworkMonitor& netmon);
|
||||
std::vector<shared_ptr<const ndn::net::NetworkInterface>>
|
||||
enumerateNetworkInterfaces(ndn::net::NetworkMonitor& netmon);
|
||||
|
||||
/** \brief Collect information about network interfaces
|
||||
* \param allowCached if true, previously collected information can be returned
|
||||
* \note This function is blocking if \p allowCached is false or no previous information exists
|
||||
* \warning Signals are not triggered on returned NetworkInterfaces because NetworkMonitor is not running
|
||||
*/
|
||||
std::vector<shared_ptr<const NetworkInterface>>
|
||||
std::vector<shared_ptr<const ndn::net::NetworkInterface>>
|
||||
collectNetworkInterfaces(bool allowCached = true);
|
||||
|
||||
} // namespace nfd::tests
|
||||
|
||||
@@ -61,29 +61,35 @@ class IpTransportFixture : public TransportFixtureBase
|
||||
protected:
|
||||
IpTransportFixture()
|
||||
{
|
||||
std::tie(interface, address) = getTestInterfaceAndIp(AF, AS, MC);
|
||||
|
||||
BOOST_TEST_MESSAGE("Testing with AddressFamily=" << AF <<
|
||||
" AddressScope=" << AS <<
|
||||
" MulticastInterface=" << MC <<
|
||||
" TestIp=" << address);
|
||||
" TestInterface=" << (interface == nullptr ? "N/A" : interface->getName()) <<
|
||||
" TestIp=" << (address.is_unspecified() ? "N/A" : address.to_string()));
|
||||
}
|
||||
|
||||
[[nodiscard]] std::pair<bool, std::string>
|
||||
[[nodiscard]] std::tuple<bool, std::string>
|
||||
checkPreconditions() const
|
||||
{
|
||||
return {!address.is_unspecified(), "no appropriate IP address available"};
|
||||
return {interface != nullptr && !address.is_unspecified(),
|
||||
"no appropriate interface or IP address available"};
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void
|
||||
initialize(Args&&... args)
|
||||
{
|
||||
TransportFixtureBase::initialize(address, std::forward<Args>(args)...);
|
||||
TransportFixtureBase::initialize(interface, address, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
protected:
|
||||
static constexpr AddressFamily addressFamily = AF;
|
||||
static constexpr AddressScope addressScope = AS;
|
||||
const boost::asio::ip::address address = getTestIp(AF, AS, MC);
|
||||
|
||||
shared_ptr<const ndn::net::NetworkInterface> interface;
|
||||
boost::asio::ip::address address;
|
||||
};
|
||||
|
||||
} // namespace nfd::tests
|
||||
|
||||
@@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(DefaultMtu, F, AddressFamilies)
|
||||
SKIP_IF_IP_UNAVAILABLE(address);
|
||||
this->listen(address,1452);
|
||||
|
||||
auto ch1 = this->makeChannel(typename IpAddressFromFamily<F::value>::type(), 0, 1232);
|
||||
auto ch1 = this->makeChannel(IpAddressTypeFromFamily<F::value>(), 0, 1232);
|
||||
connect(*ch1);
|
||||
|
||||
BOOST_CHECK_EQUAL(this->limitedIo.run(2, 1_s), LimitedIo::EXCEED_OPS);
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace nfd::tests {
|
||||
|
||||
using face::UdpChannel;
|
||||
using face::UdpFactory;
|
||||
using ndn::net::NetworkInterface;
|
||||
|
||||
class UdpFactoryFixture : public FaceSystemFactoryFixture<UdpFactory>
|
||||
{
|
||||
@@ -79,11 +80,11 @@ protected:
|
||||
|
||||
if (localAddress.is_v4()) {
|
||||
BOOST_ASSERT(!netifsV4.empty());
|
||||
return factory.createMulticastFace(netifsV4.front(), localAddress, mcastEndpoint);
|
||||
return factory.createMulticastFace(*netifsV4.front(), localAddress, mcastEndpoint);
|
||||
}
|
||||
else {
|
||||
BOOST_ASSERT(!netifsV6.empty());
|
||||
return factory.createMulticastFace(netifsV6.front(), localAddress, mcastEndpoint);
|
||||
return factory.createMulticastFace(*netifsV6.front(), localAddress, mcastEndpoint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +121,7 @@ protected:
|
||||
hasAddressFamily(const NetworkInterface& netif, ndn::net::AddressFamily af)
|
||||
{
|
||||
return std::any_of(netif.getNetworkAddresses().begin(), netif.getNetworkAddresses().end(),
|
||||
[af] (const NetworkAddress& a) { return a.getFamily() == af; });
|
||||
[af] (const auto& a) { return a.getFamily() == af; });
|
||||
}
|
||||
|
||||
/** \brief determine whether a UDP multicast face is created on \p netif
|
||||
@@ -130,7 +131,7 @@ protected:
|
||||
{
|
||||
auto ip = boost::asio::ip::address::from_string(face.getLocalUri().getHost());
|
||||
return std::any_of(netif.getNetworkAddresses().begin(), netif.getNetworkAddresses().end(),
|
||||
[ip] (const NetworkAddress& a) { return a.getIp() == ip; });
|
||||
[ip] (const auto& a) { return a.getIp() == ip; });
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "transport-test-common.hpp"
|
||||
|
||||
#include "ethernet-fixture.hpp"
|
||||
|
||||
#include "common/global.hpp"
|
||||
|
||||
#include "tests/daemon/face/transport-test-common.hpp"
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
using namespace nfd::face;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "tests/test-common.hpp"
|
||||
#include "tests/daemon/limited-io.hpp"
|
||||
#include "tests/daemon/face/dummy-link-service.hpp"
|
||||
#include "tests/daemon/face/transport-test-common.hpp"
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
@@ -43,7 +44,7 @@ class UnicastUdpTransportFixture : public GlobalIoFixture
|
||||
{
|
||||
protected:
|
||||
void
|
||||
initialize(ip::address address,
|
||||
initialize(const shared_ptr<const ndn::net::NetworkInterface>&, const ip::address& address,
|
||||
ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
|
||||
{
|
||||
udp::socket sock(g_io);
|
||||
@@ -61,7 +62,7 @@ protected:
|
||||
}
|
||||
|
||||
void
|
||||
remoteConnect(ip::address address = ip::address_v4::loopback())
|
||||
remoteConnect(const ip::address& address = ip::address_v4::loopback())
|
||||
{
|
||||
udp::endpoint remoteEp(address, 7070);
|
||||
remoteSocket.open(remoteEp.protocol());
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "transport-test-common.hpp"
|
||||
|
||||
#include "unicast-udp-transport-fixture.hpp"
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "tests/test-common.hpp"
|
||||
#include "tests/daemon/limited-io.hpp"
|
||||
#include "tests/daemon/face/dummy-link-service.hpp"
|
||||
#include "tests/daemon/face/transport-test-common.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
@@ -87,7 +88,7 @@ protected:
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<bool, std::string>
|
||||
[[nodiscard]] std::tuple<bool, std::string>
|
||||
checkPreconditions() const
|
||||
{
|
||||
return {true, ""};
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "transport-test-common.hpp"
|
||||
|
||||
#include "unix-stream-transport-fixture.hpp"
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
@@ -41,16 +41,14 @@ using AddressFamilies = boost::mpl::vector<
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE(Uri, F, AddressFamilies)
|
||||
{
|
||||
using Address = typename IpAddressFromFamily<F::value>::type;
|
||||
websocket::Endpoint ep(Address::loopback(), 20070);
|
||||
websocket::Endpoint ep(IpAddressTypeFromFamily<F::value>::loopback(), 20070);
|
||||
auto channel = this->makeChannel(ep.address(), ep.port());
|
||||
BOOST_CHECK_EQUAL(channel->getUri(), FaceUri(ep, "ws"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE(Listen, F, AddressFamilies)
|
||||
{
|
||||
using Address = typename IpAddressFromFamily<F::value>::type;
|
||||
auto channel = this->makeChannel(Address());
|
||||
auto channel = this->makeChannel(IpAddressTypeFromFamily<F::value>());
|
||||
BOOST_CHECK_EQUAL(channel->isListening(), false);
|
||||
|
||||
channel->listen(nullptr);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "tests/test-common.hpp"
|
||||
#include "tests/daemon/limited-io.hpp"
|
||||
#include "tests/daemon/face/dummy-link-service.hpp"
|
||||
#include "tests/daemon/face/transport-test-common.hpp"
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
@@ -86,10 +87,12 @@ protected:
|
||||
client.connect(con);
|
||||
}
|
||||
|
||||
/** \brief initialize both server and client, and have each other connected, create Transport
|
||||
/**
|
||||
* \brief Initialize both server and client, and have each other connected, create Transport
|
||||
*/
|
||||
void
|
||||
initialize(ip::address address,
|
||||
initialize(const shared_ptr<const ndn::net::NetworkInterface>&,
|
||||
const ip::address& address,
|
||||
time::milliseconds pingInterval = 10_s,
|
||||
time::milliseconds pongTimeout = 1_s)
|
||||
{
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "transport-test-common.hpp"
|
||||
|
||||
#include "websocket-transport-fixture.hpp"
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
@@ -67,7 +65,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(StaticPropertiesV4Mapped, T, StaticPropertiesV4
|
||||
TRANSPORT_TEST_CHECK_PRECONDITIONS();
|
||||
auto mappedAddr = ip::address_v6::v4_mapped(this->address.to_v4());
|
||||
BOOST_REQUIRE(mappedAddr.is_v4_mapped());
|
||||
WebSocketTransportFixture::initialize(mappedAddr);
|
||||
WebSocketTransportFixture::initialize(this->interface, mappedAddr);
|
||||
|
||||
checkStaticPropertiesInitialized(*this->transport);
|
||||
|
||||
|
||||
Reference in new issue
Block a user