include/boost/corosio/native/detail/io_uring/io_uring_buffer.hpp

100.0% Lines (8/8) 100.0% List of functions (4/4)
io_uring_buffer.hpp
f(x) Functions (4)
Line TLA Hits Source Code
1 //
2 // Copyright (c) 2026 Steve Gerbino
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/cppalliance/corosio
8 //
9
10 #ifndef BOOST_COROSIO_NATIVE_DETAIL_IO_URING_IO_URING_BUFFER_HPP
11 #define BOOST_COROSIO_NATIVE_DETAIL_IO_URING_IO_URING_BUFFER_HPP
12
13 #include <boost/corosio/detail/platform.hpp>
14
15 #if BOOST_COROSIO_HAS_IO_URING
16
17 #include <boost/corosio/local_endpoint.hpp>
18 #include <boost/corosio/native/detail/endpoint_convert.hpp>
19
20 namespace boost::corosio::detail {
21
22 /** Convert a corosio::endpoint to a sockaddr_storage.
23
24 Fills `out` with the appropriate sockaddr_in (IPv4) or sockaddr_in6
25 (IPv6) representation, with all fields in network byte order.
26
27 @param ep The endpoint to convert.
28 @param out Destination storage; zeroed then written.
29 @return The actual address length written into `out`
30 (`sizeof(sockaddr_in)` or `sizeof(sockaddr_in6)`).
31 */
32 inline socklen_t
33 137x endpoint_to_sockaddr(endpoint const& ep, sockaddr_storage& out) noexcept
34 {
35 137x return to_sockaddr(ep, out);
36 }
37
38 /// Convert a corosio::local_endpoint to a sockaddr_storage.
39 inline socklen_t
40 38x endpoint_to_sockaddr(corosio::local_endpoint const& ep, sockaddr_storage& out) noexcept
41 {
42 38x return to_sockaddr(ep, out);
43 }
44
45 /** Convert a sockaddr_storage to a corosio::endpoint.
46
47 Dispatches on `sa.ss_family`; returns a default-constructed
48 endpoint for any family other than `AF_INET` or `AF_INET6`.
49
50 @param sa The sockaddr_storage in network byte order.
51 @return The reconstructed endpoint.
52 */
53 inline endpoint
54 8037x sockaddr_to_endpoint(sockaddr_storage const& sa) noexcept
55 {
56 8037x return from_sockaddr(sa);
57 }
58
59 /// Convert a sockaddr_storage to a corosio::local_endpoint.
60 inline corosio::local_endpoint
61 119x sockaddr_to_local_endpoint(
62 sockaddr_storage const& sa, socklen_t len) noexcept
63 {
64 119x return from_sockaddr_local(sa, len);
65 }
66
67 } // namespace boost::corosio::detail
68
69 #endif // BOOST_COROSIO_HAS_IO_URING
70
71 #endif // BOOST_COROSIO_NATIVE_DETAIL_IO_URING_IO_URING_BUFFER_HPP
72