From c3c168c1cc39539f5ec452ab2f556e78bfa92917 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Fri, 10 Feb 2017 23:37:11 +0100 Subject: [PATCH] Don't use _services._dns-sd._tcp.local MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Acked-by: John Crispin --- dns.c | 4 +--- service.c | 15 +++------------ service.h | 3 +-- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/dns.c b/dns.c index 550befc..91434f2 100644 --- 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; diff --git a/service.c b/service.c index e375fce..993e7cf 100644 --- 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 diff --git a/service.h b/service.h index 901bcbd..78ee854 100644 --- a/service.h +++ b/service.h @@ -15,11 +15,10 @@ #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 -- 2.25.1