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 @@ class DatagramTransport : public Transport 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 @@ class EthernetTransport : public Transport }; /** - * @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 @@ class EthernetTransport : public Transport 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 @@ class MulticastEthernetTransport final : public EthernetTransport 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 @@ class MulticastUdpTransport final : public DatagramTransport 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 @@ class TcpTransport NFD_FINAL_UNLESS_WITH_TESTS : public StreamTransport), 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 @@ class TcpTransportFixture : public GlobalIoFixture { 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 @@ class UnicastUdpTransportFixture : public GlobalIoFixture { 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); }