cache_update(void)
{
struct cache_service *s;
- struct interface *iface;
-
- vlist_for_each_element(&interfaces, iface, node) {
- dns_send_question(iface, NULL, C_DNS_SD, TYPE_ANY, interface_multicast(iface));
- dns_send_question(iface, NULL, C_DNS_SD, TYPE_PTR, interface_multicast(iface));
- avl_for_each_element(&services, s, avl)
- if (!s->host)
- dns_send_question(iface, NULL, s->entry, TYPE_PTR,
- interface_multicast(iface));
+ int count = 2;
+
+ dns_packet_init();
+ dns_packet_question(C_DNS_SD, TYPE_ANY);
+ dns_packet_question(C_DNS_SD, TYPE_PTR);
+ avl_for_each_element(&services, s, avl) {
+ dns_packet_question(s->entry, TYPE_PTR);
+ if (++count < 16)
+ continue;
+ dns_packet_broadcast();
+ count = 0;
}
+
+ if (count)
+ dns_packet_broadcast();
}
static struct cache_service*
perror("failed to send answer");
}
+void dns_packet_broadcast(void)
+{
+ struct interface *iface;
+
+ vlist_for_each_element(&interfaces, iface, node)
+ dns_packet_send(iface, NULL, 1, -1);
+}
+
void
dns_send_question(struct interface *iface, struct sockaddr *to,
const char *question, int type, int multicast)
bool dns_packet_question(const char *name, int type);
void dns_packet_answer(const char *name, int type, const uint8_t *rdata, uint16_t rdlength, int ttl);
void dns_packet_send(struct interface *iface, struct sockaddr *to, bool query, int multicast);
+void dns_packet_broadcast(void);
void dns_send_question(struct interface *iface, struct sockaddr *to,
const char *question, int type, int multicast);