face: deduplicate multicast UDP socket setup
In preparation for adding IPv6 support.
Change-Id: I5a3be2007f7fecc44915a5d6794093143ce9c0f9
Refs: #4222
diff --git a/tests/daemon/face/multicast-udp-transport-fixture.hpp b/tests/daemon/face/multicast-udp-transport-fixture.hpp
index 7c3ca21..2b86833 100644
--- a/tests/daemon/face/multicast-udp-transport-fixture.hpp
+++ b/tests/daemon/face/multicast-udp-transport-fixture.hpp
@@ -55,12 +55,16 @@
void
initialize(ip::address address)
{
- openMulticastSockets(remoteSockRx, remoteSockTx, multicastEp.port());
+ localEp = udp::endpoint(address, 7001);
+
+ MulticastUdpTransport::openRxSocket(remoteSockRx, multicastEp, ip::address_v4::any());
+ MulticastUdpTransport::openTxSocket(remoteSockTx, udp::endpoint(udp::v4(), 0), true);
udp::socket sockRx(g_io);
udp::socket sockTx(g_io);
- localEp = udp::endpoint(address, 7001);
- openMulticastSockets(sockRx, sockTx, localEp.port());
+ MulticastUdpTransport::openRxSocket(sockRx, udp::endpoint(multicastEp.address(), localEp.port()),
+ ip::address_v4::any());
+ MulticastUdpTransport::openTxSocket(sockTx, udp::endpoint(udp::v4(), 0), true);
face = make_unique<Face>(
make_unique<DummyReceiveLinkService>(),
@@ -73,20 +77,6 @@
}
void
- openMulticastSockets(udp::socket& rx, udp::socket& tx, uint16_t port)
- {
- rx.open(udp::v4());
- rx.set_option(udp::socket::reuse_address(true));
- rx.bind(udp::endpoint(multicastEp.address(), port));
- rx.set_option(ip::multicast::join_group(multicastEp.address()));
-
- tx.open(udp::v4());
- tx.set_option(udp::socket::reuse_address(true));
- tx.set_option(ip::multicast::enable_loopback(true));
- tx.bind(udp::endpoint(ip::address_v4::any(), port));
- }
-
- void
remoteRead(std::vector<uint8_t>& buf, bool needToCheck = true)
{
remoteSockRx.async_receive(boost::asio::buffer(buf),