service: announce all services in single dns answer
authorJohn Crispin <john@phrozen.org>
Wed, 11 Dec 2024 14:27:22 +0000 (15:27 +0100)
committerJohn Crispin <john@phrozen.org>
Wed, 11 Dec 2024 14:27:22 +0000 (15:27 +0100)
Annouce all services in single packet, and do not send single reply
for each of the service while annoucing. The single reply is sent
in response to specific service queries only.

Signed-off-by: Rahul Thakur <rahul.thakur@iopsys.eu>
Signed-off-by: John Crispin <john@phrozen.org>
service.c

index 21bdc7bee6771c181516836f2343fc2115e47a01..1f81031f8d5ee3b8e96b7abd0d9e36fd13578e60 100644 (file)
--- a/service.c
+++ b/service.c
@@ -161,16 +161,18 @@ void
 service_announce_services(struct interface *iface, struct sockaddr *to, int ttl)
 {
        struct service *s;
+       int count = 0;
 
+       dns_init_answer();
        vlist_for_each_element(&announced_services, s, node) {
                s->t = 0;
                if (ttl) {
-                       dns_init_answer();
                        service_add_ptr(s->service, ttl);
-                       dns_send_answer(iface, to, C_DNS_SD);
+                       count++;
                }
-               service_reply_single(iface, to, s, ttl, 0);
        }
+       if (count)
+               dns_send_answer(iface, to, C_DNS_SD);
 }
 
 void