Age | Commit message (Collapse) | Author | Files | Lines |
|
As per RFC 4795, section 2.1.1:
The 'TC' bit MUST NOT be set in an LLMNR query and, if set, is ignored
by an LLMNR responder.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Poll "/proc/sys/kernel/hostname" and update the hostname when it was
changed. systemd has a similar mechanism.
Note that the hostname is not polled if it has been provided on the
command line, or if "/proc/sys/kernel/hostname" cannot be opened.
Patch contributed by @tbetker
Fixes #23
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Use strncasecmp() from <strings.h> to compare the hostnames.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Make sure the hostname buffer is not accessed out of bounds.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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.
|
|
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>
|
|
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>
|
|
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>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Closes #5
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
These could be used to DoS llmnrd, just silently discard invalid
packets.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
Exit out early if the query class is not LLMNR_QCLASS_IN.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
|