summaryrefslogtreecommitdiff
path: root/llmnr.c
AgeCommit message (Collapse)AuthorFilesLines
2017-02-10llmnrd: Fix typo in commentTobias Klauser1-1/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-08llmnrd: Use strncasecmp() instead of open-coding itTobias Klauser1-11/+3
Use strncasecmp() from <strings.h> to compare the hostnames. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-08llmnrd: Check query name length against LLMNR_LABEL_MAX_SIZETobias Klauser1-1/+2
Make sure the hostname buffer is not accessed out of bounds. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-07llmnrd: compare full hostname in query, fix off-by-one errorTobias Klauser1-2/+8
When checking whether the hostname matches, llmnrd does not consider the last character of the hostnames, leading to the following incorrect behavior: $ ./llmnrd -H foobar Starting llmnrd on port 5355, hostname foobar ... $ ./llmnr-query foobaZ LLMNR query: foobaZ IN ANY LLMNR response: foobar IN A 10.42.0.42 (TTL 30) Fix it by considering the full hostname. Also do only convert alphabetic characters to lowercase using tolower(3), since its behavior is undefined for any other characters. Fixes #21 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-10llmnrd: Correct IPv6 check in llmnr_respond()Tobias Klauser1-1/+1
Implement the check whether IPv6 is enabled properly, checking the bool variable llmnr_ipv6 < 0 doesn't make sense. Found by the coverity scanner (CID 159830). Fixes: e9cd5a6826f1 ("llmnrd: merge rtnl interface event loop into main select() loops") Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-10llmnrd: merge rtnl interface event loop into main select() loopsTobias Klauser1-83/+6
Instead of spawming a thread for the sole purpose of watching the rtnl for (presumably) seldom events, just merge the select() for all sockets together in one single main loop. This reduces unnecessary complexity and makes llmnrd no longer require any locking. It also allows us to handle signals in a thread-safe manner (as there aren't any ;) and thus the race condition on exit reported in #20 Closes #20 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-07llmnrd: Don't busy wait in receive loopTobias Klauser1-6/+2
There is no need to have a timeout for select(2) to check llmnr_running periodically. It can just block until a packet is received and will be interrupted by any terminating signal. Closes #19 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-09-12Fix misaligned memory accessMichael Evertz1-2/+4
This changes fixes misaligned memory access. Without the patch I get several "Misaligend access trap for user program 'llmnrd'" messages on my platform if the system has odd hostname length.
2016-08-29llmnrd: Don't send empty AAAA responseTobias Klauser1-1/+8
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>
2016-08-17llmnrd: Allow to bind to a specific network interfaceTobias Klauser1-3/+5
Add a command line option -i/--interface which allows to bind the llmnrd sockets to a specific interface. If used, requests are only answered on the specified interface. Example: llmnrd -i eth0 Closes #9 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnrd: Increase select() timeoutTobias Klauser1-2/+2
There is no need to have such a short timeout value (200us), increase it to 50ms in order to reduce CPU load. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-19llmnrd: Fix address family type in event callbackTobias Klauser1-1/+2
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18llmnrd: Add IPv6 supportTobias Klauser1-42/+88
Closes #5 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18llmnrd: Join IP multicast group on each new interfaceTobias Klauser1-17/+38
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-17llmnrd: Implement message compression for nameTobias Klauser1-7/+8
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-17all: Remove unnecessary log messagesTobias Klauser1-43/+15
These could be used to DoS llmnrd, just silently discard invalid packets. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-17llmnr: Report proper address type in response for qtype ANYTobias Klauser1-1/+4
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-16llmnr: Remove some unnecessary log messagesTobias Klauser1-5/+0
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-16llmnr: Fix response packet byte order and name sizeTobias Klauser1-5/+5
We need to return type, class, ttl and rdlength in network byte order. Also we need to pkt_put() 2 bytes in addition to the hostname length (length and NULL byte). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-16llmnr: Unindent llmnr_respond()Tobias Klauser1-87/+89
Exit out early if the query class is not LLMNR_QCLASS_IN. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-16pkt: Implement growing of packet on pkt_putTobias Klauser1-1/+1
Also get rid of the unnecessary head member of struct pkt. For now we only append data at the end of a packet. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-16all: Remove trailing whitespacesTobias Klauser1-5/+5
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-06Initial import, still work in progressTobias Klauser1-0/+293