mdnsd: interface: enable looped back messages
[project/mdnsd.git] / interface.c
index 70c02aa706351d19c096bf0429b09f174104103f..9ca85e1a6dc343a9ecb055cf90df64c75de83566 100644 (file)
@@ -315,7 +315,7 @@ interface_mcast_setup4(struct interface *iface)
 {
        struct ip_mreqn mreq;
        uint8_t ttl = 255;
-       int no = 0;
+       int yes = 1;
        struct sockaddr_in sa = { 0 };
        int fd = iface->fd.fd;
 
@@ -345,7 +345,7 @@ interface_mcast_setup4(struct interface *iface)
                return -1;
        }
 
-       if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &no, sizeof(no)) < 0)
+       if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0)
                fprintf(stderr, "ioctl failed: IP_MULTICAST_LOOP\n");
 
        return 0;
@@ -356,7 +356,7 @@ interface_socket_setup6(struct interface *iface)
 {
        struct ipv6_mreq mreq;
        int ttl = 255;
-       int no = 0;
+       int yes = 1;
        struct sockaddr_in6 sa = { 0 };
        int fd = iface->fd.fd;
 
@@ -379,7 +379,7 @@ interface_socket_setup6(struct interface *iface)
                return -1;
        }
 
-       if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &no, sizeof(no)) < 0)
+       if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &yes, sizeof(yes)) < 0)
                fprintf(stderr, "ioctl failed: IPV6_MULTICAST_LOOP\n");
 
        return 0;
@@ -627,4 +627,13 @@ void interface_shutdown(void)
                interface_close(iface);
 }
 
+struct interface*
+interface_get(const char *name, int v6, int multicast)
+{
+       char id_buf[32];
+       snprintf(id_buf, sizeof(id_buf), "%d_%d_%s", multicast, v6, name);
+       struct interface *iface = vlist_find(&interfaces, id_buf, iface, node);
+       return iface;
+}
+
 VLIST_TREE(interfaces, avl_strcmp, iface_update_cb, false, false);