From d4ae5d9bb723e2ec2fcbaaa954cb76312bca1e7a Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 29 Aug 2016 11:21:04 +0200 Subject: 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 --- llmnr.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-54-g00ecf