Origin: https://github.com/isc-projects/kea/pull/143/
Date: 2025-02-09
Description: Fix build issue of Kea when boost version 1.87 (or higher)
is installed. The build failes as some deprecated definitions
are finally gone.
The patch is from ISC for Key-2.7.x (devel series) but it
applies to 2.6.1, too.
From 6300b3c937f91042594cf0944a8ec358d5bed809 Mon Sep 17 00:00:00 2001
From: q66 <q66@chimera-linux.org>
Date: Sun, 15 Dec 2024 03:04:53 +0100
Subject: [PATCH] Update asiolink for boost 1.87
---
src/lib/asiolink/io_address.cc | 4 ++--
src/lib/asiolink/io_service.cc | 8 ++++----
src/lib/asiolink/tcp_endpoint.h | 2 +-
src/lib/asiolink/udp_endpoint.h | 2 +-
src/lib/asiolink/unix_domain_socket.cc | 16 ++++++++--------
src/lib/dhcp/iface_mgr.cc | 2 +-
6 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/lib/asiolink/io_address.cc b/src/lib/asiolink/io_address.cc
index 43459bfe5a..06b7d3d990 100644
a
|
b
|
IOAddress::Hash::operator()(const IOAddress &io_address) const {
|
37 | 37 | // because we'd like to throw our own exception on failure. |
38 | 38 | IOAddress::IOAddress(const std::string& address_str) { |
39 | 39 | boost::system::error_code err; |
40 | | asio_address_ = ip::address::from_string(address_str, err); |
| 40 | asio_address_ = ip::make_address(address_str, err); |
41 | 41 | if (err) { |
42 | 42 | isc_throw(IOError, "Failed to convert string to address '" |
43 | 43 | << address_str << "': " << err.message()); |
… |
… |
IOAddress::isV6Multicast() const {
|
116 | 116 | uint32_t |
117 | 117 | IOAddress::toUint32() const { |
118 | 118 | if (asio_address_.is_v4()) { |
119 | | return (asio_address_.to_v4().to_ulong()); |
| 119 | return (asio_address_.to_v4().to_uint()); |
120 | 120 | } else { |
121 | 121 | isc_throw(BadValue, "Can't convert " << toText() |
122 | 122 | << " address to IPv4."); |
diff --git a/src/lib/asiolink/io_service.cc b/src/lib/asiolink/io_service.cc
index 411de64191..cc28d24c19 100644
a
|
b
|
class IOServiceImpl {
|
30 | 30 | /// @brief The constructor. |
31 | 31 | IOServiceImpl() : |
32 | 32 | io_service_(), |
33 | | work_(new boost::asio::io_service::work(io_service_)) { |
| 33 | work_(boost::asio::make_work_guard(io_service_)) { |
34 | 34 | }; |
35 | 35 | |
36 | 36 | /// @brief The destructor. |
… |
… |
class IOServiceImpl {
|
92 | 92 | |
93 | 93 | /// @brief Restarts the IOService in preparation for a subsequent @ref run() invocation. |
94 | 94 | void restart() { |
95 | | io_service_.reset(); |
| 95 | io_service_.restart(); |
96 | 96 | } |
97 | 97 | |
98 | 98 | /// @brief Removes IO service work object to let it finish running |
… |
… |
class IOServiceImpl {
|
115 | 115 | /// |
116 | 116 | /// @param callback The callback to be run on the IO service. |
117 | 117 | void post(const std::function<void ()>& callback) { |
118 | | io_service_.post(callback); |
| 118 | boost::asio::post(io_service_, callback); |
119 | 119 | } |
120 | 120 | |
121 | 121 | private: |
122 | 122 | boost::asio::io_service io_service_; |
123 | | boost::shared_ptr<boost::asio::io_service::work> work_; |
| 123 | boost::asio::executor_work_guard<boost::asio::io_service::executor_type> work_; |
124 | 124 | }; |
125 | 125 | |
126 | 126 | IOService::IOService() : io_impl_(new IOServiceImpl()) { |
diff --git a/src/lib/asiolink/tcp_endpoint.h b/src/lib/asiolink/tcp_endpoint.h
index 8ebd57551d..7c8cb35535 100644
a
|
b
|
class TCPEndpoint : public IOEndpoint {
|
42 | 42 | /// \param port The TCP port number of the endpoint. |
43 | 43 | TCPEndpoint(const IOAddress& address, const unsigned short port) : |
44 | 44 | asio_endpoint_placeholder_( |
45 | | new boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(address.toText()), |
| 45 | new boost::asio::ip::tcp::endpoint(boost::asio::ip::make_address(address.toText()), |
46 | 46 | port)), |
47 | 47 | asio_endpoint_(*asio_endpoint_placeholder_) |
48 | 48 | {} |
diff --git a/src/lib/asiolink/udp_endpoint.h b/src/lib/asiolink/udp_endpoint.h
index f960bf3ce9..2a3da9f046 100644
a
|
b
|
class UDPEndpoint : public IOEndpoint {
|
42 | 42 | /// \param port The UDP port number of the endpoint. |
43 | 43 | UDPEndpoint(const IOAddress& address, const unsigned short port) : |
44 | 44 | asio_endpoint_placeholder_( |
45 | | new boost::asio::ip::udp::endpoint(boost::asio::ip::address::from_string(address.toText()), |
| 45 | new boost::asio::ip::udp::endpoint(boost::asio::ip::make_address(address.toText()), |
46 | 46 | port)), |
47 | 47 | asio_endpoint_(*asio_endpoint_placeholder_) |
48 | 48 | {} |
diff --git a/src/lib/asiolink/unix_domain_socket.cc b/src/lib/asiolink/unix_domain_socket.cc
index f43e1c9e9b..43ff3c8f24 100644
a
|
b
|
class UnixDomainSocketImpl : public boost::enable_shared_from_this<UnixDomainSoc
|
83 | 83 | /// @param buffer Buffers holding the data to be sent. |
84 | 84 | /// @param handler User supplied callback to be invoked when data have |
85 | 85 | /// been sent or sending error is signalled. |
86 | | void doSend(const boost::asio::const_buffers_1& buffer, |
| 86 | void doSend(const boost::asio::const_buffer& buffer, |
87 | 87 | const UnixDomainSocket::Handler& handler); |
88 | 88 | |
89 | 89 | |
… |
… |
class UnixDomainSocketImpl : public boost::enable_shared_from_this<UnixDomainSoc
|
103 | 103 | /// @param ec Error code returned as a result of sending the data. |
104 | 104 | /// @param length Length of the data sent. |
105 | 105 | void sendHandler(const UnixDomainSocket::Handler& remote_handler, |
106 | | const boost::asio::const_buffers_1& buffer, |
| 106 | const boost::asio::const_buffer& buffer, |
107 | 107 | const boost::system::error_code& ec, |
108 | 108 | size_t length); |
109 | 109 | |
… |
… |
class UnixDomainSocketImpl : public boost::enable_shared_from_this<UnixDomainSoc
|
127 | 127 | /// @param buffer A buffer into which the data should be received. |
128 | 128 | /// @param handler User supplied callback invoked when data have been |
129 | 129 | /// received on an error is signalled. |
130 | | void doReceive(const boost::asio::mutable_buffers_1& buffer, |
| 130 | void doReceive(const boost::asio::mutable_buffer& buffer, |
131 | 131 | const UnixDomainSocket::Handler& handler); |
132 | 132 | |
133 | 133 | /// @brief Local handler invoked as a result of asynchronous receive. |
… |
… |
class UnixDomainSocketImpl : public boost::enable_shared_from_this<UnixDomainSoc
|
146 | 146 | /// @param ec Error code returned as a result of asynchronous receive. |
147 | 147 | /// @param length Size of the received data. |
148 | 148 | void receiveHandler(const UnixDomainSocket::Handler& remote_handler, |
149 | | const boost::asio::mutable_buffers_1& buffer, |
| 149 | const boost::asio::mutable_buffer& buffer, |
150 | 150 | const boost::system::error_code& ec, |
151 | 151 | size_t length); |
152 | 152 | |
… |
… |
UnixDomainSocketImpl::asyncSend(const void* data, const size_t length,
|
197 | 197 | } |
198 | 198 | |
199 | 199 | void |
200 | | UnixDomainSocketImpl::doSend(const boost::asio::const_buffers_1& buffer, |
| 200 | UnixDomainSocketImpl::doSend(const boost::asio::const_buffer& buffer, |
201 | 201 | const UnixDomainSocket::Handler& handler) { |
202 | 202 | auto local_handler = std::bind(&UnixDomainSocketImpl::sendHandler, |
203 | 203 | shared_from_this(), |
… |
… |
UnixDomainSocketImpl::doSend(const boost::asio::const_buffers_1& buffer,
|
207 | 207 | |
208 | 208 | void |
209 | 209 | UnixDomainSocketImpl::sendHandler(const UnixDomainSocket::Handler& remote_handler, |
210 | | const boost::asio::const_buffers_1& buffer, |
| 210 | const boost::asio::const_buffer& buffer, |
211 | 211 | const boost::system::error_code& ec, |
212 | 212 | size_t length) { |
213 | 213 | // The asynchronous send may return EWOULDBLOCK or EAGAIN on some |
… |
… |
UnixDomainSocketImpl::asyncReceive(void* data, const size_t length,
|
230 | 230 | } |
231 | 231 | |
232 | 232 | void |
233 | | UnixDomainSocketImpl::doReceive(const boost::asio::mutable_buffers_1& buffer, |
| 233 | UnixDomainSocketImpl::doReceive(const boost::asio::mutable_buffer& buffer, |
234 | 234 | const UnixDomainSocket::Handler& handler) { |
235 | 235 | auto local_handler = std::bind(&UnixDomainSocketImpl::receiveHandler, |
236 | 236 | shared_from_this(), |
… |
… |
UnixDomainSocketImpl::doReceive(const boost::asio::mutable_buffers_1& buffer,
|
240 | 240 | |
241 | 241 | void |
242 | 242 | UnixDomainSocketImpl::receiveHandler(const UnixDomainSocket::Handler& remote_handler, |
243 | | const boost::asio::mutable_buffers_1& buffer, |
| 243 | const boost::asio::mutable_buffer& buffer, |
244 | 244 | const boost::system::error_code& ec, |
245 | 245 | size_t length) { |
246 | 246 | // The asynchronous receive may return EWOULDBLOCK or EAGAIN on some |
diff --git a/src/lib/dhcp/iface_mgr.cc b/src/lib/dhcp/iface_mgr.cc
index 01a1d63da5..419268bfe5 100644
a
|
b
|
IfaceMgr::getLocalAddress(const IOAddress& remote_addr, const uint16_t port) {
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | // Create socket that will be used to connect to remote endpoint. |
1037 | | boost::asio::io_service io_service; |
| 1037 | boost::asio::io_context io_service; |
1038 | 1038 | boost::asio::ip::udp::socket sock(io_service); |
1039 | 1039 | |
1040 | 1040 | boost::system::error_code err_code; |