Load service JSONs from /etc/umdns/
[project/mdnsd.git] / service.c
index 182b2b2..15f05f9 100644 (file)
--- a/service.c
+++ b/service.c
@@ -65,8 +65,7 @@ service_update(struct vlist_tree *tree, struct vlist_node *node_new,
 
 static struct blob_buf b;
 static VLIST_TREE(services, avl_strcmp, service_update, false, false);
-static char *sdudp =  "_services._dns-sd._udp.local";
-static char *sdtcp =  "_services._dns-sd._tcp.local";
+char *sdudp =  "_services._dns-sd._udp.local";
 static int service_init_announce;
 
 static const char *
@@ -155,41 +154,21 @@ service_reply(struct interface *iface, const char *match, int ttl)
 }
 
 void
-service_announce_services(struct interface *iface, const char *service, int ttl)
+service_announce_services(struct interface *iface, int ttl)
 {
        struct service *s;
-       int tcp = 1;
-
-       if (!strcmp(service, sdudp))
-               tcp = 0;
-       else if (strcmp(service, sdtcp))
-               return;
 
        vlist_for_each_element(&services, s, node) {
-               if (!strstr(s->service, "._tcp") && tcp)
-                       continue;
-               if (!strstr(s->service, "._udp") && !tcp)
-                       continue;
                s->t = 0;
                if (ttl) {
                        dns_init_answer();
                        service_add_ptr(s->service, ttl);
-                       if (tcp)
-                               dns_send_answer(iface, sdtcp);
-                       else
-                               dns_send_answer(iface, sdudp);
+                       dns_send_answer(iface, sdudp);
                }
-               service_reply(iface, s->service, ttl);
+               service_reply_single(iface, s, ttl, 0);
        }
 }
 
-void
-service_announce(struct interface *iface, int ttl)
-{
-       service_announce_services(iface, sdudp, ttl);
-       service_announce_services(iface, sdtcp, ttl);
-}
-
 static void
 service_update(struct vlist_tree *tree, struct vlist_node *node_new,
               struct vlist_node *node_old)
@@ -229,7 +208,7 @@ service_load_blob(struct blob_attr *b)
        if (!_tb[SERVICE_PORT] || !_tb[SERVICE_SERVICE])
                return;
 
-       if (_tb[SERVICE_SERVICE])
+       if (_tb[SERVICE_TXT])
                blobmsg_for_each_attr(txt, _tb[SERVICE_TXT], rem2)
                        txt_len += 1 + strlen(blobmsg_get_string(txt));
 
@@ -248,7 +227,7 @@ service_load_blob(struct blob_attr *b)
        s->txt_len = txt_len;
        s->txt = d_txt;
 
-       if (_tb[SERVICE_SERVICE])
+       if (_tb[SERVICE_TXT])
                blobmsg_for_each_attr(txt, _tb[SERVICE_TXT], rem2) {
                        int len = strlen(blobmsg_get_string(txt));
                        if (!len)
@@ -292,7 +271,7 @@ service_init_cb(struct ubus_request *req, int type, struct blob_attr *msg)
        get_hostname();
 
        vlist_update(&services);
-       service_load("/tmp/run/mdns/*");
+       service_load("/etc/umdns/*");
 
        blob_for_each_attr(cur, msg, rem) {
                struct blob_attr *cur2;