From: Lennart Poettering Date: Sun, 16 Dec 2007 20:55:38 +0000 (+0000) Subject: work around yet another bsd limitation: prefer IP_MULTICAST_IF over IP_SENDSRCADDR... X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=83b48838576d84c9683ba9a7ea0813856bfa9f38;p=catta work around yet another bsd limitation: prefer IP_MULTICAST_IF over IP_SENDSRCADDR. Patch from zml. Closes #163 git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1590 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-core/socket.c b/avahi-core/socket.c index cdfe479..265536d 100644 --- a/avahi-core/socket.c +++ b/avahi-core/socket.c @@ -476,7 +476,7 @@ int avahi_send_dns_packet_ipv4( #ifdef IP_PKTINFO struct cmsghdr *cmsg; size_t cmsg_data[( CMSG_SPACE(sizeof(struct in_pktinfo)) / sizeof(size_t)) + 1]; -#elif defined(IP_SENDSRCADDR) +#elif !defined(IP_MULTICAST_IF) && defined(IP_SENDSRCADDR) struct cmsghdr *cmsg; size_t cmsg_data[( CMSG_SPACE(sizeof(struct in_addr)) / sizeof(size_t)) + 1]; #endif @@ -525,6 +525,14 @@ int avahi_send_dns_packet_ipv4( if (src_address) pkti->ipi_spec_dst.s_addr = src_address->address; } +#elif defined(IP_MULTICAST_IF) + if (src_address) { + struct in_addr any = { INADDR_ANY }; + if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, src_address ? &src_address->address : &any, sizeof(struct in_addr)) < 0) { + avahi_log_warn("IP_MULTICAST_IF failed: %s", strerror(errno)); + return -1; + } + } #elif defined(IP_SENDSRCADDR) if (src_address) { struct in_addr *addr; @@ -541,14 +549,6 @@ int avahi_send_dns_packet_ipv4( addr = (struct in_addr *)CMSG_DATA(cmsg); addr->s_addr = src_address->address; } -#elif defined(IP_MULTICAST_IF) - { - struct in_addr any = { INADDR_ANY }; - if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, src_address ? (const void*) &src_address->address : (const void*) &any, sizeof(struct in_addr)) < 0) { - avahi_log_warn("IP_MULTICAST_IF failed: %s", strerror(errno)); - return -1; - } - } #elif defined(__GNUC__) #warning "FIXME: We need some code to set the outgoing interface/local address here if IP_PKTINFO/IP_MULTICAST_IF is not available" #endif