]> git.meshlink.io Git - catta/commitdiff
work around yet another bsd limitation: prefer IP_MULTICAST_IF over IP_SENDSRCADDR...
authorLennart Poettering <lennart@poettering.net>
Sun, 16 Dec 2007 20:55:38 +0000 (20:55 +0000)
committerLennart Poettering <lennart@poettering.net>
Sun, 16 Dec 2007 20:55:38 +0000 (20:55 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1590 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-core/socket.c

index cdfe4793b6b90ea2a0bbe98aa09571b3e179c209..265536de1d5f28ec9b208a47b2692e2ac0b01ef1 100644 (file)
@@ -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