From c0df94ed10de2180016b7bcd605952e9bf80f19c Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Sun, 8 Oct 2023 19:26:55 -0400 Subject: [PATCH] face: minor code cleanups Change-Id: I154d2ad4dfd9e12e1fa9756f74884286b31298e4 --- daemon/face/datagram-transport.hpp | 7 +-- daemon/face/ethernet-transport.hpp | 8 ++-- daemon/face/multicast-ethernet-transport.cpp | 5 +-- daemon/face/multicast-ethernet-transport.hpp | 8 ++-- daemon/face/multicast-udp-transport.cpp | 43 ++++++++++--------- daemon/face/multicast-udp-transport.hpp | 28 ++++++------ daemon/face/network-predicate.hpp | 2 +- daemon/face/stream-transport.hpp | 10 +++-- daemon/face/tcp-channel.cpp | 6 +-- daemon/face/tcp-factory.cpp | 4 +- daemon/face/tcp-transport.cpp | 8 ++-- daemon/face/tcp-transport.hpp | 22 +++++----- daemon/face/udp-channel.cpp | 10 ++--- daemon/face/udp-channel.hpp | 4 -- daemon/face/unicast-ethernet-transport.hpp | 6 +-- daemon/face/unicast-udp-transport.cpp | 8 ++-- daemon/face/unicast-udp-transport.hpp | 6 +-- daemon/face/unix-stream-transport.cpp | 10 +++-- daemon/face/unix-stream-transport.hpp | 6 +-- tests/daemon/face/tcp-transport-fixture.hpp | 4 +- .../face/unicast-udp-transport-fixture.hpp | 4 +- 21 files changed, 106 insertions(+), 103 deletions(-) diff --git a/daemon/face/datagram-transport.hpp b/daemon/face/datagram-transport.hpp index cbef9baf..e34e4431 100644 --- a/daemon/face/datagram-transport.hpp +++ b/daemon/face/datagram-transport.hpp @@ -40,7 +40,7 @@ struct Unicast {}; struct Multicast {}; /** - * \brief Implements Transport for datagram-based protocols. + * \brief Implements a Transport for datagram-based protocols. * * \tparam Protocol A datagram-based protocol in Boost.Asio * \tparam Addressing The addressing mode, either Unicast or Multicast @@ -52,9 +52,10 @@ public: using protocol = Protocol; using addressing = Addressing; - /** \brief Construct datagram transport. + /** + * \brief Construct datagram transport. * - * \param socket Protocol-specific socket for the created transport + * \param socket Protocol-specific socket for the created transport */ explicit DatagramTransport(typename protocol::socket&& socket); diff --git a/daemon/face/ethernet-transport.hpp b/daemon/face/ethernet-transport.hpp index 8fa7a6a5..a1d3c802 100644 --- a/daemon/face/ethernet-transport.hpp +++ b/daemon/face/ethernet-transport.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -36,7 +36,7 @@ namespace nfd::face { /** - * @brief Base class for Ethernet-based Transports + * @brief Base class for Ethernet-based Transports. */ class EthernetTransport : public Transport { @@ -48,7 +48,7 @@ public: }; /** - * @brief Processes the payload of an incoming frame + * @brief Processes the payload of an incoming frame. * @param payload Payload bytes, starting from the first byte after the Ethernet header * @param sender Sender address */ @@ -82,7 +82,7 @@ private: doSend(const Block& packet) final; /** - * @brief Sends the specified TLV block on the network wrapped in an Ethernet frame + * @brief Sends the specified TLV block on the network wrapped in an Ethernet frame. */ void sendPacket(const ndn::Block& block); diff --git a/daemon/face/multicast-ethernet-transport.cpp b/daemon/face/multicast-ethernet-transport.cpp index 2068012f..459c8c1a 100644 --- a/daemon/face/multicast-ethernet-transport.cpp +++ b/daemon/face/multicast-ethernet-transport.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -103,8 +103,7 @@ MulticastEthernetTransport::joinMulticastGroup() #if defined(__APPLE__) || defined(__FreeBSD__) // see bug #2327 - using boost::asio::ip::udp; - udp::socket sock(getGlobalIoService(), udp::v4()); + boost::asio::ip::udp::socket sock(getGlobalIoService(), boost::asio::ip::udp::v4()); int fd = sock.native_handle(); // Differences between Linux and the BSDs (including macOS): diff --git a/daemon/face/multicast-ethernet-transport.hpp b/daemon/face/multicast-ethernet-transport.hpp index 27c195c9..9ab04a0a 100644 --- a/daemon/face/multicast-ethernet-transport.hpp +++ b/daemon/face/multicast-ethernet-transport.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -31,13 +31,13 @@ namespace nfd::face { /** - * @brief A multicast Transport that uses raw Ethernet II frames + * @brief A multicast Transport that uses raw Ethernet II frames. */ class MulticastEthernetTransport final : public EthernetTransport { public: /** - * @brief Creates an Ethernet-based transport for multicast communication + * @brief Creates an Ethernet-based transport for multicast communication. */ MulticastEthernetTransport(const ndn::net::NetworkInterface& localEndpoint, const ethernet::Address& mcastAddress, @@ -45,7 +45,7 @@ public: private: /** - * @brief Enables receiving frames addressed to our MAC multicast group + * @brief Enables receiving frames addressed to our MAC multicast group. */ void joinMulticastGroup(); diff --git a/daemon/face/multicast-udp-transport.cpp b/daemon/face/multicast-udp-transport.cpp index 60827457..22c157c6 100644 --- a/daemon/face/multicast-udp-transport.cpp +++ b/daemon/face/multicast-udp-transport.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -40,11 +40,13 @@ namespace nfd::face { -NFD_LOG_MEMBER_INIT_SPECIALIZED((DatagramTransport), MulticastUdpTransport); +namespace ip = boost::asio::ip; -MulticastUdpTransport::MulticastUdpTransport(const protocol::endpoint& multicastGroup, - protocol::socket&& recvSocket, - protocol::socket&& sendSocket, +NFD_LOG_MEMBER_INIT_SPECIALIZED((DatagramTransport), MulticastUdpTransport); + +MulticastUdpTransport::MulticastUdpTransport(const ip::udp::endpoint& multicastGroup, + ip::udp::socket&& recvSocket, + ip::udp::socket&& sendSocket, ndn::nfd::LinkType linkType) : DatagramTransport(std::move(recvSocket)) , m_multicastGroup(multicastGroup) @@ -57,7 +59,7 @@ MulticastUdpTransport::MulticastUdpTransport(const protocol::endpoint& multicast this->setLinkType(linkType); this->setMtu(udp::computeMtu(m_sendSocket.local_endpoint())); - protocol::socket::send_buffer_size sendBufferSizeOption; + boost::asio::socket_base::send_buffer_size sendBufferSizeOption; boost::system::error_code error; m_sendSocket.get_option(sendBufferSizeOption); if (error) { @@ -131,27 +133,26 @@ bindToDevice(int fd, const std::string& ifname) } void -MulticastUdpTransport::openRxSocket(protocol::socket& sock, - const protocol::endpoint& multicastGroup, - const boost::asio::ip::address& localAddress, +MulticastUdpTransport::openRxSocket(ip::udp::socket& sock, + const ip::udp::endpoint& multicastGroup, + const ip::address& localAddress, const ndn::net::NetworkInterface* netif) { BOOST_ASSERT(!sock.is_open()); sock.open(multicastGroup.protocol()); - sock.set_option(protocol::socket::reuse_address(true)); + sock.set_option(boost::asio::socket_base::reuse_address(true)); if (multicastGroup.address().is_v4()) { BOOST_ASSERT(localAddress.is_v4()); sock.bind(multicastGroup); - sock.set_option(boost::asio::ip::multicast::join_group(multicastGroup.address().to_v4(), - localAddress.to_v4())); + sock.set_option(ip::multicast::join_group(multicastGroup.address().to_v4(), localAddress.to_v4())); } else { BOOST_ASSERT(multicastGroup.address().to_v6().scope_id() != 0); - sock.set_option(boost::asio::ip::v6_only(true)); + sock.set_option(ip::v6_only(true)); sock.bind(multicastGroup); - sock.set_option(boost::asio::ip::multicast::join_group(multicastGroup.address().to_v6())); + sock.set_option(ip::multicast::join_group(multicastGroup.address().to_v6())); } if (netif) @@ -159,27 +160,27 @@ MulticastUdpTransport::openRxSocket(protocol::socket& sock, } void -MulticastUdpTransport::openTxSocket(protocol::socket& sock, - const protocol::endpoint& localEndpoint, +MulticastUdpTransport::openTxSocket(ip::udp::socket& sock, + const ip::udp::endpoint& localEndpoint, const ndn::net::NetworkInterface* netif, bool enableLoopback) { BOOST_ASSERT(!sock.is_open()); sock.open(localEndpoint.protocol()); - sock.set_option(protocol::socket::reuse_address(true)); - sock.set_option(boost::asio::ip::multicast::enable_loopback(enableLoopback)); + sock.set_option(boost::asio::socket_base::reuse_address(true)); + sock.set_option(ip::multicast::enable_loopback(enableLoopback)); if (localEndpoint.address().is_v4()) { sock.bind(localEndpoint); if (!localEndpoint.address().is_unspecified()) - sock.set_option(boost::asio::ip::multicast::outbound_interface(localEndpoint.address().to_v4())); + sock.set_option(ip::multicast::outbound_interface(localEndpoint.address().to_v4())); } else { - sock.set_option(boost::asio::ip::v6_only(true)); + sock.set_option(ip::v6_only(true)); sock.bind(localEndpoint); if (netif) - sock.set_option(boost::asio::ip::multicast::outbound_interface(netif->getIndex())); + sock.set_option(ip::multicast::outbound_interface(netif->getIndex())); } } diff --git a/daemon/face/multicast-udp-transport.hpp b/daemon/face/multicast-udp-transport.hpp index 52952384..3f7cfa14 100644 --- a/daemon/face/multicast-udp-transport.hpp +++ b/daemon/face/multicast-udp-transport.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -36,7 +36,7 @@ namespace nfd::face { NFD_LOG_MEMBER_DECL_SPECIALIZED((DatagramTransport)); /** - * \brief A Transport that communicates on a UDP multicast group + * \brief A Transport that communicates on a UDP multicast group. */ class MulticastUdpTransport final : public DatagramTransport { @@ -48,35 +48,35 @@ public: }; /** - * \brief Creates a UDP-based transport for multicast communication + * \brief Creates a UDP-based transport for multicast communication. * \param multicastGroup multicast group * \param recvSocket socket used to receive multicast packets * \param sendSocket socket used to send to the multicast group * \param linkType either `ndn::nfd::LINK_TYPE_MULTI_ACCESS` or `ndn::nfd::LINK_TYPE_AD_HOC` */ - MulticastUdpTransport(const protocol::endpoint& multicastGroup, - protocol::socket&& recvSocket, - protocol::socket&& sendSocket, + MulticastUdpTransport(const boost::asio::ip::udp::endpoint& multicastGroup, + boost::asio::ip::udp::socket&& recvSocket, + boost::asio::ip::udp::socket&& sendSocket, ndn::nfd::LinkType linkType); ssize_t getSendQueueLength() final; /** - * \brief Opens and configures the receive-side socket + * \brief Opens and configures the receive-side socket. */ static void - openRxSocket(protocol::socket& sock, - const protocol::endpoint& multicastGroup, + openRxSocket(boost::asio::ip::udp::socket& sock, + const boost::asio::ip::udp::endpoint& multicastGroup, const boost::asio::ip::address& localAddress = {}, const ndn::net::NetworkInterface* netif = nullptr); /** - * \brief Opens and configures the transmit-side socket + * \brief Opens and configures the transmit-side socket. */ static void - openTxSocket(protocol::socket& sock, - const protocol::endpoint& localEndpoint, + openTxSocket(boost::asio::ip::udp::socket& sock, + const boost::asio::ip::udp::endpoint& localEndpoint, const ndn::net::NetworkInterface* netif = nullptr, bool enableLoopback = false); @@ -88,8 +88,8 @@ private: doClose() final; private: - protocol::endpoint m_multicastGroup; - protocol::socket m_sendSocket; + boost::asio::ip::udp::endpoint m_multicastGroup; + boost::asio::ip::udp::socket m_sendSocket; }; } // namespace nfd::face diff --git a/daemon/face/network-predicate.hpp b/daemon/face/network-predicate.hpp index 3405f7c4..965ec880 100644 --- a/daemon/face/network-predicate.hpp +++ b/daemon/face/network-predicate.hpp @@ -44,7 +44,7 @@ public: ~NetworkPredicateBase(); /** - * \brief Set the whitelist to "*" and clear the blacklist + * \brief Set the whitelist to "*" and clear the blacklist. */ void clear(); diff --git a/daemon/face/stream-transport.hpp b/daemon/face/stream-transport.hpp index dcb5265d..448b28b3 100644 --- a/daemon/face/stream-transport.hpp +++ b/daemon/face/stream-transport.hpp @@ -37,9 +37,10 @@ namespace nfd::face { -/** \brief Implements Transport for stream-based protocols. +/** + * \brief Implements a Transport for stream-based protocols. * - * \tparam Protocol a stream-based protocol in Boost.Asio + * \tparam Protocol a stream-based protocol in Boost.Asio */ template class StreamTransport : public Transport @@ -47,9 +48,10 @@ class StreamTransport : public Transport public: using protocol = Protocol; - /** \brief Construct stream transport. + /** + * \brief Construct stream transport. * - * \param socket Protocol-specific socket for the created transport + * \param socket Protocol-specific socket for the created transport */ explicit StreamTransport(typename protocol::socket&& socket); diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp index 38fcd05f..fbfd17d9 100644 --- a/daemon/face/tcp-channel.cpp +++ b/daemon/face/tcp-channel.cpp @@ -33,10 +33,10 @@ namespace nfd::face { -NFD_LOG_INIT(TcpChannel); - namespace ip = boost::asio::ip; +NFD_LOG_INIT(TcpChannel); + TcpChannel::TcpChannel(const tcp::Endpoint& localEndpoint, bool wantCongestionMarking, DetermineFaceScopeFromAddress determineFaceScope) : m_localEndpoint(localEndpoint) @@ -59,7 +59,7 @@ TcpChannel::listen(const FaceCreatedCallback& onFaceCreated, } m_acceptor.open(m_localEndpoint.protocol()); - m_acceptor.set_option(ip::tcp::acceptor::reuse_address(true)); + m_acceptor.set_option(boost::asio::socket_base::reuse_address(true)); if (m_localEndpoint.address().is_v6()) { m_acceptor.set_option(ip::v6_only(true)); } diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp index 09d2cd48..072525d5 100644 --- a/daemon/face/tcp-factory.cpp +++ b/daemon/face/tcp-factory.cpp @@ -215,8 +215,8 @@ TcpFactory::doGetChannels() const } ndn::nfd::FaceScope -TcpFactory::determineFaceScopeFromAddresses(const boost::asio::ip::address& localAddress, - const boost::asio::ip::address& remoteAddress) const +TcpFactory::determineFaceScopeFromAddresses(const ip::address& localAddress, + const ip::address& remoteAddress) const { if (m_local(localAddress) && m_local(remoteAddress)) { return ndn::nfd::FACE_SCOPE_LOCAL; diff --git a/daemon/face/tcp-transport.cpp b/daemon/face/tcp-transport.cpp index 15c07699..074e53a6 100644 --- a/daemon/face/tcp-transport.cpp +++ b/daemon/face/tcp-transport.cpp @@ -35,9 +35,11 @@ namespace nfd::face { -NFD_LOG_MEMBER_INIT_SPECIALIZED(StreamTransport, TcpTransport); +namespace ip = boost::asio::ip; -TcpTransport::TcpTransport(protocol::socket&& socket, +NFD_LOG_MEMBER_INIT_SPECIALIZED(StreamTransport, TcpTransport); + +TcpTransport::TcpTransport(ip::tcp::socket&& socket, ndn::nfd::FacePersistency persistency, ndn::nfd::FaceScope faceScope) : StreamTransport(std::move(socket)) @@ -130,7 +132,7 @@ TcpTransport::reconnect() BOOST_ASSERT(getState() == TransportState::DOWN); // recreate the socket - m_socket = protocol::socket(m_socket.get_executor()); + m_socket = ip::tcp::socket(m_socket.get_executor()); this->resetReceiveBuffer(); this->resetSendQueue(); diff --git a/daemon/face/tcp-transport.hpp b/daemon/face/tcp-transport.hpp index ed147fe4..2b088bb8 100644 --- a/daemon/face/tcp-transport.hpp +++ b/daemon/face/tcp-transport.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -35,7 +35,7 @@ namespace nfd::face { NFD_LOG_MEMBER_DECL_SPECIALIZED(StreamTransport); /** - * \brief A Transport that communicates on a connected TCP socket + * \brief A Transport that communicates on a connected TCP socket. * * When persistency is set to permanent, whenever the TCP connection is severed, the transport * state is set to DOWN, and the connection is retried periodically with exponential backoff @@ -44,7 +44,9 @@ NFD_LOG_MEMBER_DECL_SPECIALIZED(StreamTransport); class TcpTransport NFD_FINAL_UNLESS_WITH_TESTS : public StreamTransport { public: - TcpTransport(protocol::socket&& socket, ndn::nfd::FacePersistency persistency, ndn::nfd::FaceScope faceScope); + TcpTransport(boost::asio::ip::tcp::socket&& socket, + ndn::nfd::FacePersistency persistency, + ndn::nfd::FaceScope faceScope); ssize_t getSendQueueLength() final; @@ -74,29 +76,25 @@ NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE: NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE: /** - * \brief Delay before the first reconnection attempt after the TCP connection has been severed + * \brief Delay before the first reconnection attempt after the TCP connection has been severed. */ static constexpr time::milliseconds INITIAL_RECONNECT_DELAY = 1_s; /** - * \brief Maximum amount of time to wait before a reconnection attempt + * \brief Maximum amount of time to wait before a reconnection attempt. */ static constexpr time::milliseconds MAX_RECONNECT_DELAY = 5_min; /** - * \brief Multiplier for the exponential backoff of the reconnection timer + * \brief Multiplier for the exponential backoff of the reconnection timer. */ static constexpr float RECONNECT_DELAY_MULTIPLIER = 2.0f; private: - typename protocol::endpoint m_remoteEndpoint; + boost::asio::ip::tcp::endpoint m_remoteEndpoint; - /** \note valid only when persistency is set to permanent - */ + // The following members are valid only when the persistency is set to permanent scheduler::ScopedEventId m_reconnectEvent; - - /** \note valid only when persistency is set to permanent - */ time::milliseconds m_nextReconnectWait; }; diff --git a/daemon/face/udp-channel.cpp b/daemon/face/udp-channel.cpp index 80c68787..55733060 100644 --- a/daemon/face/udp-channel.cpp +++ b/daemon/face/udp-channel.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -33,10 +33,10 @@ namespace nfd::face { -NFD_LOG_INIT(UdpChannel); - namespace ip = boost::asio::ip; +NFD_LOG_INIT(UdpChannel); + UdpChannel::UdpChannel(const udp::Endpoint& localEndpoint, time::nanoseconds idleTimeout, bool wantCongestionMarking, @@ -83,7 +83,7 @@ UdpChannel::listen(const FaceCreatedCallback& onFaceCreated, } m_socket.open(m_localEndpoint.protocol()); - m_socket.set_option(ip::udp::socket::reuse_address(true)); + m_socket.set_option(boost::asio::socket_base::reuse_address(true)); if (m_localEndpoint.address().is_v6()) { m_socket.set_option(ip::v6_only(true)); } @@ -160,7 +160,7 @@ UdpChannel::createFace(const udp::Endpoint& remoteEndpoint, // else, create a new face ip::udp::socket socket(getGlobalIoService(), m_localEndpoint.protocol()); - socket.set_option(ip::udp::socket::reuse_address(true)); + socket.set_option(boost::asio::socket_base::reuse_address(true)); socket.bind(m_localEndpoint); socket.connect(remoteEndpoint); diff --git a/daemon/face/udp-channel.hpp b/daemon/face/udp-channel.hpp index e594f640..8c96b095 100644 --- a/daemon/face/udp-channel.hpp +++ b/daemon/face/udp-channel.hpp @@ -91,10 +91,6 @@ private: waitForNewPeer(const FaceCreatedCallback& onFaceCreated, const FaceCreationFailedCallback& onReceiveFailed); - /** - * \brief The channel has received a packet from a remote - * endpoint not associated with any UDP face yet. - */ void handleNewPeer(const boost::system::error_code& error, size_t nBytesReceived, diff --git a/daemon/face/unicast-ethernet-transport.hpp b/daemon/face/unicast-ethernet-transport.hpp index 8078d448..22e943ea 100644 --- a/daemon/face/unicast-ethernet-transport.hpp +++ b/daemon/face/unicast-ethernet-transport.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -31,13 +31,13 @@ namespace nfd::face { /** - * @brief A unicast Transport that uses raw Ethernet II frames + * @brief A unicast Transport that uses raw Ethernet II frames. */ class UnicastEthernetTransport final : public EthernetTransport { public: /** - * @brief Creates an Ethernet-based transport for unicast communication + * @brief Creates an Ethernet-based transport for unicast communication. */ UnicastEthernetTransport(const ndn::net::NetworkInterface& localEndpoint, const ethernet::Address& remoteEndpoint, diff --git a/daemon/face/unicast-udp-transport.cpp b/daemon/face/unicast-udp-transport.cpp index c8a208e2..f6614f81 100644 --- a/daemon/face/unicast-udp-transport.cpp +++ b/daemon/face/unicast-udp-transport.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -36,9 +36,11 @@ namespace nfd::face { -NFD_LOG_MEMBER_INIT_SPECIALIZED((DatagramTransport), UnicastUdpTransport); +namespace ip = boost::asio::ip; -UnicastUdpTransport::UnicastUdpTransport(protocol::socket&& socket, +NFD_LOG_MEMBER_INIT_SPECIALIZED((DatagramTransport), UnicastUdpTransport); + +UnicastUdpTransport::UnicastUdpTransport(ip::udp::socket&& socket, ndn::nfd::FacePersistency persistency, time::nanoseconds idleTimeout) : DatagramTransport(std::move(socket)) diff --git a/daemon/face/unicast-udp-transport.hpp b/daemon/face/unicast-udp-transport.hpp index 82982fc3..4aa7233e 100644 --- a/daemon/face/unicast-udp-transport.hpp +++ b/daemon/face/unicast-udp-transport.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -35,12 +35,12 @@ namespace nfd::face { NFD_LOG_MEMBER_DECL_SPECIALIZED((DatagramTransport)); /** - * \brief A Transport that communicates on a unicast UDP socket + * \brief A Transport that communicates on a unicast UDP socket. */ class UnicastUdpTransport final : public DatagramTransport { public: - UnicastUdpTransport(protocol::socket&& socket, + UnicastUdpTransport(boost::asio::ip::udp::socket&& socket, ndn::nfd::FacePersistency persistency, time::nanoseconds idleTimeout); diff --git a/daemon/face/unix-stream-transport.cpp b/daemon/face/unix-stream-transport.cpp index 76652f37..45947b29 100644 --- a/daemon/face/unix-stream-transport.cpp +++ b/daemon/face/unix-stream-transport.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -27,13 +27,15 @@ namespace nfd::face { -NFD_LOG_MEMBER_INIT_SPECIALIZED(StreamTransport, UnixStreamTransport); +namespace local = boost::asio::local; -UnixStreamTransport::UnixStreamTransport(protocol::socket&& socket) +NFD_LOG_MEMBER_INIT_SPECIALIZED(StreamTransport, UnixStreamTransport); + +UnixStreamTransport::UnixStreamTransport(local::stream_protocol::socket&& socket) : StreamTransport(std::move(socket)) { static_assert( - std::is_same_v, int>, + std::is_same_v, int>, "The native handle type for UnixStreamTransport sockets must be 'int'" ); diff --git a/daemon/face/unix-stream-transport.hpp b/daemon/face/unix-stream-transport.hpp index 47b6a7e6..5b4a6f4a 100644 --- a/daemon/face/unix-stream-transport.hpp +++ b/daemon/face/unix-stream-transport.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -39,13 +39,13 @@ namespace nfd::face { NFD_LOG_MEMBER_DECL_SPECIALIZED(StreamTransport); /** - * \brief A Transport that communicates on a stream-oriented Unix domain socket + * \brief A Transport that communicates on a stream-oriented Unix domain socket. */ class UnixStreamTransport final : public StreamTransport { public: explicit - UnixStreamTransport(protocol::socket&& socket); + UnixStreamTransport(boost::asio::local::stream_protocol::socket&& socket); }; } // namespace nfd::face diff --git a/tests/daemon/face/tcp-transport-fixture.hpp b/tests/daemon/face/tcp-transport-fixture.hpp index 1d1d5ac9..01114e16 100644 --- a/tests/daemon/face/tcp-transport-fixture.hpp +++ b/tests/daemon/face/tcp-transport-fixture.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -48,7 +48,7 @@ protected: { BOOST_REQUIRE(!acceptor.is_open()); acceptor.open(remoteEp.protocol()); - acceptor.set_option(tcp::acceptor::reuse_address(true)); + acceptor.set_option(boost::asio::socket_base::reuse_address(true)); acceptor.bind(remoteEp); acceptor.listen(1); acceptor.async_accept(remoteSocket, [this] (const boost::system::error_code& error) { diff --git a/tests/daemon/face/unicast-udp-transport-fixture.hpp b/tests/daemon/face/unicast-udp-transport-fixture.hpp index 7ec48965..24d7e265 100644 --- a/tests/daemon/face/unicast-udp-transport-fixture.hpp +++ b/tests/daemon/face/unicast-udp-transport-fixture.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2014-2022, Regents of the University of California, + * Copyright (c) 2014-2023, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -66,7 +66,7 @@ protected: { udp::endpoint remoteEp(address, 7070); remoteSocket.open(remoteEp.protocol()); - remoteSocket.set_option(udp::socket::reuse_address(true)); + remoteSocket.set_option(boost::asio::socket_base::reuse_address(true)); remoteSocket.bind(remoteEp); remoteSocket.connect(localEp); }