DBG(1, "Q <- %s %s\n", dns_type_string(type), question);
if (interface_send_packet(iface, NULL, iov, ARRAY_SIZE(iov)) < 0)
- perror("failed to send question :");
+ perror("failed to send question");
}
}
if (interface_send_packet(iface, to, iov, n_iov) < 0)
- fprintf(stderr, "failed to send question\n");
+ perror("failed to send answer");
}
void
static void
parse_question(struct interface *iface, struct sockaddr *from, char *name, struct dns_question *q)
{
- struct sockaddr *to;
+ struct sockaddr *to = NULL;
char *host;
/* TODO: Multicast if more than one quarter of TTL has passed */
- if ((q->class & CLASS_UNICAST) && iface->multicast) {
- iface = iface->peer;
+ if (q->class & CLASS_UNICAST) {
to = from;
- } else {
- to = NULL;
+ if (iface->multicast)
+ iface = iface->peer;
}
DBG(1, "Q -> %s %s\n", dns_type_string(q->type), name);
break;
case TYPE_PTR:
- if (!strcmp(name, sdudp)) {
+ if (!strcmp(name, C_DNS_SD)) {
dns_reply_a(iface, to, announce_ttl);
service_announce_services(iface, to, announce_ttl);
} else {
return;
}
- if (h->questions && !iface->multicast && port != 5353)
+ if (h->questions && !iface->multicast && port != MCAST_PORT)
/* silently drop unicast questions that dont originate from port 5353 */
return;