diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp index 587fb94c2..a45860a6d 100644 --- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp @@ -862,7 +862,13 @@ udp_server_endpoint_impl::set_multicast_option( int its_pktinfo_option(1); ::setsockopt(multicast_socket_->native_handle(), (is_v4_ ? IPPROTO_IP : IPPROTO_IPV6), +#if defined(IP_PKTINFO) (is_v4_ ? IP_PKTINFO : IPV6_RECVPKTINFO), +#elif defined(IP_RECVDSTADDR) + (is_v4_ ? IP_RECVDSTADDR : IPV6_RECVPKTINFO), +#else + #error "Platform not supported. Neither IP_PKTINFO nor IP_RECVDSTADDR is defined."; +#endif &its_pktinfo_option, sizeof(its_pktinfo_option)); #endif diff --git a/implementation/helper/boost/asio/detail/impl/socket_ops_ext.ipp b/implementation/helper/boost/asio/detail/impl/socket_ops_ext.ipp index fe90e83e9..260d09b85 100644 --- a/implementation/helper/boost/asio/detail/impl/socket_ops_ext.ipp +++ b/implementation/helper/boost/asio/detail/impl/socket_ops_ext.ipp @@ -96,6 +96,7 @@ signed_size_type recvfrom(socket_type s, buf* bufs, size_t count, cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { +#if defined(IP_PKTINFO) if (cmsg->cmsg_level != IPPROTO_IP || cmsg->cmsg_type != IP_PKTINFO) continue; @@ -104,6 +105,18 @@ signed_size_type recvfrom(socket_type s, buf* bufs, size_t count, { da = boost::asio::ip::address_v4(ntohl(pi->ipi_addr.s_addr)); } +#elif defined(IP_RECVDSTADDR) + if (cmsg->cmsg_level != IPPROTO_IP || cmsg->cmsg_type != IP_RECVDSTADDR) + continue; + + struct in_addr *addr = (struct in_addr*) CMSG_DATA(cmsg); + if (addr) + { + da = boost::asio::ip::address_v4(ntohl(addr->s_addr)); + } +#else + #error "Platform not supported. Neither IP_PKTINFO nor IP_RECVDSTADDR is defined."; +#endif } } return result;