include/boost/corosio/native/detail/uring/uring_buffer.hpp

100.0% Lines (8/0/8) 100.0% List of functions (4/0/4)
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_URING_URING_BUFFER_HPP
11 #define BOOST_COROSIO_NATIVE_DETAIL_URING_URING_BUFFER_HPP
12
13 #include <boost/corosio/detail/platform.hpp>
14
15 #if BOOST_COROSIO_HAS_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 325x endpoint_to_sockaddr(endpoint const& ep, sockaddr_storage& out) noexcept
34 {
35 325x return to_sockaddr(ep, out);
36 }
37
38 /// Convert a corosio::local_endpoint to a sockaddr_storage.
39 inline socklen_t
40 152x endpoint_to_sockaddr(
41 corosio::local_endpoint const& ep, sockaddr_storage& out) noexcept
42 {
43 152x return to_sockaddr(ep, out);
44 }
45
46 /** Convert a sockaddr_storage to a corosio::endpoint.
47
48 Dispatches on `sa.ss_family`; returns a default-constructed
49 endpoint for any family other than `AF_INET` or `AF_INET6`.
50
51 @param sa The sockaddr_storage in network byte order.
52 @return The reconstructed endpoint.
53 */
54 inline endpoint
55 6883x sockaddr_to_endpoint(sockaddr_storage const& sa) noexcept
56 {
57 6883x return from_sockaddr(sa);
58 }
59
60 /// Convert a sockaddr_storage to a corosio::local_endpoint.
61 inline corosio::local_endpoint
62 445x sockaddr_to_local_endpoint(sockaddr_storage const& sa, socklen_t len) noexcept
63 {
64 445x return from_sockaddr_local(sa, len);
65 }
66
67 } // namespace boost::corosio::detail
68
69 #endif // BOOST_COROSIO_HAS_URING
70
71 #endif // BOOST_COROSIO_NATIVE_DETAIL_URING_URING_BUFFER_HPP
72