3 #include <boost/asio/ip/udp.hpp>
5 #include <nexus/error_code.hpp>
9 using boost::asio::ip::udp;
13 template <
int Name4,
int Name6>
17 constexpr socket_option(
bool b) : value(b ? 1 : 0) {}
19 constexpr
operator bool()
const {
return value; }
21 template <
typename Protocol>
22 constexpr
int level(
const Protocol& proto)
const {
23 return proto.family() == PF_INET6 ? IPPROTO_IPV6 : IPPROTO_IP;
25 template <
typename Protocol>
26 constexpr
int name(
const Protocol& proto)
const {
27 return proto.family() == PF_INET6 ? Name6 : Name4;
29 template <
typename Protocol>
30 constexpr
size_t size(
const Protocol&)
const {
33 template <
typename Protocol>
34 constexpr
void* data(
const Protocol&) {
37 template <
typename Protocol>
38 constexpr
const void* data(
const Protocol&)
const {
41 template <
typename Protocol>
42 constexpr
void resize(Protocol&, std::size_t) {}
45 template <
typename Socket,
typename Option>
46 error_code set_option(Socket& sock, Option&& option) {
48 sock.set_option(option, ec);
52 template <
typename Socket,
typename ...Options>
53 error_code set_options(Socket& sock, Options&& ...options) {
56 ((ec = set_option(sock, options)) || ...);
62 using receive_ecn = detail::socket_option<IP_RECVTOS, IPV6_RECVTCLASS>;
64 #ifdef IP_RECVORIGDSTADDR
65 using receive_dstaddr = detail::socket_option<IP_RECVORIGDSTADDR, IPV6_RECVPKTINFO>;
67 using receive_dstaddr = detail::socket_option<IP_PKTINFO, IPV6_RECVPKTINFO>;
networking
Definition: error_code.hpp:8