+static int ip_pktinfo (int fd, int yes)
+{
+ int ret = -1;
+
+#if IP_PKTINFO
+ if ((ret = setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &yes, sizeof(yes))) < 0) {
+ avahi_log_warn("IP_PKTINFO failed: %s", strerror(errno));
+ }
+#else
+#ifdef IP_RECVINTERFACE
+ if ((ret = setsockopt (fd, IPPROTO_IP, IP_RECVINTERFACE, &yes, sizeof (yes))) < 0) {
+ avahi_log_warn("IP_RECVINTERFACE failed: %s", strerror(errno));
+ }
+#else
+#ifdef IP_RECVIF
+ if ((ret = setsockopt (fd, IPPROTO_IP, IP_RECVIF, &yes, sizeof (yes))) < 0) {
+ avahi_log_warn("IP_RECVIF failed: %s", strerror(errno));
+ }
+#endif /* IP_RECVIF */
+#endif /* IP_RECVINTERFACE */
+#if defined (IP_RECVDSTADDR) /* && !defined(solaris) */
+ if ((ret = setsockopt (fd, IPPROTO_IP, IP_RECVDSTADDR, &yes, sizeof (yes))) < 0) {
+ avahi_log_warn("IP_RECVDSTADDR failed: %s", strerror(errno));
+ }
+#endif /* IP_RECVDSTADDR */
+#endif /* IP_PKTINFO */
+
+ return (ret);
+}
+