Skip to content

Commit

Permalink
llmnrd: Don't send empty AAAA response
Browse files Browse the repository at this point in the history
Don't send an AAAA response if IPv6 is disabled or if no address of the
requested address family was found for a given interface.

Closes #10
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  • Loading branch information
tklauser committed Aug 29, 2016
1 parent f46d59e commit d4ae5d9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion llmnr.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,14 @@ static void llmnr_respond(unsigned int ifindex, const struct llmnr_hdr *hdr,
qtype = ntohs(*((uint16_t *)query_name_end));
qclass = ntohs(*((uint16_t *)query_name_end + 1));

/* Ony IN queries supported */
/* Only IN queries supported */
if (qclass != LLMNR_QCLASS_IN)
return;

/* No AAAA responses if IPv6 is disabled */
if (llmnr_sock_ipv6 < 0 && qtype == LLMNR_QTYPE_AAAA)
return;

switch (qtype) {
case LLMNR_QTYPE_A:
family = AF_INET;
Expand All @@ -146,6 +150,9 @@ static void llmnr_respond(unsigned int ifindex, const struct llmnr_hdr *hdr,
}

n = iface_addr_lookup(ifindex, family, addrs, ARRAY_SIZE(addrs));
/* Don't respond if no address was found for the given interface */
if (n == 0)
return;

/*
* This is the max response length (i.e. using all IPv6 addresses and
Expand Down

0 comments on commit d4ae5d9

Please sign in to comment.