core+face: avoid deprecated Boost.Asio interfaces
Change-Id: I07ec286531edf63f258babe1561b4da2a88edd10
diff --git a/daemon/face/stream-transport.hpp b/daemon/face/stream-transport.hpp
index c8b0ac3..dcb5265 100644
--- a/daemon/face/stream-transport.hpp
+++ b/daemon/face/stream-transport.hpp
@@ -145,7 +145,7 @@
// Use the non-throwing variants and ignore errors, if any.
boost::system::error_code error;
m_socket.cancel(error);
- m_socket.shutdown(protocol::socket::shutdown_both, error);
+ m_socket.shutdown(boost::asio::socket_base::shutdown_both, error);
}
// Ensure that the Transport stays alive at least until
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index e3c9910..17f2786 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-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,
@@ -52,7 +52,7 @@
void
TcpChannel::listen(const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onAcceptFailed,
- int backlog/* = tcp::acceptor::max_connections*/)
+ int backlog)
{
if (isListening()) {
NFD_LOG_CHAN_WARN("Already listening");
@@ -150,7 +150,7 @@
NFD_LOG_CHAN_TRACE("Reusing existing face for " << remoteEndpoint);
boost::system::error_code error;
- socket.shutdown(ip::tcp::socket::shutdown_both, error);
+ socket.shutdown(boost::asio::socket_base::shutdown_both, error);
socket.close(error);
}
diff --git a/daemon/face/tcp-channel.hpp b/daemon/face/tcp-channel.hpp
index 811ee5e..1220687 100644
--- a/daemon/face/tcp-channel.hpp
+++ b/daemon/face/tcp-channel.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,
@@ -40,20 +40,19 @@
const boost::asio::ip::address& remote)>;
/**
- * \brief Class implementing TCP-based channel to create faces
+ * \brief Class implementing a TCP-based channel to create faces.
*
- * Channel can create faces as a response to incoming TCP
- * connections (TcpChannel::listen needs to be called for that
- * to work) or explicitly after using TcpChannel::connect method.
+ * The channel can create faces as a response to incoming TCP connections (TcpChannel::listen()
+ * needs to be called for that to work) or explicitly by using TcpChannel::connect().
*/
class TcpChannel final : public Channel
{
public:
/**
- * \brief Create TCP channel for the local endpoint
+ * \brief Create a TCP channel for the specified \p localEndpoint.
*
- * To enable creation faces upon incoming connections,
- * one needs to explicitly call TcpChannel::listen method.
+ * To enable the creation of faces upon incoming connections, one needs to
+ * explicitly call listen().
*/
TcpChannel(const tcp::Endpoint& localEndpoint, bool wantCongestionMarking,
DetermineFaceScopeFromAddress determineFaceScope);
@@ -72,7 +71,7 @@
/**
* \brief Enable listening on the local endpoint, accept connections,
- * and create faces when remote host makes a connection
+ * and create faces when remote host makes a connection.
* \param onFaceCreated Callback to notify successful creation of the face
* \param onAcceptFailed Callback to notify when channel fails (accept call
* returns an error)
@@ -82,10 +81,10 @@
void
listen(const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onAcceptFailed,
- int backlog = boost::asio::ip::tcp::acceptor::max_connections);
+ int backlog = boost::asio::socket_base::max_listen_connections);
/**
- * \brief Create a face by establishing a TCP connection to \p remoteEndpoint
+ * \brief Create a face by establishing a TCP connection to \p remoteEndpoint.
*/
void
connect(const tcp::Endpoint& remoteEndpoint,
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index 1d25419..09d2cd4 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.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,
@@ -163,7 +163,7 @@
return;
}
- tcp::Endpoint endpoint(ip::address::from_string(req.remoteUri.getHost()),
+ tcp::Endpoint endpoint(ip::make_address(req.remoteUri.getHost()),
boost::lexical_cast<uint16_t>(req.remoteUri.getPort()));
// a canonical tcp4/tcp6 FaceUri cannot have a multicast address
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index fafa29e..c4baac2 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.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,
@@ -129,7 +129,7 @@
else if (key == "mcast_group") {
const std::string& valueStr = value.get_value<std::string>();
boost::system::error_code ec;
- mcastConfig.group.address(ip::address_v4::from_string(valueStr, ec));
+ mcastConfig.group.address(ip::make_address_v4(valueStr, ec));
if (ec) {
NDN_THROW(ConfigFile::Error("face_system.udp.mcast_group: '" +
valueStr + "' cannot be parsed as an IPv4 address"));
@@ -145,7 +145,7 @@
else if (key == "mcast_group_v6") {
const std::string& valueStr = value.get_value<std::string>();
boost::system::error_code ec;
- mcastConfig.groupV6.address(ip::address_v6::from_string(valueStr, ec));
+ mcastConfig.groupV6.address(ip::make_address_v6(valueStr, ec));
if (ec) {
NDN_THROW(ConfigFile::Error("face_system.udp.mcast_group_v6: '" +
valueStr + "' cannot be parsed as an IPv6 address"));
@@ -261,7 +261,7 @@
return;
}
- udp::Endpoint endpoint(ip::address::from_string(req.remoteUri.getHost()),
+ udp::Endpoint endpoint(ip::make_address(req.remoteUri.getHost()),
boost::lexical_cast<uint16_t>(req.remoteUri.getPort()));
if (endpoint.address().is_multicast()) {
diff --git a/daemon/face/udp-protocol.hpp b/daemon/face/udp-protocol.hpp
index 5f00b00..1004c3c 100644
--- a/daemon/face/udp-protocol.hpp
+++ b/daemon/face/udp-protocol.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,
@@ -46,7 +46,7 @@
inline Endpoint
getDefaultMulticastGroup()
{
- return {boost::asio::ip::address_v4(0xE00017AA), 56363};
+ return {boost::asio::ip::make_address_v4(0xE00017AA), 56363};
}
/**
@@ -55,7 +55,7 @@
inline Endpoint
getDefaultMulticastGroupV6()
{
- return {boost::asio::ip::address_v6::from_string("FF02::1234"), 56363};
+ return {boost::asio::ip::make_address_v6("FF02::1234"), 56363};
}
} // namespace nfd::udp
diff --git a/daemon/face/unix-stream-channel.cpp b/daemon/face/unix-stream-channel.cpp
index 2526d45..b2bb84a 100644
--- a/daemon/face/unix-stream-channel.cpp
+++ b/daemon/face/unix-stream-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,
@@ -63,7 +63,7 @@
void
UnixStreamChannel::listen(const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onAcceptFailed,
- int backlog/* = acceptor::max_connections*/)
+ int backlog)
{
if (isListening()) {
NFD_LOG_CHAN_WARN("Already listening");
diff --git a/daemon/face/unix-stream-channel.hpp b/daemon/face/unix-stream-channel.hpp
index b0fdf2c..705d6f8 100644
--- a/daemon/face/unix-stream-channel.hpp
+++ b/daemon/face/unix-stream-channel.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,
@@ -37,16 +37,16 @@
namespace nfd::face {
/**
- * \brief Class implementing a local channel to create faces
+ * \brief Class implementing a local channel to create faces.
*
* Channel can create faces as a response to incoming IPC connections
- * (UnixStreamChannel::listen needs to be called for that to work).
+ * (UnixStreamChannel::listen() needs to be called for that to work).
*/
class UnixStreamChannel final : public Channel
{
public:
/**
- * \brief UnixStreamChannel-related error
+ * \brief UnixStreamChannel-related error.
*/
class Error : public std::runtime_error
{
@@ -55,10 +55,10 @@
};
/**
- * \brief Create UnixStream channel for the specified endpoint
+ * \brief Create a UnixStream channel for the specified \p endpoint.
*
- * To enable creation of faces upon incoming connections, one
- * needs to explicitly call UnixStreamChannel::listen method.
+ * To enable the creation of faces upon incoming connections, one needs to
+ * explicitly call listen().
*/
UnixStreamChannel(const unix_stream::Endpoint& endpoint, bool wantCongestionMarking);
@@ -77,7 +77,7 @@
}
/**
- * \brief Start listening
+ * \brief Start listening.
*
* Enable listening on the Unix socket, waiting for incoming connections,
* and creating a face when a connection is made.
@@ -94,7 +94,7 @@
void
listen(const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onAcceptFailed,
- int backlog = boost::asio::local::stream_protocol::acceptor::max_connections);
+ int backlog = boost::asio::socket_base::max_listen_connections);
private:
void
diff --git a/daemon/face/websocket-transport.cpp b/daemon/face/websocket-transport.cpp
index df7b36b..8862b0f 100644
--- a/daemon/face/websocket-transport.cpp
+++ b/daemon/face/websocket-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,12 +36,13 @@
if (addr.is_loopback()) {
return true;
}
+
// Workaround for loopback IPv4-mapped IPv6 addresses
// see https://svn.boost.org/trac/boost/ticket/9084
- else if (addr.is_v6()) {
+ if (addr.is_v6()) {
auto addr6 = addr.to_v6();
if (addr6.is_v4_mapped()) {
- return addr6.to_v4().is_loopback();
+ return boost::asio::ip::make_address_v4(boost::asio::ip::v4_mapped, addr6).is_loopback();
}
}