Don't use _services._dns-sd._tcp.local
authorRafał Miłecki <rafal@milecki.pl>
Fri, 10 Feb 2017 22:37:11 +0000 (23:37 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Sat, 11 Feb 2017 09:11:06 +0000 (10:11 +0100)
It seems mdns(d) was trying to support queries for two records with
following names:
1) _services._dns-sd._udp.local
2) _services._dns-sd._tcp.local

According to the RFC 6763 Section 9 only the first one should be used
and response PTR records should include services of both protocols: UDP
and TCP.

This fixes discovering TCP services as in practice no other software was
sending queries with _services._dns-sd._tcp.local.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
dns.c
service.c
service.h

diff --git a/dns.c b/dns.c
index 550befc24c1593ca2f7bcef14fed22456304908f..91434f20b184d2696129ecb2a3038483a9ee204e 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -368,9 +368,7 @@ parse_question(struct interface *iface, char *name, struct dns_question *q)
 
        case TYPE_PTR:
                if (!strcmp(name, sdudp))
-                       service_announce_services(iface, 0, announce_ttl);
-               else if (!strcmp(name, sdtcp))
-                       service_announce_services(iface, 1, announce_ttl);
+                       service_announce_services(iface, announce_ttl);
                service_reply(iface, name, announce_ttl);
                break;
 
index e375fced85ffb8f1a13a8d0b4cd8933a06c79f56..993e7cfd10d7a089b73b331e696affe14878732d 100644 (file)
--- a/service.c
+++ b/service.c
@@ -66,7 +66,6 @@ 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);
 char *sdudp =  "_services._dns-sd._udp.local";
-char *sdtcp =  "_services._dns-sd._tcp.local";
 static int service_init_announce;
 
 static const char *
@@ -155,23 +154,16 @@ service_reply(struct interface *iface, const char *match, int ttl)
 }
 
 void
-service_announce_services(struct interface *iface, int tcp, int ttl)
+service_announce_services(struct interface *iface, int ttl)
 {
        struct service *s;
 
        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_single(iface, s, ttl, 0);
        }
@@ -180,8 +172,7 @@ service_announce_services(struct interface *iface, int tcp, int ttl)
 void
 service_announce(struct interface *iface, int ttl)
 {
-       service_announce_services(iface, 0, ttl);
-       service_announce_services(iface, 1, ttl);
+       service_announce_services(iface, ttl);
 }
 
 static void
index 901bcbd007cab75785bc6f646a0211ba34738661..78ee8543a0d9e97b3d636280839ab4c18787c1c6 100644 (file)
--- a/service.h
+++ b/service.h
 #define _SERVICE_H__
 
 extern char *sdudp;
-extern char *sdtcp;
 extern void service_init(int announce);
 extern void service_cleanup(void);
 extern void service_announce(struct interface *iface, int ttl);
 extern void service_reply(struct interface *iface, const char *match, int ttl);
-extern void service_announce_services(struct interface *iface, int tcp, int ttl);
+extern void service_announce_services(struct interface *iface, int ttl);
 
 #endif