static void
parse_question(struct interface *iface, struct sockaddr *from, char *name, struct dns_question *q)
{
+ int is_unicast = (q->class & CLASS_UNICAST) != 0;
struct sockaddr *to = NULL;
struct hostname *h;
char *host;
/* TODO: Multicast if more than one quarter of TTL has passed */
- if (q->class & CLASS_UNICAST) {
+ if (is_unicast) {
to = from;
if (interface_multicast(iface))
iface = interface_get(iface->name, iface->type | SOCKTYPE_BIT_UNICAST);
if (!strcmp(name, mdns_hostname_local)) {
dns_reply_a(iface, to, announce_ttl, NULL);
dns_reply_a_additional(iface, to, announce_ttl);
- service_reply(iface, to, NULL, NULL, announce_ttl);
+ service_reply(iface, to, NULL, NULL, announce_ttl, is_unicast);
}
break;
service_announce_services(iface, to, announce_ttl);
} else {
if (name[0] == '_') {
- service_reply(iface, to, NULL, name, announce_ttl);
+ service_reply(iface, to, NULL, name, announce_ttl, is_unicast);
} else {
/* First dot separates instance name from the rest */
char *dot = strchr(name, '.');
if (dot) {
*dot = '\0';
- service_reply(iface, to, name, dot + 1, announce_ttl);
+ service_reply(iface, to, name, dot + 1, announce_ttl, is_unicast);
*dot = '.';
}
}
}
void
-service_reply(struct interface *iface, struct sockaddr *to, const char *instance, const char *service_domain, int ttl)
+service_reply(struct interface *iface, struct sockaddr *to, const char *instance, const char *service_domain, int ttl, int force)
{
struct service *s;
continue;
if (service_domain && strcmp(s->service, service_domain))
continue;
- service_reply_single(iface, to, s, ttl, 0);
+ service_reply_single(iface, to, s, ttl, force);
}
}
extern void service_init(int announce);
extern void service_cleanup(void);
-extern void service_reply(struct interface *iface, struct sockaddr *to, const char *instance, const char *service_domain, int ttl);
+extern void service_reply(struct interface *iface, struct sockaddr *to, const char *instance, const char *service_domain, int ttl, int force);
extern void service_announce_services(struct interface *iface, struct sockaddr *to, int ttl);
extern void service_update(struct vlist_tree *tree, struct vlist_node *node_new, struct vlist_node *node_old);