From: Rafał Miłecki Date: Wed, 10 May 2017 20:45:48 +0000 (+0200) Subject: Allow filtering with instance name in service_reply X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fmdnsd.git;a=commitdiff_plain;h=26ce7dca8085d34e6c3910680da51695f3508eec Allow filtering with instance name in service_reply This will allow sending replies more flexibly. Signed-off-by: Rafał Miłecki --- diff --git a/dns.c b/dns.c index 68a088f..bccaa29 100644 --- a/dns.c +++ b/dns.c @@ -369,7 +369,7 @@ parse_question(struct interface *iface, struct sockaddr *from, char *name, struc case TYPE_ANY: if (!strcmp(name, mdns_hostname_local)) { dns_reply_a(iface, to, announce_ttl); - service_reply(iface, to, NULL, announce_ttl); + service_reply(iface, to, NULL, NULL, announce_ttl); } break; @@ -386,7 +386,7 @@ parse_question(struct interface *iface, struct sockaddr *from, char *name, struc /* Make sure it's query for the instance name we use */ if (len && len == strlen(umdns_host_label) && !strncmp(name, umdns_host_label, len)) - service_reply(iface, to, dot + 1, announce_ttl); + service_reply(iface, to, NULL, dot + 1, announce_ttl); } break; diff --git a/service.c b/service.c index e6d9618..67e8f40 100644 --- a/service.c +++ b/service.c @@ -152,13 +152,16 @@ service_reply_single(struct interface *iface, struct sockaddr *to, struct servic } void -service_reply(struct interface *iface, struct sockaddr *to, const char *match, int ttl) +service_reply(struct interface *iface, struct sockaddr *to, const char *instance, const char *service_domain, int ttl) { struct service *s; vlist_for_each_element(&services, s, node) { - if (!match || !strcmp(s->service, match)) - service_reply_single(iface, to, s, ttl, 0); + if (instance && strcmp(s->instance, instance)) + continue; + if (service_domain && strcmp(s->service, service_domain)) + continue; + service_reply_single(iface, to, s, ttl, 0); } } diff --git a/service.h b/service.h index 086a0af..db8f374 100644 --- a/service.h +++ b/service.h @@ -16,7 +16,7 @@ extern void service_init(int announce); extern void service_cleanup(void); -extern void service_reply(struct interface *iface, struct sockaddr *to, const char *match, int ttl); +extern void service_reply(struct interface *iface, struct sockaddr *to, const char *instance, const char *service_domain, int ttl); extern void service_announce_services(struct interface *iface, struct sockaddr *to, int ttl); #endif