Skip to content

Commit

Permalink
Add OS annotations to socket option checks to enhance maintainability.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfr-haleytek committed Oct 21, 2024
1 parent 99b790d commit d9bd120
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ receive_cb (std::shared_ptr<storage> _data) {
cmsg != NULL;
cmsg = CMSG_NXTHDR(&its_header, cmsg)) {

#if defined(IP_PKTINFO)
#if defined(IP_PKTINFO) # Linux, QNX io-pkt
struct in_pktinfo *its_pktinfo_v4;
if (cmsg->cmsg_level == IPPROTO_IP
&& cmsg->cmsg_type == IP_PKTINFO
Expand All @@ -322,7 +322,7 @@ receive_cb (std::shared_ptr<storage> _data) {
break;
}
}
#elif defined(IP_RECVDSTADDR)
#elif defined(IP_RECVDSTADDR) # FreeBSD, QNX io-sock
struct in_addr *its_pktinfo_v4;
if (cmsg->cmsg_level == IPPROTO_IP
&& cmsg->cmsg_type == IP_RECVDSTADDR
Expand Down
4 changes: 2 additions & 2 deletions implementation/endpoints/src/udp_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,9 @@ udp_server_endpoint_impl::set_multicast_option(const boost::asio::ip::address& _
int its_pktinfo_option(1);
::setsockopt(multicast_socket_->native_handle(),
(is_v4_ ? IPPROTO_IP : IPPROTO_IPV6),
#if defined(IP_PKTINFO)
#if defined(IP_PKTINFO) # Linux, QNX io-pkt
(is_v4_ ? IP_PKTINFO : IPV6_RECVPKTINFO),
#elif defined(IP_RECVDSTADDR)
#elif defined(IP_RECVDSTADDR) # FreeBSD, QNX io-sock
(is_v4_ ? IP_RECVDSTADDR : IPV6_RECVPKTINFO),
#else
#error "Platform not supported. Neither IP_PKTINFO nor IP_RECVDSTADDR is defined.";
Expand Down

0 comments on commit d9bd120

Please sign in to comment.