Use one define for DNS-Based Service Discovery service name
[project/mdnsd.git] / interface.c
index ada8acb..a984be9 100644 (file)
@@ -34,6 +34,7 @@
 #include <libubox/uloop.h>
 #include <libubox/avl-cmp.h>
 #include <libubox/utils.h>
+#include "cache.h"
 #include "interface.h"
 #include "util.h"
 #include "dns.h"
@@ -125,6 +126,7 @@ interface_send_packet(struct interface *iface, struct sockaddr *to, struct iovec
 {
        if (!iface->multicast && !to) {
                fprintf(stderr, "No IP address specified for unicast interface\n");
+               errno = EINVAL;
                return -1;
        }
 
@@ -152,6 +154,7 @@ static void interface_close(struct interface *iface)
 
 static void interface_free(struct interface *iface)
 {
+       uloop_timeout_cancel(&iface->reconnect);
        interface_close(iface);
        free(iface);
 }
@@ -438,7 +441,7 @@ reconnect_socket4(struct uloop_timeout *timeout)
 
        uloop_fd_add(&iface->fd, ULOOP_READ);
        if (iface->multicast) {
-               dns_send_question(iface, "_services._dns-sd._udp.local", TYPE_PTR, 0);
+               dns_send_question(iface, C_DNS_SD, TYPE_PTR, 0);
                announce_init(iface);
        }
 
@@ -486,7 +489,7 @@ reconnect_socket6(struct uloop_timeout *timeout)
        uloop_fd_add(&iface->fd, ULOOP_READ);
 
        if (iface->multicast) {
-               dns_send_question(iface, "_services._dns-sd._udp.local", TYPE_PTR, 0);
+               dns_send_question(iface, C_DNS_SD, TYPE_PTR, 0);
                announce_init(iface);
        }
 
@@ -517,6 +520,7 @@ iface_update_cb(struct vlist_tree *tree, struct vlist_node *node_new,
 
        if (node_old) {
                iface = container_of(node_old, struct interface, node);
+               cache_cleanup(iface);
                interface_free(iface);
        }