summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2018-02-11Makefile: assign CC conditionallympvader1-1/+1
Only assign CC if its not yet defined. The Yocto SDK sets CC as an env variable, including --sysroot and various other parameters. This change fixes the Makefile for using with Yocto SDK.
2017-10-18llmnrd v0.5v0.5Tobias Klauser1-1/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-03-16make: add -Wextra to CFLAGS_WARN, sort additional warning flagsTobias Klauser1-4/+14
Enable -Wextra, sort warning flags in CFLAGS_WARN alphabetically to avoid adding duplicates. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-03-07make: install manpages in 'install' targetTobias Klauser2-0/+14
gzip and install the manpages for llmnrd and llmnr-query in the Makefile's 'install' target. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-03-07doc: add manpages for llmnrd and llmnr-queryTobias Klauser2-0/+78
Add rudimentary manpages for llmnrd and llmnr-query describing their usage. Fixes #14 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-28llmnrd: Update copyright in version informationTobias Klauser1-1/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-28llmnrd: Poll hostnameTobias Klauser3-3/+39
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>
2017-02-28README.md: Acknowledge @tbetkerTobias Klauser1-2/+3
Acknowledge @tbetker for issues #22 and #23 and the patches provided therein. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-28llmnr-query: Fix missing NULL byteTobias Klauser1-3/+4
If the domain name in the response is <len> <octets> <00>, the code copies 'len' octets to name[], but does not add a terminating NULL character. The same may happen in the "compression" case. Fix this by adding a NULL byte in both cases. Patch constributed by @tbetker. Fixes #22 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-10llmnrd v0.4v0.4Tobias Klauser1-1/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-10llmnrd: Fix typo in commentTobias Klauser1-1/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-09llmnr-query: Allocate receive buffer large enoughTobias Klauser1-1/+4
If an LLMNR response exceeds 128 bytes, it will get truncated. This leads to out-of-bounds read access during parsing and causes garbage data to be printed. Fix it by allocating the buffer large enough (according to RFC). Possible future improvment would be to consider the link MTU size to save some memory. Fixes #21 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-09llmnr-query: Fix two cases where misaliged access could occurTobias Klauser1-10/+12
Two places where a misaliged could occur were missed in commit 7f719d2 ("llmnr-query: Extract LLMNR packet data in an alignment-safe way"). Fix them now. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-08debian: remove debian packaging filesTobias Klauser9-76/+0
There is now an official package in the Debian package repository [1] which should be used instead of locally built packages. Drop the local packaging file which anyway no longer match the version in Debian. [1] https://packages.debian.org/sid/llmnrd Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-08llmnr-query: Extract LLMNR packet data in an alignment-safe wayTobias Klauser2-7/+24
Follow commit 9bec6fb9 ("Fix misaligned memory access") for llmnr-query and extract values from the response packets in a way that doesn't cause unaligned memory access on architectures that don't support it. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-08llmnr-query: Account for terminating NULL byte in address string bufferTobias Klauser1-1/+2
If the IPv6 address in the reply is 48 bytes long, inet_ntop() would overflow the addr buffer. Account for the terminating NULL byte. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-08iface: Merge duplicate codeTobias Klauser2-20/+10
Call iface_recv() from iface_rtnl_enumerate() instead of open-coding it. Reorder code a bit to avoid duplication. 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-02-07socket: ignore EADDRINUSE when joining multicast groupTobias Klauser1-6/+16
If an interface is configured with multiple addresses, llmnrd tries to join the LLMNR multicast group for each address instead of once per interface. Ideally llmnrd should track whether the group is already joined but since the kernel tells us that the group is already joined, just omit the error message on EADDRINUSE. This fixes the following error case: $ ip address add 2001:db8:1::/48 dev eth0 $ ./llmnrd -6 Starting llmnrd on port 5355, hostname foobar Added IPv4 address 127.0.0.1 on interface lo Added IPv4 address 10.42.0.42 on interface eth0 Added IPv6 address ::1 on interface lo Added IPv6 address 2001:db8:1:: on interface eth1 Error: Failed to join IPv6 multicast group on interface eth1: Address already in use Added IPv6 address fe80::xxxx:xxxx:xxxx:xxxx on interface eth0 Reference: #21 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-25llmnrd v0.3v0.3Tobias Klauser1-1/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-13illmnr-query: Add const qualifier to name variableTobias Klauser1-1/+1
This fixes the following GCC warning: llmnr-query.c:345:12: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-13util: Add printf format GCC attribute to panic() functionTobias Klauser2-2/+8
This fixes the following GCC warning: util.h:55:2: warning: function might be possible candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-13make: Enable additional GCC warningsTobias Klauser1-1/+6
Enable some sensible GCC warnings for default build. The list of flags was based on the flags from the nftables source. 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 Klauser6-178/+116
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-09make: Append instead of override CPPFLAGS and CFLAGS passed by userTobias Klauser1-6/+7
Distribution build scripts commonly assume the CPPFLAGS, CFLAGS and LDFLAGS passed via command line or environment to be appended to the base set of flags defined in the Makefile. Follow this assumption instead of overriding the already defined values. Also treat these three variables entriely independently instead of appending CPPFLAGS to CFLAGS. Reported-by: @pali Really-fixes: #17 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-09make: don't show echo commands in verbose modeTobias Klauser1-8/+13
Avoid echoing the CC/LD string in verbose mode, just show the plain commands: $ make Q= gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o llmnr.o -c llmnr.c gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o iface.o -c iface.c gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o socket.o -c socket.c gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o util.o -c util.c gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o llmnrd.o -c llmnrd.c gcc -o llmnrd llmnr.o iface.o socket.o util.o llmnrd.o -lpthread gcc -W -Wall -DVERSION_STRING=\"v0.2.1\" -DGIT_VERSION=\""(git id v0.2.1-6-gab7cd2fc9043)"\" -O2 -o llmnr-query.o -c llmnr-query.c gcc -o llmnr-query util.o llmnr-query.o Also consider $(Q) for the clean and install targets. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-07make: Support CPPFLAGS in MakefileHEADmasterTobias Klauser1-2/+3
Currently Makefile ignores CPPFLAGS and so any defines passed via environment/command line ignored. E.g. running make CPPFLAGS="-D_FORTIFY_SOURCE=2" does not compile llmnrd with buffer overflow checks. Fix it by considering CPPFLAGS in the Makefile and appending them to CFLAGS. Closes #17 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>
2017-01-06compiler: Avoid redefinitions of __unused and __packedTobias Klauser1-2/+6
FreeBSD defines these in sys/cdefs.h Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-06llmnr-query: Add support for FreeBSD and DarwinTobias Klauser1-2/+34
Make llmnr-query work on FreeBSD and Darwin by using sendmsg() to send UDP packets. Using sendto() doesn't seem to work for IPv6 sockets. Also specify the size of the corresponding sockaddr type, not of sockaddr_storage. Tested on FreeBSD 11.0, Mac OS X 10.11. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-06llmnr-query: Update copyrightTobias Klauser1-3/+3
Also change the description slightly and mention the LLMNR RFC number. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-06llmnr-query: Only calculate query length if send was successfulTobias Klauser1-2/+3
Also add a comment indicating the repurposing of the pkt struct. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-22llmnrd v0.2.1v0.2.1Tobias Klauser1-1/+1
Bugfix release to create source packages without debian packaging information. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-22build: Add release targetTobias Klauser1-0/+15
Add a release target to the Makefile (akin to the one from netsniff-ng) in order to streamline the release process. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-22README.md: Add basic usage informationTobias Klauser1-3/+30
Add a small section about basic usage of llmnrd/llmnr-query. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-22README.md: Acknowledge Pali RohárTobias Klauser1-2/+3
Acknowledge Pali Rohár for feedback and contributions regarding packaging for Debian. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-22Add .gitattributesTobias Klauser1-0/+4
Ignore dotfiles and debian packaging in exports. The reason for excluding the debian/ directory is that Debian preferes upstream source packages to not contain devian packaging info. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-21llmnrd v0.2v0.2Tobias Klauser1-1/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-01README.md: Acknowledge Elazar LeibovichTobias Klauser1-0/+1
Add Elazar Leibovich to the list of contributors for #12, #13 and commit 0c6df1b8 ("debian: add debian packaging files"). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-01debian: add debian packaging filesElazar Leibovich8-0/+75
This allows to build a debian package by running debuild, fixes #12. Signed-off-by: Elazar Leibovich <elazarl@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-09-12README.md: Add Travis CI and Coverity Scanner status badgesTobias Klauser1-0/+3
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-09-12README: Convert to markdownTobias Klauser1-24/+29
Convert the README file to markdown syntax so we get the nice rendering on GitHub. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-09-12README: Acknowledge all the contributors so farTobias Klauser1-2/+12
Mention all people how contributed to the development of llmnrd in one way or another. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-09-12Fix misaligned memory accessMichael Evertz2-4/+6
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 Klauser7-14/+55
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-16llmnrd: Don't enumerate and store IPv6 addresses if IPv6 is disabledTobias Klauser5-13/+21
Currently IPv6 addresses are always enumerated via RTNL socket and then stored internally, even if llmnrd was started without the IPv6 command line option '-6'. Even though no queries on AF_INET6 sockets will be answered, this behavior might be confusing. Especially due to messages like: Added IPv6 address fe80::f0eb:aaff:feb3:ae58 on interface tap0 being logged. Explicitely disable IPv6 address enumeration on the RTNL socket to fix this behavior. Closes #8 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>