From 39a1608d17e3be7b64ffcad19d46647519229ff3 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Tue, 16 Sep 2025 13:21:42 +0200 Subject: [PATCH 01/20] :sparkles: Initial IP multicast support --- include/asyncpp/io/detail/io_engine.h | 5 ++ include/asyncpp/io/socket.h | 9 +- src/io_engine_generic_unix.cpp | 110 ++++++++++++++++++++++++- src/io_engine_generic_unix.h | 8 ++ src/io_engine_iocp.cpp | 114 +++++++++++++++++++++++++- src/socket.cpp | 37 +++++++++ 6 files changed, 279 insertions(+), 4 deletions(-) diff --git a/include/asyncpp/io/detail/io_engine.h b/include/asyncpp/io/detail/io_engine.h index eec102c..c21014e 100644 --- a/include/asyncpp/io/detail/io_engine.h +++ b/include/asyncpp/io/detail/io_engine.h @@ -79,6 +79,11 @@ namespace asyncpp::io::detail { virtual endpoint socket_local_endpoint(socket_handle_t socket) = 0; virtual endpoint socket_remote_endpoint(socket_handle_t socket) = 0; virtual void socket_enable_broadcast(socket_handle_t socket, bool enable) = 0; + virtual void socket_multicast_join(socket_handle_t socket, address group, address interface) = 0; + virtual void socket_multicast_drop(socket_handle_t socket, address group, address interface) = 0; + virtual void socket_multicast_set_send_interface(socket_handle_t socket, address interface) = 0; + virtual void socket_multicast_set_ttl(socket_handle_t socket, size_t ttl) = 0; + virtual void socket_multicast_set_loopback(socket_handle_t socket, bool enabled) = 0; virtual void socket_shutdown(socket_handle_t socket, bool receive, bool send) = 0; virtual bool enqueue_connect(socket_handle_t socket, endpoint ep, completion_data* cd) = 0; virtual bool enqueue_accept(socket_handle_t socket, completion_data* cd) = 0; diff --git a/include/asyncpp/io/socket.h b/include/asyncpp/io/socket.h index da2034c..b61700d 100644 --- a/include/asyncpp/io/socket.h +++ b/include/asyncpp/io/socket.h @@ -97,6 +97,13 @@ namespace asyncpp::io { void listen(std::uint32_t backlog = 0); void allow_broadcast(bool enable); + void multicast_join(address group, address interface); + void multicast_join(address group); + void multicast_drop(address group, address interface); + void multicast_drop(address group); + void multicast_set_send_interface(address interface); + void multicast_set_ttl(size_t ttl); + void multicast_set_loopback(bool enabled); [[nodiscard]] detail::io_engine::socket_handle_t native_handle() const noexcept { return m_fd; } [[nodiscard]] detail::io_engine::socket_handle_t release() noexcept { @@ -620,7 +627,7 @@ namespace asyncpp::io { if (that->result) that->real_cb(that->result); else - that->real_cb(socket::from_fd(that->service(), that->result_handle)); + that->real_cb(socket::from_fd(that->service, that->result_handle)); delete that; }; diff --git a/src/io_engine_generic_unix.cpp b/src/io_engine_generic_unix.cpp index 2886aee..c5bd540 100644 --- a/src/io_engine_generic_unix.cpp +++ b/src/io_engine_generic_unix.cpp @@ -137,6 +137,99 @@ namespace asyncpp::io::detail { if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); } + void io_engine_generic_unix::socket_multicast_join(socket_handle_t socket, address group, address interface) { + if (group.type() != interface.type()) + throw std::system_error(std::make_error_code(std::errc::invalid_argument), + "group and interface need to be of the same type"); + if (group.is_ipv4()) { + struct ip_mreq mc_req{}; + mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; + mc_req.imr_interface = interface.ipv4().to_sockaddr_in().first.sin_addr; + auto res = setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mc_req, sizeof(mc_req)); + if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); + } else if (group.is_ipv6()) { + struct ipv6_mreq mc_req{}; + mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; + mc_req.ipv6mr_interface = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mc_req, sizeof(mc_req)); + if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); + } else { + throw std::system_error(std::make_error_code(std::errc::not_supported), + "multicast is only supported on IPv4/IPv6"); + } + } + + void io_engine_generic_unix::socket_multicast_drop(socket_handle_t socket, address group, address interface) { + if (group.type() != interface.type()) + throw std::system_error(std::make_error_code(std::errc::invalid_argument), + "group and interface need to be of the same type"); + if (group.is_ipv4()) { + struct ip_mreq mc_req{}; + mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; + mc_req.imr_interface = interface.ipv4().to_sockaddr_in().first.sin_addr; + auto res = setsockopt(socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mc_req, sizeof(mc_req)); + if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); + } else if (group.is_ipv6()) { + struct ipv6_mreq mc_req{}; + mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; + mc_req.ipv6mr_interface = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mc_req, sizeof(mc_req)); + if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); + } else { + throw std::system_error(std::make_error_code(std::errc::not_supported), + "multicast is only supported on IPv4/IPv6"); + } + } + + void io_engine_generic_unix::socket_multicast_set_send_interface(socket_handle_t socket, address interface) { + if (interface.is_ipv4()) { + auto addr = interface.ipv4().to_sockaddr_in().first.sin_addr.s_addr; + auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, reinterpret_cast(&addr), sizeof(addr)); + if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); + } else if (interface.is_ipv6()) { + auto scope = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + auto res = + setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, reinterpret_cast(&scope), sizeof(scope)); + if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); + } else { + throw std::system_error(std::make_error_code(std::errc::not_supported), + "multicast is only supported on IPv4/IPv6"); + } + } + + void io_engine_generic_unix::socket_multicast_set_ttl(socket_handle_t socket, size_t ttl) { + auto type = get_handle_type(socket); + if (ttl > std::numeric_limits::max()) throw std::invalid_argument("ttl value out of range"); + int ittl = ttl; + if (type == address_type::ipv4) { + auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, reinterpret_cast(&ittl), sizeof(ittl)); + if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); + } else if (type == address_type::ipv6) { + auto res = + setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, reinterpret_cast(&ittl), sizeof(ittl)); + if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); + } else { + throw std::system_error(std::make_error_code(std::errc::not_supported), + "multicast is only supported on IPv4/IPv6"); + } + } + + void io_engine_generic_unix::socket_multicast_set_loopback(socket_handle_t socket, bool enabled) { + auto type = get_handle_type(socket); + int val = enabled ? 1 : 0; + if (type == address_type::ipv4) { + auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_LOOP, reinterpret_cast(&val), sizeof(val)); + if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); + } else if (type == address_type::ipv6) { + auto res = + setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, reinterpret_cast(&val), sizeof(val)); + if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); + } else { + throw std::system_error(std::make_error_code(std::errc::not_supported), + "multicast is only supported on IPv4/IPv6"); + } + } + void io_engine_generic_unix::socket_shutdown(socket_handle_t socket, bool receive, bool send) { int mode = 0; if (receive && send) @@ -151,6 +244,19 @@ namespace asyncpp::io::detail { if (res < 0 && errno != ENOTCONN) throw std::system_error(errno, std::system_category(), "shutdown failed"); } + address_type io_engine_generic_unix::get_handle_type(socket_handle_t socket) { + int type = -1; + socklen_t length = sizeof(int); + auto res = getsockopt(socket, SOL_SOCKET, SO_TYPE, &type, &length); + if (res < 0) throw std::system_error(errno, std::system_category(), "getsockopt failed"); + switch (type) { + case AF_INET: return address_type::ipv4; + case AF_INET6: return address_type::ipv6; + case AF_UNIX: return address_type::uds; + default: throw std::logic_error("unknown socket type"); + } + } + io_engine::file_handle_t io_engine_generic_unix::file_open(const char* filename, std::ios_base::openmode mode) { if ((mode & std::ios_base::ate) == std::ios_base::ate) throw std::logic_error("unsupported flag"); int m = 0; @@ -173,12 +279,12 @@ namespace asyncpp::io::detail { uint64_t io_engine_generic_unix::file_size(file_handle_t fd) { #ifdef __APPLE__ - struct stat info {}; + struct stat info{}; auto res = fstat(fd, &info); if (res < 0) throw std::system_error(errno, std::system_category()); return info.st_size; #else - struct stat64 info {}; + struct stat64 info{}; auto res = fstat64(fd, &info); if (res < 0) throw std::system_error(errno, std::system_category()); return info.st_size; diff --git a/src/io_engine_generic_unix.h b/src/io_engine_generic_unix.h index 3d4cb28..00ba381 100644 --- a/src/io_engine_generic_unix.h +++ b/src/io_engine_generic_unix.h @@ -14,12 +14,20 @@ namespace asyncpp::io::detail { endpoint socket_local_endpoint(socket_handle_t socket) override; endpoint socket_remote_endpoint(socket_handle_t socket) override; void socket_enable_broadcast(socket_handle_t socket, bool enable) override; + void socket_multicast_join(socket_handle_t socket, address group, address interface) override; + void socket_multicast_drop(socket_handle_t socket, address group, address interface) override; + void socket_multicast_set_send_interface(socket_handle_t socket, address interface) override; + void socket_multicast_set_ttl(socket_handle_t socket, size_t ttl) override; + void socket_multicast_set_loopback(socket_handle_t socket, bool enabled) override; void socket_shutdown(socket_handle_t socket, bool receive, bool send) override; file_handle_t file_open(const char* filename, std::ios_base::openmode mode) override; void file_close(file_handle_t fd) override; uint64_t file_size(file_handle_t fd) override; + protected: + address_type get_handle_type(socket_handle_t socket); + private: }; diff --git a/src/io_engine_iocp.cpp b/src/io_engine_iocp.cpp index c709f9b..7f40a7e 100644 --- a/src/io_engine_iocp.cpp +++ b/src/io_engine_iocp.cpp @@ -84,6 +84,11 @@ namespace asyncpp::io::detail { endpoint socket_local_endpoint(socket_handle_t socket) override; endpoint socket_remote_endpoint(socket_handle_t socket) override; void socket_enable_broadcast(socket_handle_t socket, bool enable) override; + void socket_multicast_join(socket_handle_t socket, address group, address interface) override; + void socket_multicast_drop(socket_handle_t socket, address group, address interface) override; + void socket_multicast_set_send_interface(socket_handle_t socket, address interface) override; + void socket_multicast_set_ttl(socket_handle_t socket, size_t ttl) override; + void socket_multicast_set_loopback(socket_handle_t socket, bool enabled) override; void socket_shutdown(socket_handle_t socket, bool receive, bool send) override; bool enqueue_connect(socket_handle_t socket, endpoint ep, completion_data* cd) override; bool enqueue_accept(socket_handle_t socket, completion_data* cd) override; @@ -109,6 +114,8 @@ namespace asyncpp::io::detail { private: HANDLE m_completion_port = INVALID_HANDLE_VALUE; std::atomic m_inflight_count{}; + + address_type get_handle_type(socket_handle_t socket); }; std::unique_ptr create_io_engine_iocp() { return std::make_unique(); } @@ -245,7 +252,7 @@ namespace asyncpp::io::detail { if (setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, (char*)&reuse, (socklen_t)sizeof(reuse)) == -1) close_and_throw("setsockopt", listener); - struct sockaddr_in inaddr {}; + struct sockaddr_in inaddr{}; inaddr.sin_family = AF_INET; inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); if (bind(listener, reinterpret_cast(&inaddr), sizeof(inaddr)) == SOCKET_ERROR) @@ -345,6 +352,99 @@ namespace asyncpp::io::detail { if (res == SOCKET_ERROR) throw std::system_error(WSAGetLastError(), std::system_category()); } + void io_engine_iocp::socket_multicast_join(socket_handle_t socket, address group, address interface) { + if (group.type() != interface.type()) + throw std::system_error(std::make_error_code(std::errc::invalid_argument), + "group and interface need to be of the same type"); + if (group.is_ipv4()) { + struct ip_mreq mc_req{}; + mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; + mc_req.imr_interface = interface.ipv4().to_sockaddr_in().first.sin_addr; + auto res = setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mc_req, sizeof(mc_req)); + if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); + } else if (group.is_ipv6()) { + struct ipv6_mreq mc_req{}; + mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; + mc_req.ipv6mr_interface = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mc_req, sizeof(mc_req)); + if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); + } else { + throw std::system_error(std::make_error_code(std::errc::not_supported), + "multicast is only supported on IPv4/IPv6"); + } + } + + void io_engine_iocp::socket_multicast_drop(socket_handle_t socket, address group, address interface) { + if (group.type() != interface.type()) + throw std::system_error(std::make_error_code(std::errc::invalid_argument), + "group and interface need to be of the same type"); + if (group.is_ipv4()) { + struct ip_mreq mc_req{}; + mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; + mc_req.imr_interface = interface.ipv4().to_sockaddr_in().first.sin_addr; + auto res = setsockopt(socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mc_req, sizeof(mc_req)); + if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); + } else if (group.is_ipv6()) { + struct ipv6_mreq mc_req{}; + mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; + mc_req.ipv6mr_interface = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mc_req, sizeof(mc_req)); + if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); + } else { + throw std::system_error(std::make_error_code(std::errc::not_supported), + "multicast is only supported on IPv4/IPv6"); + } + } + + void io_engine_iocp::socket_multicast_set_send_interface(socket_handle_t socket, address interface) { + if (interface.is_ipv4()) { + auto addr = interface.ipv4().to_sockaddr_in().first.sin_addr.s_addr; + auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, reinterpret_cast(&addr), sizeof(addr)); + if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); + } else if (interface.is_ipv6()) { + auto scope = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + auto res = + setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, reinterpret_cast(&scope), sizeof(scope)); + if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); + } else { + throw std::system_error(std::make_error_code(std::errc::not_supported), + "multicast is only supported on IPv4/IPv6"); + } + } + + void io_engine_iocp::socket_multicast_set_ttl(socket_handle_t socket, size_t ttl) { + auto type = get_handle_type(socket); + if (ttl > std::numeric_limits::max()) throw std::invalid_argument("ttl value out of range"); + int ittl = ttl; + if (type == address_type::ipv4) { + auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, reinterpret_cast(&ittl), sizeof(ittl)); + if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); + } else if (type == address_type::ipv6) { + auto res = + setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, reinterpret_cast(&ittl), sizeof(ittl)); + if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); + } else { + throw std::system_error(std::make_error_code(std::errc::not_supported), + "multicast is only supported on IPv4/IPv6"); + } + } + + void io_engine_iocp::socket_multicast_set_loopback(socket_handle_t socket, bool enabled) { + auto type = get_handle_type(socket); + int val = enabled ? 1 : 0; + if (type == address_type::ipv4) { + auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_LOOP, reinterpret_cast(&val), sizeof(val)); + if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); + } else if (type == address_type::ipv6) { + auto res = + setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, reinterpret_cast(&val), sizeof(val)); + if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); + } else { + throw std::system_error(std::make_error_code(std::errc::not_supported), + "multicast is only supported on IPv4/IPv6"); + } + } + void io_engine_iocp::socket_shutdown(socket_handle_t socket, bool receive, bool send) { int mode = 0; if (receive && send) @@ -532,6 +632,18 @@ namespace asyncpp::io::detail { } } + address_type io_engine_iocp::get_handle_type(socket_handle_t socket) { + WSAPROTOCOL_INFO info{}; + socklen_t length = sizeof(info); + auto res = getsockopt(socket, SOL_SOCKET, SO_PROTOCOL_INFO, &info, &length); + if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "getsockopt failed"); + switch (info.iAddressFamily) { + case AF_INET: return address_type::ipv4; + case AF_INET6: return address_type::ipv6; + default: throw std::logic_error("unknown socket type"); + } + } + io_engine::file_handle_t io_engine_iocp::file_open(const char* filename, std::ios_base::openmode mode) { DWORD access_mode = 0; if ((mode & std::ios_base::in) == std::ios_base::in) access_mode |= GENERIC_READ; diff --git a/src/socket.cpp b/src/socket.cpp index 3ec52eb..184b7a7 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -110,6 +110,43 @@ namespace asyncpp::io { m_io->engine()->socket_enable_broadcast(m_fd, enable); } + void socket::multicast_join(address group, address interface) { + if (m_fd == detail::io_engine::invalid_socket_handle) throw std::logic_error("invalid socket"); + if (group.type() != interface.type()) throw std::logic_error("group and interface need to be of the same type"); + m_io->engine()->socket_multicast_join(m_fd, group, interface); + } + + void socket::multicast_join(address group) { + auto iface = group.type() == address_type::ipv4 ? address{ipv4_address::any()} : address{ipv6_address::any()}; + return multicast_join(group, iface); + } + + void socket::multicast_drop(address group, address interface) { + if (m_fd == detail::io_engine::invalid_socket_handle) throw std::logic_error("invalid socket"); + if (group.type() != interface.type()) throw std::logic_error("group and interface need to be of the same type"); + m_io->engine()->socket_multicast_drop(m_fd, group, interface); + } + + void socket::multicast_drop(address group) { + auto iface = group.type() == address_type::ipv4 ? address{ipv4_address::any()} : address{ipv6_address::any()}; + return multicast_drop(group, iface); + } + + void socket::multicast_set_send_interface(address interface) { + if (m_fd == detail::io_engine::invalid_socket_handle) throw std::logic_error("invalid socket"); + m_io->engine()->socket_multicast_set_send_interface(m_fd, interface); + } + + void socket::multicast_set_ttl(size_t ttl) { + if (m_fd == detail::io_engine::invalid_socket_handle) throw std::logic_error("invalid socket"); + m_io->engine()->socket_multicast_set_ttl(m_fd, ttl); + } + + void socket::multicast_set_loopback(bool enabled) { + if (m_fd == detail::io_engine::invalid_socket_handle) throw std::logic_error("invalid socket"); + m_io->engine()->socket_multicast_set_loopback(m_fd, enabled); + } + void socket::close_send() { if (m_fd == detail::io_engine::invalid_socket_handle) throw std::logic_error("invalid socket"); m_io->engine()->socket_shutdown(m_fd, false, true); From f159da4860e508742d46bbd38e7510c02c4de2ed Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Tue, 16 Sep 2025 13:34:47 +0200 Subject: [PATCH 02/20] :bug: Remove interface keyword --- include/asyncpp/io/detail/io_engine.h | 6 +++--- include/asyncpp/io/socket.h | 6 +++--- src/io_engine_generic_unix.cpp | 26 +++++++++++++------------- src/io_engine_generic_unix.h | 6 +++--- src/io_engine_iocp.cpp | 8 ++++---- src/io_engine_uring.cpp | 8 ++++++++ 6 files changed, 34 insertions(+), 26 deletions(-) diff --git a/include/asyncpp/io/detail/io_engine.h b/include/asyncpp/io/detail/io_engine.h index c21014e..d984868 100644 --- a/include/asyncpp/io/detail/io_engine.h +++ b/include/asyncpp/io/detail/io_engine.h @@ -79,9 +79,9 @@ namespace asyncpp::io::detail { virtual endpoint socket_local_endpoint(socket_handle_t socket) = 0; virtual endpoint socket_remote_endpoint(socket_handle_t socket) = 0; virtual void socket_enable_broadcast(socket_handle_t socket, bool enable) = 0; - virtual void socket_multicast_join(socket_handle_t socket, address group, address interface) = 0; - virtual void socket_multicast_drop(socket_handle_t socket, address group, address interface) = 0; - virtual void socket_multicast_set_send_interface(socket_handle_t socket, address interface) = 0; + virtual void socket_multicast_join(socket_handle_t socket, address group, address iface) = 0; + virtual void socket_multicast_drop(socket_handle_t socket, address group, address iface) = 0; + virtual void socket_multicast_set_send_interface(socket_handle_t socket, address iface) = 0; virtual void socket_multicast_set_ttl(socket_handle_t socket, size_t ttl) = 0; virtual void socket_multicast_set_loopback(socket_handle_t socket, bool enabled) = 0; virtual void socket_shutdown(socket_handle_t socket, bool receive, bool send) = 0; diff --git a/include/asyncpp/io/socket.h b/include/asyncpp/io/socket.h index b61700d..8115a88 100644 --- a/include/asyncpp/io/socket.h +++ b/include/asyncpp/io/socket.h @@ -97,11 +97,11 @@ namespace asyncpp::io { void listen(std::uint32_t backlog = 0); void allow_broadcast(bool enable); - void multicast_join(address group, address interface); + void multicast_join(address group, address iface); void multicast_join(address group); - void multicast_drop(address group, address interface); + void multicast_drop(address group, address iface); void multicast_drop(address group); - void multicast_set_send_interface(address interface); + void multicast_set_send_interface(address iface); void multicast_set_ttl(size_t ttl); void multicast_set_loopback(bool enabled); diff --git a/src/io_engine_generic_unix.cpp b/src/io_engine_generic_unix.cpp index c5bd540..5bf625b 100644 --- a/src/io_engine_generic_unix.cpp +++ b/src/io_engine_generic_unix.cpp @@ -137,20 +137,20 @@ namespace asyncpp::io::detail { if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); } - void io_engine_generic_unix::socket_multicast_join(socket_handle_t socket, address group, address interface) { - if (group.type() != interface.type()) + void io_engine_generic_unix::socket_multicast_join(socket_handle_t socket, address group, address iface) { + if (group.type() != iface.type()) throw std::system_error(std::make_error_code(std::errc::invalid_argument), "group and interface need to be of the same type"); if (group.is_ipv4()) { struct ip_mreq mc_req{}; mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; - mc_req.imr_interface = interface.ipv4().to_sockaddr_in().first.sin_addr; + mc_req.imr_interface = iface.ipv4().to_sockaddr_in().first.sin_addr; auto res = setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mc_req, sizeof(mc_req)); if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); } else if (group.is_ipv6()) { struct ipv6_mreq mc_req{}; mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; - mc_req.ipv6mr_interface = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + mc_req.ipv6mr_interface = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mc_req, sizeof(mc_req)); if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); } else { @@ -159,20 +159,20 @@ namespace asyncpp::io::detail { } } - void io_engine_generic_unix::socket_multicast_drop(socket_handle_t socket, address group, address interface) { - if (group.type() != interface.type()) + void io_engine_generic_unix::socket_multicast_drop(socket_handle_t socket, address group, address iface) { + if (group.type() != iface.type()) throw std::system_error(std::make_error_code(std::errc::invalid_argument), "group and interface need to be of the same type"); if (group.is_ipv4()) { struct ip_mreq mc_req{}; mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; - mc_req.imr_interface = interface.ipv4().to_sockaddr_in().first.sin_addr; + mc_req.imr_interface = iface.ipv4().to_sockaddr_in().first.sin_addr; auto res = setsockopt(socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mc_req, sizeof(mc_req)); if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); } else if (group.is_ipv6()) { struct ipv6_mreq mc_req{}; mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; - mc_req.ipv6mr_interface = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + mc_req.ipv6mr_interface = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mc_req, sizeof(mc_req)); if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); } else { @@ -181,13 +181,13 @@ namespace asyncpp::io::detail { } } - void io_engine_generic_unix::socket_multicast_set_send_interface(socket_handle_t socket, address interface) { - if (interface.is_ipv4()) { - auto addr = interface.ipv4().to_sockaddr_in().first.sin_addr.s_addr; + void io_engine_generic_unix::socket_multicast_set_send_interface(socket_handle_t socket, address iface) { + if (iface.is_ipv4()) { + auto addr = iface.ipv4().to_sockaddr_in().first.sin_addr.s_addr; auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, reinterpret_cast(&addr), sizeof(addr)); if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); - } else if (interface.is_ipv6()) { - auto scope = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + } else if (iface.is_ipv6()) { + auto scope = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, reinterpret_cast(&scope), sizeof(scope)); if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); diff --git a/src/io_engine_generic_unix.h b/src/io_engine_generic_unix.h index 00ba381..cadbcaf 100644 --- a/src/io_engine_generic_unix.h +++ b/src/io_engine_generic_unix.h @@ -14,9 +14,9 @@ namespace asyncpp::io::detail { endpoint socket_local_endpoint(socket_handle_t socket) override; endpoint socket_remote_endpoint(socket_handle_t socket) override; void socket_enable_broadcast(socket_handle_t socket, bool enable) override; - void socket_multicast_join(socket_handle_t socket, address group, address interface) override; - void socket_multicast_drop(socket_handle_t socket, address group, address interface) override; - void socket_multicast_set_send_interface(socket_handle_t socket, address interface) override; + void socket_multicast_join(socket_handle_t socket, address group, address iface) override; + void socket_multicast_drop(socket_handle_t socket, address group, address iface) override; + void socket_multicast_set_send_interface(socket_handle_t socket, address iface) override; void socket_multicast_set_ttl(socket_handle_t socket, size_t ttl) override; void socket_multicast_set_loopback(socket_handle_t socket, bool enabled) override; void socket_shutdown(socket_handle_t socket, bool receive, bool send) override; diff --git a/src/io_engine_iocp.cpp b/src/io_engine_iocp.cpp index 7f40a7e..cc0bc73 100644 --- a/src/io_engine_iocp.cpp +++ b/src/io_engine_iocp.cpp @@ -84,9 +84,9 @@ namespace asyncpp::io::detail { endpoint socket_local_endpoint(socket_handle_t socket) override; endpoint socket_remote_endpoint(socket_handle_t socket) override; void socket_enable_broadcast(socket_handle_t socket, bool enable) override; - void socket_multicast_join(socket_handle_t socket, address group, address interface) override; - void socket_multicast_drop(socket_handle_t socket, address group, address interface) override; - void socket_multicast_set_send_interface(socket_handle_t socket, address interface) override; + void socket_multicast_join(socket_handle_t socket, address group, address iface) override; + void socket_multicast_drop(socket_handle_t socket, address group, address iface) override; + void socket_multicast_set_send_interface(socket_handle_t socket, address iface) override; void socket_multicast_set_ttl(socket_handle_t socket, size_t ttl) override; void socket_multicast_set_loopback(socket_handle_t socket, bool enabled) override; void socket_shutdown(socket_handle_t socket, bool receive, bool send) override; @@ -635,7 +635,7 @@ namespace asyncpp::io::detail { address_type io_engine_iocp::get_handle_type(socket_handle_t socket) { WSAPROTOCOL_INFO info{}; socklen_t length = sizeof(info); - auto res = getsockopt(socket, SOL_SOCKET, SO_PROTOCOL_INFO, &info, &length); + auto res = getsockopt(socket, SOL_SOCKET, SO_PROTOCOL_INFO, reinterpret_cast(&info), &length); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "getsockopt failed"); switch (info.iAddressFamily) { case AF_INET: return address_type::ipv4; diff --git a/src/io_engine_uring.cpp b/src/io_engine_uring.cpp index 1dce978..dd97a57 100644 --- a/src/io_engine_uring.cpp +++ b/src/io_engine_uring.cpp @@ -17,6 +17,14 @@ namespace asyncpp::io::detail { #include #include +#ifndef __NR_io_uring_register +#ifdef __alpha__ +#define __NR_io_uring_register 537 +#else +#define __NR_io_uring_register 427 +#endif +#endif + namespace asyncpp::io::detail { class io_engine_uring : public io_engine_generic_unix { From ba763a52c770660c6119900b2d694ff5a696d972 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Tue, 16 Sep 2025 13:45:38 +0200 Subject: [PATCH 03/20] :bug: More renaming --- src/io_engine_iocp.cpp | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/io_engine_iocp.cpp b/src/io_engine_iocp.cpp index cc0bc73..b327247 100644 --- a/src/io_engine_iocp.cpp +++ b/src/io_engine_iocp.cpp @@ -352,21 +352,21 @@ namespace asyncpp::io::detail { if (res == SOCKET_ERROR) throw std::system_error(WSAGetLastError(), std::system_category()); } - void io_engine_iocp::socket_multicast_join(socket_handle_t socket, address group, address interface) { - if (group.type() != interface.type()) + void io_engine_iocp::socket_multicast_join(socket_handle_t socket, address group, address iface) { + if (group.type() != iface.type()) throw std::system_error(std::make_error_code(std::errc::invalid_argument), "group and interface need to be of the same type"); if (group.is_ipv4()) { struct ip_mreq mc_req{}; mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; - mc_req.imr_interface = interface.ipv4().to_sockaddr_in().first.sin_addr; - auto res = setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mc_req, sizeof(mc_req)); + mc_req.imr_interface = iface.ipv4().to_sockaddr_in().first.sin_addr; + auto res = setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, reinterpret_cast(&mc_req), sizeof(mc_req)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else if (group.is_ipv6()) { struct ipv6_mreq mc_req{}; mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; - mc_req.ipv6mr_interface = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; - auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mc_req, sizeof(mc_req)); + mc_req.ipv6mr_interface = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, reinterpret_cast(&mc_req), sizeof(mc_req)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else { throw std::system_error(std::make_error_code(std::errc::not_supported), @@ -374,21 +374,21 @@ namespace asyncpp::io::detail { } } - void io_engine_iocp::socket_multicast_drop(socket_handle_t socket, address group, address interface) { - if (group.type() != interface.type()) + void io_engine_iocp::socket_multicast_drop(socket_handle_t socket, address group, address iface) { + if (group.type() != iface.type()) throw std::system_error(std::make_error_code(std::errc::invalid_argument), "group and interface need to be of the same type"); if (group.is_ipv4()) { struct ip_mreq mc_req{}; mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; - mc_req.imr_interface = interface.ipv4().to_sockaddr_in().first.sin_addr; - auto res = setsockopt(socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mc_req, sizeof(mc_req)); + mc_req.imr_interface = iface.ipv4().to_sockaddr_in().first.sin_addr; + auto res = setsockopt(socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, reinterpret_cast(&mc_req), sizeof(mc_req)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else if (group.is_ipv6()) { struct ipv6_mreq mc_req{}; mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; - mc_req.ipv6mr_interface = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; - auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mc_req, sizeof(mc_req)); + mc_req.ipv6mr_interface = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, reinterpret_cast(&mc_req), sizeof(mc_req)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else { throw std::system_error(std::make_error_code(std::errc::not_supported), @@ -396,15 +396,15 @@ namespace asyncpp::io::detail { } } - void io_engine_iocp::socket_multicast_set_send_interface(socket_handle_t socket, address interface) { - if (interface.is_ipv4()) { - auto addr = interface.ipv4().to_sockaddr_in().first.sin_addr.s_addr; - auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, reinterpret_cast(&addr), sizeof(addr)); + void io_engine_iocp::socket_multicast_set_send_interface(socket_handle_t socket, address iface) { + if (iface.is_ipv4()) { + auto addr = iface.ipv4().to_sockaddr_in().first.sin_addr.s_addr; + auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, reinterpret_cast(&addr), sizeof(addr)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); - } else if (interface.is_ipv6()) { - auto scope = interface.ipv6().to_sockaddr_in6().first.sin6_scope_id; + } else if (iface.is_ipv6()) { + auto scope = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; auto res = - setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, reinterpret_cast(&scope), sizeof(scope)); + setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, reinterpret_cast(&scope), sizeof(scope)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else { throw std::system_error(std::make_error_code(std::errc::not_supported), @@ -417,11 +417,11 @@ namespace asyncpp::io::detail { if (ttl > std::numeric_limits::max()) throw std::invalid_argument("ttl value out of range"); int ittl = ttl; if (type == address_type::ipv4) { - auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, reinterpret_cast(&ittl), sizeof(ittl)); + auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, reinterpret_cast(&ittl), sizeof(ittl)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else if (type == address_type::ipv6) { auto res = - setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, reinterpret_cast(&ittl), sizeof(ittl)); + setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, reinterpret_cast(&ittl), sizeof(ittl)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else { throw std::system_error(std::make_error_code(std::errc::not_supported), @@ -433,11 +433,11 @@ namespace asyncpp::io::detail { auto type = get_handle_type(socket); int val = enabled ? 1 : 0; if (type == address_type::ipv4) { - auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_LOOP, reinterpret_cast(&val), sizeof(val)); + auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_LOOP, reinterpret_cast(&val), sizeof(val)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else if (type == address_type::ipv6) { auto res = - setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, reinterpret_cast(&val), sizeof(val)); + setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, reinterpret_cast(&val), sizeof(val)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else { throw std::system_error(std::make_error_code(std::errc::not_supported), From 82fa9b643ad47b29daff83abc6ae4b4ead6c383b Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Tue, 16 Sep 2025 13:50:10 +0200 Subject: [PATCH 04/20] :bug: Fixing windows max macro --- src/io_engine_iocp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io_engine_iocp.cpp b/src/io_engine_iocp.cpp index b327247..f373857 100644 --- a/src/io_engine_iocp.cpp +++ b/src/io_engine_iocp.cpp @@ -414,7 +414,7 @@ namespace asyncpp::io::detail { void io_engine_iocp::socket_multicast_set_ttl(socket_handle_t socket, size_t ttl) { auto type = get_handle_type(socket); - if (ttl > std::numeric_limits::max()) throw std::invalid_argument("ttl value out of range"); + if (ttl > (std::numeric_limits::max)()) throw std::invalid_argument("ttl value out of range"); int ittl = ttl; if (type == address_type::ipv4) { auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, reinterpret_cast(&ittl), sizeof(ittl)); From 58681abfd93358f907645736aa70fe6bfd513978 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 09:48:29 +0200 Subject: [PATCH 05/20] Testing macOS headers --- src/io_engine_generic_unix.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/io_engine_generic_unix.cpp b/src/io_engine_generic_unix.cpp index 5bf625b..402d4f7 100644 --- a/src/io_engine_generic_unix.cpp +++ b/src/io_engine_generic_unix.cpp @@ -11,6 +11,14 @@ #include #include +// Mac Testing +#include +#include +#include +#include +#include +#include + // Fixes for MUSL Libc that lacks *64_t types #ifndef __GLIBC__ #define off64_t off_t From b803719449dde1efa2421e35869135195122ea8d Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:00:03 +0200 Subject: [PATCH 06/20] macos testing --- .github/workflows/compiler-support.yml | 2 +- .github/workflows/macos-grep-headers.yml | 19 +++++++++++++++++++ src/io_engine_generic_unix.cpp | 8 -------- 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/macos-grep-headers.yml diff --git a/.github/workflows/compiler-support.yml b/.github/workflows/compiler-support.yml index 671b76e..697a046 100644 --- a/.github/workflows/compiler-support.yml +++ b/.github/workflows/compiler-support.yml @@ -3,7 +3,7 @@ name: Compiler Compatibility CI on: push: branches: [master] - pull_request: + #pull_request: jobs: build: diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml new file mode 100644 index 0000000..276d65f --- /dev/null +++ b/.github/workflows/macos-grep-headers.yml @@ -0,0 +1,19 @@ +name: Grep Mac headers + +on: + pull_request: + +jobs: + build: + runs-on: macos-15 + name: Find it + env: + CXX: /opt/homebrew/opt/llvm@18/bin/clang++ + CC: /opt/homebrew/opt/llvm@18/bin/clang + defaults: + run: + shell: bash -l {0} + steps: + - name: Print include paths + run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null + \ No newline at end of file diff --git a/src/io_engine_generic_unix.cpp b/src/io_engine_generic_unix.cpp index 402d4f7..5bf625b 100644 --- a/src/io_engine_generic_unix.cpp +++ b/src/io_engine_generic_unix.cpp @@ -11,14 +11,6 @@ #include #include -// Mac Testing -#include -#include -#include -#include -#include -#include - // Fixes for MUSL Libc that lacks *64_t types #ifndef __GLIBC__ #define off64_t off_t From 90d65be2f1ddfc14db51180341c23a6df232dad8 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:05:28 +0200 Subject: [PATCH 07/20] macos tampering --- .github/workflows/macos-grep-headers.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml index 276d65f..357bb8a 100644 --- a/.github/workflows/macos-grep-headers.yml +++ b/.github/workflows/macos-grep-headers.yml @@ -16,4 +16,12 @@ jobs: steps: - name: Print include paths run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null + - name: Grep /opt/homebrew/opt/llvm@18/bin/../include/c++/v1 + run: grep -rn -A 10 -B 10 "ip_mreq" /opt/homebrew/opt/llvm@18/bin/../include/c++/v1 + - name: Grep /opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include + run: grep -rn -A 10 -B 10 "ip_mreq" /opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include + - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include + run: grep -rn -A 10 -B 10 "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include + - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks + run: grep -rn -A 10 -B 10 "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks \ No newline at end of file From ab32d5c30d58e20ec6fd2d148abc2a594b7795f2 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:08:33 +0200 Subject: [PATCH 08/20] macos crap --- .github/workflows/macos-grep-headers.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml index 357bb8a..4cb6e33 100644 --- a/.github/workflows/macos-grep-headers.yml +++ b/.github/workflows/macos-grep-headers.yml @@ -16,12 +16,12 @@ jobs: steps: - name: Print include paths run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null - - name: Grep /opt/homebrew/opt/llvm@18/bin/../include/c++/v1 - run: grep -rn -A 10 -B 10 "ip_mreq" /opt/homebrew/opt/llvm@18/bin/../include/c++/v1 + - name: Grep /opt/homebrew/opt/llvm@18/include/c++/v1 + run: grep -r -A 10 -B 10 "ip_mreq" "/opt/homebrew/opt/llvm@18/include/c++/v1" - name: Grep /opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include - run: grep -rn -A 10 -B 10 "ip_mreq" /opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include + run: grep -r -A 10 -B 10 "ip_mreq" "/opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include" - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - run: grep -rn -A 10 -B 10 "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include + run: grep -r -A 10 -B 10 "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - run: grep -rn -A 10 -B 10 "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks + run: grep -r -A 10 -B 10 "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks \ No newline at end of file From 804c0dedcd7868d600245c40d5a7192e866dc787 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:10:07 +0200 Subject: [PATCH 09/20] 1234 --- .github/workflows/macos-grep-headers.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml index 4cb6e33..48ec14f 100644 --- a/.github/workflows/macos-grep-headers.yml +++ b/.github/workflows/macos-grep-headers.yml @@ -17,11 +17,11 @@ jobs: - name: Print include paths run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null - name: Grep /opt/homebrew/opt/llvm@18/include/c++/v1 - run: grep -r -A 10 -B 10 "ip_mreq" "/opt/homebrew/opt/llvm@18/include/c++/v1" + run: grep -r "ip_mreq" "/opt/homebrew/opt/llvm@18/include/c++/v1" - name: Grep /opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include - run: grep -r -A 10 -B 10 "ip_mreq" "/opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include" + run: grep -r "ip_mreq" "/opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include" - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - run: grep -r -A 10 -B 10 "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include + run: grep -r "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - run: grep -r -A 10 -B 10 "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks + run: grep -r "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks \ No newline at end of file From 92a0aebad5de27887ac70fc92d3d8d46427dab6d Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:11:11 +0200 Subject: [PATCH 10/20] fydkjfs --- .github/workflows/macos-grep-headers.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml index 48ec14f..3b8935f 100644 --- a/.github/workflows/macos-grep-headers.yml +++ b/.github/workflows/macos-grep-headers.yml @@ -16,6 +16,8 @@ jobs: steps: - name: Print include paths run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null + - name: Grep Random + run: grep - name: Grep /opt/homebrew/opt/llvm@18/include/c++/v1 run: grep -r "ip_mreq" "/opt/homebrew/opt/llvm@18/include/c++/v1" - name: Grep /opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include From 52e60d928acd2e19baf9d8366ae113b556e3dd5d Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:16:16 +0200 Subject: [PATCH 11/20] macos... --- .github/workflows/macos-grep-headers.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml index 3b8935f..fbb12f5 100644 --- a/.github/workflows/macos-grep-headers.yml +++ b/.github/workflows/macos-grep-headers.yml @@ -16,14 +16,11 @@ jobs: steps: - name: Print include paths run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null - - name: Grep Random - run: grep - name: Grep /opt/homebrew/opt/llvm@18/include/c++/v1 - run: grep -r "ip_mreq" "/opt/homebrew/opt/llvm@18/include/c++/v1" + run: grep -R "ip_mreq" "/opt/homebrew/opt/llvm@18/include/c++/v1" - name: Grep /opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include - run: grep -r "ip_mreq" "/opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include" + run: grep -R "ip_mreq" "/opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include" - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - run: grep -r "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include + run: grep -R "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - run: grep -r "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - \ No newline at end of file + run: grep -R "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks From 2dba78fb97324a7e40f3771e71caea13cd807c4e Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:22:01 +0200 Subject: [PATCH 12/20] macos... --- .github/workflows/macos-grep-headers.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml index fbb12f5..1982d5f 100644 --- a/.github/workflows/macos-grep-headers.yml +++ b/.github/workflows/macos-grep-headers.yml @@ -16,11 +16,16 @@ jobs: steps: - name: Print include paths run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null + - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include + if: always() + run: find /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include -type f -exec grep "ip_mreq" {} \; + #run: grep -R "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include + - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks + if: always() + run: grep -R "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - name: Grep /opt/homebrew/opt/llvm@18/include/c++/v1 + if: always() run: grep -R "ip_mreq" "/opt/homebrew/opt/llvm@18/include/c++/v1" - name: Grep /opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include + if: always() run: grep -R "ip_mreq" "/opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include" - - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - run: grep -R "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - run: grep -R "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks From 2249d94747c2e5390878f8712de8c7ef9c2eac6a Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:25:17 +0200 Subject: [PATCH 13/20] macos... --- .github/workflows/macos-grep-headers.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml index 1982d5f..eefdf46 100644 --- a/.github/workflows/macos-grep-headers.yml +++ b/.github/workflows/macos-grep-headers.yml @@ -18,14 +18,13 @@ jobs: run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include if: always() - run: find /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include -type f -exec grep "ip_mreq" {} \; - #run: grep -R "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include + run: grep -Rn "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks if: always() - run: grep -R "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks + run: grep -Rn "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - name: Grep /opt/homebrew/opt/llvm@18/include/c++/v1 if: always() - run: grep -R "ip_mreq" "/opt/homebrew/opt/llvm@18/include/c++/v1" + run: grep -Rn "ip_mreq" "/opt/homebrew/opt/llvm@18/include/c++/v1" - name: Grep /opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include if: always() - run: grep -R "ip_mreq" "/opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include" + run: grep -Rn "ip_mreq" "/opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include" From dc15ba2674ab3463623f7030e47d3cf5d7a694de Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:27:42 +0200 Subject: [PATCH 14/20] Yayyy macos --- .github/workflows/macos-grep-headers.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml index eefdf46..3ec3e0b 100644 --- a/.github/workflows/macos-grep-headers.yml +++ b/.github/workflows/macos-grep-headers.yml @@ -18,13 +18,10 @@ jobs: run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include if: always() - run: grep -Rn "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include + run: grep -Rn "IP_MULTICAST_IF" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks if: always() - run: grep -Rn "ip_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - - name: Grep /opt/homebrew/opt/llvm@18/include/c++/v1 + run: grep -Rn "IP_MULTICAST_IF" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks + - name: Cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet/in.h if: always() - run: grep -Rn "ip_mreq" "/opt/homebrew/opt/llvm@18/include/c++/v1" - - name: Grep /opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include - if: always() - run: grep -Rn "ip_mreq" "/opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include" + run: cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet/in.h From 28092a841db98fad6cddc915f70ffa15cf57e4a4 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:46:12 +0200 Subject: [PATCH 15/20] MacOS attempt --- .github/workflows/compiler-support.yml | 2 +- src/io_engine_generic_unix.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compiler-support.yml b/.github/workflows/compiler-support.yml index 697a046..671b76e 100644 --- a/.github/workflows/compiler-support.yml +++ b/.github/workflows/compiler-support.yml @@ -3,7 +3,7 @@ name: Compiler Compatibility CI on: push: branches: [master] - #pull_request: + pull_request: jobs: build: diff --git a/src/io_engine_generic_unix.cpp b/src/io_engine_generic_unix.cpp index 5bf625b..33e6dec 100644 --- a/src/io_engine_generic_unix.cpp +++ b/src/io_engine_generic_unix.cpp @@ -1,6 +1,10 @@ #ifndef _WIN32 #include "io_engine_generic_unix.h" +#ifdef __APPLE__ +#define _DARWIN_C_SOURCE +#endif + #include #include From 8fe87cfa3873831e11e0ef6ffa6b0f2f9023cfff Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:48:02 +0200 Subject: [PATCH 16/20] More symbol tampering --- .github/workflows/compiler-support.yml | 2 +- .github/workflows/macos-grep-headers.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compiler-support.yml b/.github/workflows/compiler-support.yml index 671b76e..697a046 100644 --- a/.github/workflows/compiler-support.yml +++ b/.github/workflows/compiler-support.yml @@ -3,7 +3,7 @@ name: Compiler Compatibility CI on: push: branches: [master] - pull_request: + #pull_request: jobs: build: diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml index 3ec3e0b..9e57a4c 100644 --- a/.github/workflows/macos-grep-headers.yml +++ b/.github/workflows/macos-grep-headers.yml @@ -18,10 +18,10 @@ jobs: run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include if: always() - run: grep -Rn "IP_MULTICAST_IF" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include + run: grep -Rn "IPV6_ADD_MEMBERSHIP" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks if: always() - run: grep -Rn "IP_MULTICAST_IF" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks + run: grep -Rn "IPV6_ADD_MEMBERSHIP" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - name: Cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet/in.h if: always() run: cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet/in.h From 7c91fac5fd3c86489500eee0b054fb576d84f822 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:51:18 +0200 Subject: [PATCH 17/20] macos --- .github/workflows/macos-grep-headers.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml index 9e57a4c..9e4dbc5 100644 --- a/.github/workflows/macos-grep-headers.yml +++ b/.github/workflows/macos-grep-headers.yml @@ -18,10 +18,10 @@ jobs: run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include if: always() - run: grep -Rn "IPV6_ADD_MEMBERSHIP" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include + run: grep -Rn "ipv6_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks if: always() - run: grep -Rn "IPV6_ADD_MEMBERSHIP" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks + run: grep -Rn "ipv6_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - name: Cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet/in.h if: always() run: cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet/in.h From 17a0c82d479a78f8ae97b653d78b9fee7ab82b66 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:52:34 +0200 Subject: [PATCH 18/20] new cat --- .github/workflows/macos-grep-headers.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml index 9e4dbc5..b98a60b 100644 --- a/.github/workflows/macos-grep-headers.yml +++ b/.github/workflows/macos-grep-headers.yml @@ -22,6 +22,6 @@ jobs: - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks if: always() run: grep -Rn "ipv6_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - - name: Cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet/in.h + - name: Cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet6/in6.h if: always() - run: cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet/in.h + run: cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet6/in6.h From f0a8ab343b4dc6498b159182e51c2078ab8bb532 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Sun, 21 Sep 2025 11:58:56 +0200 Subject: [PATCH 19/20] MacOS support ? --- .github/workflows/compiler-support.yml | 2 +- .github/workflows/macos-grep-headers.yml | 27 ------------------------ src/io_engine_generic_unix.cpp | 4 ++-- 3 files changed, 3 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/macos-grep-headers.yml diff --git a/.github/workflows/compiler-support.yml b/.github/workflows/compiler-support.yml index 697a046..671b76e 100644 --- a/.github/workflows/compiler-support.yml +++ b/.github/workflows/compiler-support.yml @@ -3,7 +3,7 @@ name: Compiler Compatibility CI on: push: branches: [master] - #pull_request: + pull_request: jobs: build: diff --git a/.github/workflows/macos-grep-headers.yml b/.github/workflows/macos-grep-headers.yml deleted file mode 100644 index b98a60b..0000000 --- a/.github/workflows/macos-grep-headers.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Grep Mac headers - -on: - pull_request: - -jobs: - build: - runs-on: macos-15 - name: Find it - env: - CXX: /opt/homebrew/opt/llvm@18/bin/clang++ - CC: /opt/homebrew/opt/llvm@18/bin/clang - defaults: - run: - shell: bash -l {0} - steps: - - name: Print include paths - run: /opt/homebrew/opt/llvm@18/bin/clang++ -E -x c++ - -v < /dev/null - - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - if: always() - run: grep -Rn "ipv6_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include - - name: Grep /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - if: always() - run: grep -Rn "ipv6_mreq" /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks - - name: Cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet6/in6.h - if: always() - run: cat /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/netinet6/in6.h diff --git a/src/io_engine_generic_unix.cpp b/src/io_engine_generic_unix.cpp index 33e6dec..b18bbe4 100644 --- a/src/io_engine_generic_unix.cpp +++ b/src/io_engine_generic_unix.cpp @@ -155,7 +155,7 @@ namespace asyncpp::io::detail { struct ipv6_mreq mc_req{}; mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; mc_req.ipv6mr_interface = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; - auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mc_req, sizeof(mc_req)); + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mc_req, sizeof(mc_req)); if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); } else { throw std::system_error(std::make_error_code(std::errc::not_supported), @@ -177,7 +177,7 @@ namespace asyncpp::io::detail { struct ipv6_mreq mc_req{}; mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; mc_req.ipv6mr_interface = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; - auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mc_req, sizeof(mc_req)); + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_LEAVE_GROUP, &mc_req, sizeof(mc_req)); if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); } else { throw std::system_error(std::make_error_code(std::errc::not_supported), From 405ba8cb55633546c1415b614a92f2afbc6f69b1 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Mon, 22 Sep 2025 14:51:12 +0200 Subject: [PATCH 20/20] :art: Fix format --- src/io_engine_generic_unix.cpp | 12 +++++------ src/io_engine_iocp.cpp | 39 ++++++++++++++++++++-------------- src/io_engine_uring.cpp | 4 ++-- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/io_engine_generic_unix.cpp b/src/io_engine_generic_unix.cpp index b18bbe4..61be121 100644 --- a/src/io_engine_generic_unix.cpp +++ b/src/io_engine_generic_unix.cpp @@ -146,13 +146,13 @@ namespace asyncpp::io::detail { throw std::system_error(std::make_error_code(std::errc::invalid_argument), "group and interface need to be of the same type"); if (group.is_ipv4()) { - struct ip_mreq mc_req{}; + struct ip_mreq mc_req {}; mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; mc_req.imr_interface = iface.ipv4().to_sockaddr_in().first.sin_addr; auto res = setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mc_req, sizeof(mc_req)); if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); } else if (group.is_ipv6()) { - struct ipv6_mreq mc_req{}; + struct ipv6_mreq mc_req {}; mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; mc_req.ipv6mr_interface = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mc_req, sizeof(mc_req)); @@ -168,13 +168,13 @@ namespace asyncpp::io::detail { throw std::system_error(std::make_error_code(std::errc::invalid_argument), "group and interface need to be of the same type"); if (group.is_ipv4()) { - struct ip_mreq mc_req{}; + struct ip_mreq mc_req {}; mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; mc_req.imr_interface = iface.ipv4().to_sockaddr_in().first.sin_addr; auto res = setsockopt(socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mc_req, sizeof(mc_req)); if (res < 0) throw std::system_error(errno, std::system_category(), "setsockopt failed"); } else if (group.is_ipv6()) { - struct ipv6_mreq mc_req{}; + struct ipv6_mreq mc_req {}; mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; mc_req.ipv6mr_interface = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_LEAVE_GROUP, &mc_req, sizeof(mc_req)); @@ -283,12 +283,12 @@ namespace asyncpp::io::detail { uint64_t io_engine_generic_unix::file_size(file_handle_t fd) { #ifdef __APPLE__ - struct stat info{}; + struct stat info {}; auto res = fstat(fd, &info); if (res < 0) throw std::system_error(errno, std::system_category()); return info.st_size; #else - struct stat64 info{}; + struct stat64 info {}; auto res = fstat64(fd, &info); if (res < 0) throw std::system_error(errno, std::system_category()); return info.st_size; diff --git a/src/io_engine_iocp.cpp b/src/io_engine_iocp.cpp index f373857..8b31707 100644 --- a/src/io_engine_iocp.cpp +++ b/src/io_engine_iocp.cpp @@ -252,7 +252,7 @@ namespace asyncpp::io::detail { if (setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, (char*)&reuse, (socklen_t)sizeof(reuse)) == -1) close_and_throw("setsockopt", listener); - struct sockaddr_in inaddr{}; + struct sockaddr_in inaddr {}; inaddr.sin_family = AF_INET; inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); if (bind(listener, reinterpret_cast(&inaddr), sizeof(inaddr)) == SOCKET_ERROR) @@ -357,16 +357,18 @@ namespace asyncpp::io::detail { throw std::system_error(std::make_error_code(std::errc::invalid_argument), "group and interface need to be of the same type"); if (group.is_ipv4()) { - struct ip_mreq mc_req{}; + struct ip_mreq mc_req {}; mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; mc_req.imr_interface = iface.ipv4().to_sockaddr_in().first.sin_addr; - auto res = setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, reinterpret_cast(&mc_req), sizeof(mc_req)); + auto res = setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, reinterpret_cast(&mc_req), + sizeof(mc_req)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else if (group.is_ipv6()) { - struct ipv6_mreq mc_req{}; + struct ipv6_mreq mc_req {}; mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; mc_req.ipv6mr_interface = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; - auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, reinterpret_cast(&mc_req), sizeof(mc_req)); + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, reinterpret_cast(&mc_req), + sizeof(mc_req)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else { throw std::system_error(std::make_error_code(std::errc::not_supported), @@ -379,16 +381,18 @@ namespace asyncpp::io::detail { throw std::system_error(std::make_error_code(std::errc::invalid_argument), "group and interface need to be of the same type"); if (group.is_ipv4()) { - struct ip_mreq mc_req{}; + struct ip_mreq mc_req {}; mc_req.imr_multiaddr = group.ipv4().to_sockaddr_in().first.sin_addr; mc_req.imr_interface = iface.ipv4().to_sockaddr_in().first.sin_addr; - auto res = setsockopt(socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, reinterpret_cast(&mc_req), sizeof(mc_req)); + auto res = setsockopt(socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, reinterpret_cast(&mc_req), + sizeof(mc_req)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else if (group.is_ipv6()) { - struct ipv6_mreq mc_req{}; + struct ipv6_mreq mc_req {}; mc_req.ipv6mr_multiaddr = group.ipv6().to_sockaddr_in6().first.sin6_addr; mc_req.ipv6mr_interface = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; - auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, reinterpret_cast(&mc_req), sizeof(mc_req)); + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, reinterpret_cast(&mc_req), + sizeof(mc_req)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else { throw std::system_error(std::make_error_code(std::errc::not_supported), @@ -399,12 +403,13 @@ namespace asyncpp::io::detail { void io_engine_iocp::socket_multicast_set_send_interface(socket_handle_t socket, address iface) { if (iface.is_ipv4()) { auto addr = iface.ipv4().to_sockaddr_in().first.sin_addr.s_addr; - auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, reinterpret_cast(&addr), sizeof(addr)); + auto res = + setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, reinterpret_cast(&addr), sizeof(addr)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else if (iface.is_ipv6()) { auto scope = iface.ipv6().to_sockaddr_in6().first.sin6_scope_id; - auto res = - setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, reinterpret_cast(&scope), sizeof(scope)); + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, reinterpret_cast(&scope), + sizeof(scope)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else { throw std::system_error(std::make_error_code(std::errc::not_supported), @@ -417,11 +422,12 @@ namespace asyncpp::io::detail { if (ttl > (std::numeric_limits::max)()) throw std::invalid_argument("ttl value out of range"); int ittl = ttl; if (type == address_type::ipv4) { - auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, reinterpret_cast(&ittl), sizeof(ittl)); + auto res = + setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, reinterpret_cast(&ittl), sizeof(ittl)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else if (type == address_type::ipv6) { - auto res = - setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, reinterpret_cast(&ittl), sizeof(ittl)); + auto res = setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, reinterpret_cast(&ittl), + sizeof(ittl)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else { throw std::system_error(std::make_error_code(std::errc::not_supported), @@ -433,7 +439,8 @@ namespace asyncpp::io::detail { auto type = get_handle_type(socket); int val = enabled ? 1 : 0; if (type == address_type::ipv4) { - auto res = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_LOOP, reinterpret_cast(&val), sizeof(val)); + auto res = + setsockopt(socket, IPPROTO_IP, IP_MULTICAST_LOOP, reinterpret_cast(&val), sizeof(val)); if (res < 0) throw std::system_error(WSAGetLastError(), std::system_category(), "setsockopt failed"); } else if (type == address_type::ipv6) { auto res = diff --git a/src/io_engine_uring.cpp b/src/io_engine_uring.cpp index dd97a57..fc204a7 100644 --- a/src/io_engine_uring.cpp +++ b/src/io_engine_uring.cpp @@ -19,9 +19,9 @@ namespace asyncpp::io::detail { #ifndef __NR_io_uring_register #ifdef __alpha__ -#define __NR_io_uring_register 537 +#define __NR_io_uring_register 537 #else -#define __NR_io_uring_register 427 +#define __NR_io_uring_register 427 #endif #endif