src/corosio/src/socket_option.cpp
62.3% Lines (86/138)
63.0% List of functions (34/54)
-% Branches (0/0)
Functions (54)
Function
Calls
Lines
Blocks
boost::corosio::socket_option::no_delay::level()
:20
42x
100.0%
100.0%
boost::corosio::socket_option::no_delay::name()
:25
42x
100.0%
100.0%
boost::corosio::socket_option::keep_alive::level()
:33
16x
100.0%
100.0%
boost::corosio::socket_option::keep_alive::name()
:38
16x
100.0%
100.0%
boost::corosio::socket_option::v6_only::level()
:46
14x
100.0%
100.0%
boost::corosio::socket_option::v6_only::name()
:51
14x
100.0%
100.0%
boost::corosio::socket_option::reuse_address::level()
:59
1224x
100.0%
100.0%
boost::corosio::socket_option::reuse_address::name()
:64
1224x
100.0%
100.0%
boost::corosio::socket_option::broadcast::level()
:72
4x
100.0%
100.0%
boost::corosio::socket_option::broadcast::name()
:77
4x
100.0%
100.0%
boost::corosio::socket_option::reuse_port::level()
:86
0
0.0%
0.0%
boost::corosio::socket_option::reuse_port::name()
:91
0
0.0%
0.0%
boost::corosio::socket_option::receive_buffer_size::level()
:111
20x
100.0%
100.0%
boost::corosio::socket_option::receive_buffer_size::name()
:116
20x
100.0%
100.0%
boost::corosio::socket_option::send_buffer_size::level()
:124
8x
100.0%
100.0%
boost::corosio::socket_option::send_buffer_size::name()
:129
8x
100.0%
100.0%
boost::corosio::socket_option::linger::linger(bool, int)
:136
4228x
100.0%
100.0%
boost::corosio::socket_option::linger::enabled() const
:146
14x
100.0%
100.0%
boost::corosio::socket_option::linger::enabled(bool)
:154
2x
100.0%
100.0%
boost::corosio::socket_option::linger::timeout() const
:163
12x
100.0%
100.0%
boost::corosio::socket_option::linger::timeout(int)
:171
2x
100.0%
100.0%
boost::corosio::socket_option::linger::level()
:180
2126x
100.0%
100.0%
boost::corosio::socket_option::linger::name()
:185
2126x
100.0%
100.0%
boost::corosio::socket_option::linger::size() const
:191
2126x
100.0%
100.0%
boost::corosio::socket_option::multicast_loop_v4::level()
:199
10x
100.0%
100.0%
boost::corosio::socket_option::multicast_loop_v4::name()
:204
10x
100.0%
100.0%
boost::corosio::socket_option::multicast_loop_v6::level()
:212
8x
100.0%
100.0%
boost::corosio::socket_option::multicast_loop_v6::name()
:217
8x
100.0%
100.0%
boost::corosio::socket_option::multicast_hops_v4::level()
:225
4x
100.0%
100.0%
boost::corosio::socket_option::multicast_hops_v4::name()
:230
4x
100.0%
100.0%
boost::corosio::socket_option::multicast_hops_v6::level()
:238
4x
100.0%
100.0%
boost::corosio::socket_option::multicast_hops_v6::name()
:243
4x
100.0%
100.0%
boost::corosio::socket_option::multicast_interface_v6::level()
:251
0
0.0%
0.0%
boost::corosio::socket_option::multicast_interface_v6::name()
:256
0
0.0%
0.0%
boost::corosio::socket_option::join_group_v4::join_group_v4(boost::corosio::ipv4_address, boost::corosio::ipv4_address)
:263
4x
100.0%
100.0%
boost::corosio::socket_option::join_group_v4::level()
:273
2x
100.0%
100.0%
boost::corosio::socket_option::join_group_v4::name()
:278
2x
100.0%
100.0%
boost::corosio::socket_option::join_group_v4::size() const
:283
2x
100.0%
100.0%
boost::corosio::socket_option::leave_group_v4::leave_group_v4(boost::corosio::ipv4_address, boost::corosio::ipv4_address)
:290
0
0.0%
0.0%
boost::corosio::socket_option::leave_group_v4::level()
:300
0
0.0%
0.0%
boost::corosio::socket_option::leave_group_v4::name()
:305
0
0.0%
0.0%
boost::corosio::socket_option::leave_group_v4::size() const
:310
0
0.0%
0.0%
boost::corosio::socket_option::join_group_v6::join_group_v6(boost::corosio::ipv6_address, unsigned int)
:317
0
0.0%
0.0%
boost::corosio::socket_option::join_group_v6::level()
:327
0
0.0%
0.0%
boost::corosio::socket_option::join_group_v6::name()
:332
0
0.0%
0.0%
boost::corosio::socket_option::join_group_v6::size() const
:337
0
0.0%
0.0%
boost::corosio::socket_option::leave_group_v6::leave_group_v6(boost::corosio::ipv6_address, unsigned int)
:344
0
0.0%
0.0%
boost::corosio::socket_option::leave_group_v6::level()
:355
0
0.0%
0.0%
boost::corosio::socket_option::leave_group_v6::name()
:360
0
0.0%
0.0%
boost::corosio::socket_option::leave_group_v6::size() const
:365
0
0.0%
0.0%
boost::corosio::socket_option::multicast_interface_v4::multicast_interface_v4(boost::corosio::ipv4_address)
:372
0
0.0%
0.0%
boost::corosio::socket_option::multicast_interface_v4::level()
:382
0
0.0%
0.0%
boost::corosio::socket_option::multicast_interface_v4::name()
:387
0
0.0%
0.0%
boost::corosio::socket_option::multicast_interface_v4::size() const
:392
0
0.0%
0.0%
| 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 | #include <boost/corosio/socket_option.hpp> | ||
| 11 | #include <boost/corosio/native/native_socket_option.hpp> | ||
| 12 | |||
| 13 | #include <cstring> | ||
| 14 | |||
| 15 | namespace boost::corosio::socket_option { | ||
| 16 | |||
| 17 | // no_delay | ||
| 18 | |||
| 19 | int | ||
| 20 | 42x | no_delay::level() noexcept | |
| 21 | { | ||
| 22 | 42x | return native_socket_option::no_delay::level(); | |
| 23 | } | ||
| 24 | int | ||
| 25 | 42x | no_delay::name() noexcept | |
| 26 | { | ||
| 27 | 42x | return native_socket_option::no_delay::name(); | |
| 28 | } | ||
| 29 | |||
| 30 | // keep_alive | ||
| 31 | |||
| 32 | int | ||
| 33 | 16x | keep_alive::level() noexcept | |
| 34 | { | ||
| 35 | 16x | return native_socket_option::keep_alive::level(); | |
| 36 | } | ||
| 37 | int | ||
| 38 | 16x | keep_alive::name() noexcept | |
| 39 | { | ||
| 40 | 16x | return native_socket_option::keep_alive::name(); | |
| 41 | } | ||
| 42 | |||
| 43 | // v6_only | ||
| 44 | |||
| 45 | int | ||
| 46 | 14x | v6_only::level() noexcept | |
| 47 | { | ||
| 48 | 14x | return native_socket_option::v6_only::level(); | |
| 49 | } | ||
| 50 | int | ||
| 51 | 14x | v6_only::name() noexcept | |
| 52 | { | ||
| 53 | 14x | return native_socket_option::v6_only::name(); | |
| 54 | } | ||
| 55 | |||
| 56 | // reuse_address | ||
| 57 | |||
| 58 | int | ||
| 59 | 1224x | reuse_address::level() noexcept | |
| 60 | { | ||
| 61 | 1224x | return native_socket_option::reuse_address::level(); | |
| 62 | } | ||
| 63 | int | ||
| 64 | 1224x | reuse_address::name() noexcept | |
| 65 | { | ||
| 66 | 1224x | return native_socket_option::reuse_address::name(); | |
| 67 | } | ||
| 68 | |||
| 69 | // broadcast | ||
| 70 | |||
| 71 | int | ||
| 72 | 4x | broadcast::level() noexcept | |
| 73 | { | ||
| 74 | 4x | return native_socket_option::broadcast::level(); | |
| 75 | } | ||
| 76 | int | ||
| 77 | 4x | broadcast::name() noexcept | |
| 78 | { | ||
| 79 | 4x | return native_socket_option::broadcast::name(); | |
| 80 | } | ||
| 81 | |||
| 82 | // reuse_port | ||
| 83 | |||
| 84 | #ifdef SO_REUSEPORT | ||
| 85 | int | ||
| 86 | ✗ | reuse_port::level() noexcept | |
| 87 | { | ||
| 88 | ✗ | return native_socket_option::reuse_port::level(); | |
| 89 | } | ||
| 90 | int | ||
| 91 | ✗ | reuse_port::name() noexcept | |
| 92 | { | ||
| 93 | ✗ | return native_socket_option::reuse_port::name(); | |
| 94 | } | ||
| 95 | #else | ||
| 96 | int | ||
| 97 | reuse_port::level() noexcept | ||
| 98 | { | ||
| 99 | return SOL_SOCKET; | ||
| 100 | } | ||
| 101 | int | ||
| 102 | reuse_port::name() noexcept | ||
| 103 | { | ||
| 104 | return -1; | ||
| 105 | } | ||
| 106 | #endif | ||
| 107 | |||
| 108 | // receive_buffer_size | ||
| 109 | |||
| 110 | int | ||
| 111 | 20x | receive_buffer_size::level() noexcept | |
| 112 | { | ||
| 113 | 20x | return native_socket_option::receive_buffer_size::level(); | |
| 114 | } | ||
| 115 | int | ||
| 116 | 20x | receive_buffer_size::name() noexcept | |
| 117 | { | ||
| 118 | 20x | return native_socket_option::receive_buffer_size::name(); | |
| 119 | } | ||
| 120 | |||
| 121 | // send_buffer_size | ||
| 122 | |||
| 123 | int | ||
| 124 | 8x | send_buffer_size::level() noexcept | |
| 125 | { | ||
| 126 | 8x | return native_socket_option::send_buffer_size::level(); | |
| 127 | } | ||
| 128 | int | ||
| 129 | 8x | send_buffer_size::name() noexcept | |
| 130 | { | ||
| 131 | 8x | return native_socket_option::send_buffer_size::name(); | |
| 132 | } | ||
| 133 | |||
| 134 | // linger | ||
| 135 | |||
| 136 | 4228x | linger::linger(bool enabled, int timeout) noexcept | |
| 137 | 2114x | { | |
| 138 | 2114x | native_socket_option::linger native(enabled, timeout); | |
| 139 | static_assert( | ||
| 140 | sizeof(native) <= sizeof(storage_), | ||
| 141 | "platform linger exceeds socket_option::linger storage"); | ||
| 142 | 2114x | std::memcpy(storage_, native.data(), native.size()); | |
| 143 | 2114x | } | |
| 144 | |||
| 145 | bool | ||
| 146 | 14x | linger::enabled() const noexcept | |
| 147 | { | ||
| 148 | 14x | native_socket_option::linger native; | |
| 149 | 14x | std::memcpy(native.data(), storage_, native.size()); | |
| 150 | 14x | return native.enabled(); | |
| 151 | } | ||
| 152 | |||
| 153 | void | ||
| 154 | 2x | linger::enabled(bool e) noexcept | |
| 155 | { | ||
| 156 | 2x | native_socket_option::linger native; | |
| 157 | 2x | std::memcpy(native.data(), storage_, native.size()); | |
| 158 | 2x | native.enabled(e); | |
| 159 | 2x | std::memcpy(storage_, native.data(), native.size()); | |
| 160 | 2x | } | |
| 161 | |||
| 162 | int | ||
| 163 | 12x | linger::timeout() const noexcept | |
| 164 | { | ||
| 165 | 12x | native_socket_option::linger native; | |
| 166 | 12x | std::memcpy(native.data(), storage_, native.size()); | |
| 167 | 12x | return native.timeout(); | |
| 168 | } | ||
| 169 | |||
| 170 | void | ||
| 171 | 2x | linger::timeout(int t) noexcept | |
| 172 | { | ||
| 173 | 2x | native_socket_option::linger native; | |
| 174 | 2x | std::memcpy(native.data(), storage_, native.size()); | |
| 175 | 2x | native.timeout(t); | |
| 176 | 2x | std::memcpy(storage_, native.data(), native.size()); | |
| 177 | 2x | } | |
| 178 | |||
| 179 | int | ||
| 180 | 2126x | linger::level() noexcept | |
| 181 | { | ||
| 182 | 2126x | return native_socket_option::linger::level(); | |
| 183 | } | ||
| 184 | int | ||
| 185 | 2126x | linger::name() noexcept | |
| 186 | { | ||
| 187 | 2126x | return native_socket_option::linger::name(); | |
| 188 | } | ||
| 189 | |||
| 190 | std::size_t | ||
| 191 | 2126x | linger::size() const noexcept | |
| 192 | { | ||
| 193 | 2126x | return native_socket_option::linger{}.size(); | |
| 194 | } | ||
| 195 | |||
| 196 | // multicast_loop_v4 | ||
| 197 | |||
| 198 | int | ||
| 199 | 10x | multicast_loop_v4::level() noexcept | |
| 200 | { | ||
| 201 | 10x | return native_socket_option::multicast_loop_v4::level(); | |
| 202 | } | ||
| 203 | int | ||
| 204 | 10x | multicast_loop_v4::name() noexcept | |
| 205 | { | ||
| 206 | 10x | return native_socket_option::multicast_loop_v4::name(); | |
| 207 | } | ||
| 208 | |||
| 209 | // multicast_loop_v6 | ||
| 210 | |||
| 211 | int | ||
| 212 | 8x | multicast_loop_v6::level() noexcept | |
| 213 | { | ||
| 214 | 8x | return native_socket_option::multicast_loop_v6::level(); | |
| 215 | } | ||
| 216 | int | ||
| 217 | 8x | multicast_loop_v6::name() noexcept | |
| 218 | { | ||
| 219 | 8x | return native_socket_option::multicast_loop_v6::name(); | |
| 220 | } | ||
| 221 | |||
| 222 | // multicast_hops_v4 | ||
| 223 | |||
| 224 | int | ||
| 225 | 4x | multicast_hops_v4::level() noexcept | |
| 226 | { | ||
| 227 | 4x | return native_socket_option::multicast_hops_v4::level(); | |
| 228 | } | ||
| 229 | int | ||
| 230 | 4x | multicast_hops_v4::name() noexcept | |
| 231 | { | ||
| 232 | 4x | return native_socket_option::multicast_hops_v4::name(); | |
| 233 | } | ||
| 234 | |||
| 235 | // multicast_hops_v6 | ||
| 236 | |||
| 237 | int | ||
| 238 | 4x | multicast_hops_v6::level() noexcept | |
| 239 | { | ||
| 240 | 4x | return native_socket_option::multicast_hops_v6::level(); | |
| 241 | } | ||
| 242 | int | ||
| 243 | 4x | multicast_hops_v6::name() noexcept | |
| 244 | { | ||
| 245 | 4x | return native_socket_option::multicast_hops_v6::name(); | |
| 246 | } | ||
| 247 | |||
| 248 | // multicast_interface_v6 | ||
| 249 | |||
| 250 | int | ||
| 251 | ✗ | multicast_interface_v6::level() noexcept | |
| 252 | { | ||
| 253 | ✗ | return native_socket_option::multicast_interface_v6::level(); | |
| 254 | } | ||
| 255 | int | ||
| 256 | ✗ | multicast_interface_v6::name() noexcept | |
| 257 | { | ||
| 258 | ✗ | return native_socket_option::multicast_interface_v6::name(); | |
| 259 | } | ||
| 260 | |||
| 261 | // join_group_v4 | ||
| 262 | |||
| 263 | 4x | join_group_v4::join_group_v4(ipv4_address group, ipv4_address iface) noexcept | |
| 264 | 2x | { | |
| 265 | 2x | native_socket_option::join_group_v4 native(group, iface); | |
| 266 | static_assert( | ||
| 267 | sizeof(native) <= sizeof(storage_), | ||
| 268 | "platform ip_mreq exceeds join_group_v4 storage"); | ||
| 269 | 2x | std::memcpy(storage_, native.data(), native.size()); | |
| 270 | 2x | } | |
| 271 | |||
| 272 | int | ||
| 273 | 2x | join_group_v4::level() noexcept | |
| 274 | { | ||
| 275 | 2x | return native_socket_option::join_group_v4::level(); | |
| 276 | } | ||
| 277 | int | ||
| 278 | 2x | join_group_v4::name() noexcept | |
| 279 | { | ||
| 280 | 2x | return native_socket_option::join_group_v4::name(); | |
| 281 | } | ||
| 282 | std::size_t | ||
| 283 | 2x | join_group_v4::size() const noexcept | |
| 284 | { | ||
| 285 | 2x | return native_socket_option::join_group_v4{}.size(); | |
| 286 | } | ||
| 287 | |||
| 288 | // leave_group_v4 | ||
| 289 | |||
| 290 | ✗ | leave_group_v4::leave_group_v4(ipv4_address group, ipv4_address iface) noexcept | |
| 291 | ✗ | { | |
| 292 | ✗ | native_socket_option::leave_group_v4 native(group, iface); | |
| 293 | static_assert( | ||
| 294 | sizeof(native) <= sizeof(storage_), | ||
| 295 | "platform ip_mreq exceeds leave_group_v4 storage"); | ||
| 296 | ✗ | std::memcpy(storage_, native.data(), native.size()); | |
| 297 | ✗ | } | |
| 298 | |||
| 299 | int | ||
| 300 | ✗ | leave_group_v4::level() noexcept | |
| 301 | { | ||
| 302 | ✗ | return native_socket_option::leave_group_v4::level(); | |
| 303 | } | ||
| 304 | int | ||
| 305 | ✗ | leave_group_v4::name() noexcept | |
| 306 | { | ||
| 307 | ✗ | return native_socket_option::leave_group_v4::name(); | |
| 308 | } | ||
| 309 | std::size_t | ||
| 310 | ✗ | leave_group_v4::size() const noexcept | |
| 311 | { | ||
| 312 | ✗ | return native_socket_option::leave_group_v4{}.size(); | |
| 313 | } | ||
| 314 | |||
| 315 | // join_group_v6 | ||
| 316 | |||
| 317 | ✗ | join_group_v6::join_group_v6(ipv6_address group, unsigned int if_index) noexcept | |
| 318 | ✗ | { | |
| 319 | ✗ | native_socket_option::join_group_v6 native(group, if_index); | |
| 320 | static_assert( | ||
| 321 | sizeof(native) <= sizeof(storage_), | ||
| 322 | "platform ipv6_mreq exceeds join_group_v6 storage"); | ||
| 323 | ✗ | std::memcpy(storage_, native.data(), native.size()); | |
| 324 | ✗ | } | |
| 325 | |||
| 326 | int | ||
| 327 | ✗ | join_group_v6::level() noexcept | |
| 328 | { | ||
| 329 | ✗ | return native_socket_option::join_group_v6::level(); | |
| 330 | } | ||
| 331 | int | ||
| 332 | ✗ | join_group_v6::name() noexcept | |
| 333 | { | ||
| 334 | ✗ | return native_socket_option::join_group_v6::name(); | |
| 335 | } | ||
| 336 | std::size_t | ||
| 337 | ✗ | join_group_v6::size() const noexcept | |
| 338 | { | ||
| 339 | ✗ | return native_socket_option::join_group_v6{}.size(); | |
| 340 | } | ||
| 341 | |||
| 342 | // leave_group_v6 | ||
| 343 | |||
| 344 | ✗ | leave_group_v6::leave_group_v6( | |
| 345 | ipv6_address group, unsigned int if_index) noexcept | ||
| 346 | ✗ | { | |
| 347 | ✗ | native_socket_option::leave_group_v6 native(group, if_index); | |
| 348 | static_assert( | ||
| 349 | sizeof(native) <= sizeof(storage_), | ||
| 350 | "platform ipv6_mreq exceeds leave_group_v6 storage"); | ||
| 351 | ✗ | std::memcpy(storage_, native.data(), native.size()); | |
| 352 | ✗ | } | |
| 353 | |||
| 354 | int | ||
| 355 | ✗ | leave_group_v6::level() noexcept | |
| 356 | { | ||
| 357 | ✗ | return native_socket_option::leave_group_v6::level(); | |
| 358 | } | ||
| 359 | int | ||
| 360 | ✗ | leave_group_v6::name() noexcept | |
| 361 | { | ||
| 362 | ✗ | return native_socket_option::leave_group_v6::name(); | |
| 363 | } | ||
| 364 | std::size_t | ||
| 365 | ✗ | leave_group_v6::size() const noexcept | |
| 366 | { | ||
| 367 | ✗ | return native_socket_option::leave_group_v6{}.size(); | |
| 368 | } | ||
| 369 | |||
| 370 | // multicast_interface_v4 | ||
| 371 | |||
| 372 | ✗ | multicast_interface_v4::multicast_interface_v4(ipv4_address iface) noexcept | |
| 373 | ✗ | { | |
| 374 | ✗ | native_socket_option::multicast_interface_v4 native(iface); | |
| 375 | static_assert( | ||
| 376 | sizeof(native) <= sizeof(storage_), | ||
| 377 | "platform in_addr exceeds multicast_interface_v4 storage"); | ||
| 378 | ✗ | std::memcpy(storage_, native.data(), native.size()); | |
| 379 | ✗ | } | |
| 380 | |||
| 381 | int | ||
| 382 | ✗ | multicast_interface_v4::level() noexcept | |
| 383 | { | ||
| 384 | ✗ | return native_socket_option::multicast_interface_v4::level(); | |
| 385 | } | ||
| 386 | int | ||
| 387 | ✗ | multicast_interface_v4::name() noexcept | |
| 388 | { | ||
| 389 | ✗ | return native_socket_option::multicast_interface_v4::name(); | |
| 390 | } | ||
| 391 | std::size_t | ||
| 392 | ✗ | multicast_interface_v4::size() const noexcept | |
| 393 | { | ||
| 394 | ✗ | return native_socket_option::multicast_interface_v4{}.size(); | |
| 395 | } | ||
| 396 | |||
| 397 | } // namespace boost::corosio::socket_option | ||
| 398 |