Skip to content

Commit 6079636

Browse files
committed
dns: add support for Legacy Unicast Responses
As per RFC 6762 Section 6.7 (Legacy Unicast Responses) "If the source UDP port in a received Multicast DNS query is not port 5353, this indicates that the querier originating the query is a simple resolver such as described in Section 5.1, "One-Shot Multicast DNS Queries", which does not fully implement all of Multicast DNS. In this case, the Multicast DNS responder MUST send a UDP response directly back to the querier, via unicast, to the query packet's source IP address and port. This unicast response MUST be a conventional unicast response as would be generated by a conventional Unicast DNS server; for example, it MUST repeat the query ID and the question given in the query message." Therefore, umdns should not ignore DNS questions coming from non- multicast sources, and also provide question section which is not usually provided in mDNS responses. Signed-off-by: Mohd Husaam Mehdi <husaam.mehdi@iopsys.eu>
1 parent 1d513b8 commit 6079636

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

dns.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,17 @@ parse_question(struct interface *iface, struct sockaddr *from, char *name, struc
393393
char *host;
394394

395395
/* TODO: Multicast if more than one quarter of TTL has passed */
396-
if (is_unicast) {
396+
if (is_unicast || port != MCAST_PORT) {
397397
to = from;
398398
if (interface_multicast(iface))
399399
iface = interface_get(iface->name, iface->type | SOCKTYPE_BIT_UNICAST);
400+
} else {
401+
/* if the query is from multicast port, no need for original buffer
402+
* while responding as per rfc 6762, section 6:
403+
* Multicast DNS responses MUST NOT contain any questions in the
404+
* Question Section. */
405+
orig_buffer = NULL;
406+
orig_len = 0;
400407
}
401408

402409
DBG(1, "Q -> %s %s\n", dns_type_string(q->type), name);
@@ -465,10 +472,6 @@ dns_handle_packet(struct interface *iface, struct sockaddr *from, uint16_t port,
465472
return;
466473
}
467474

468-
if (h->questions && !interface_multicast(iface) && port != MCAST_PORT)
469-
/* silently drop unicast questions that dont originate from port 5353 */
470-
return;
471-
472475
while (h->questions-- > 0) {
473476
char *name = dns_consume_name(buffer, len, &b, &rlen);
474477
struct dns_question *q;

0 commit comments

Comments
 (0)