summaryrefslogtreecommitdiff
path: root/llmnr.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2016-08-29 11:21:04 +0200
committerTobias Klauser <tklauser@distanz.ch>2016-08-29 11:21:04 +0200
commitd4ae5d9bb723e2ec2fcbaaa954cb76312bca1e7a (patch)
treeb5a6707d6f7ae01d3da378acfcd6e62e8e2d2b94 /llmnr.c
parentf46d59e0dc7b54a3f4a7ead2fd2d4258b3f56782 (diff)
llmnrd: Don't send empty AAAA response
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>
Diffstat (limited to 'llmnr.c')
-rw-r--r--llmnr.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/llmnr.c b/llmnr.c
index 206f165..3090845 100644
--- a/llmnr.c
+++ b/llmnr.c
@@ -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;
@@ -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