summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
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>
2016-08-03llmnrd v0.1v0.1Tobias Klauser1-2/+2
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-03llmnr-query: Prevent read buffer overflow in response parsingTobias Klauser1-2/+6
When accessing the compressed name in a response, verify that the pointer is within the packet size. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnrd: Use MAXHOSTNAMELEN for hostname buffer and zero-terminate stringTobias Klauser1-3/+4
Use MAXHOSTNAMELEN defined in sys/param.h to determine the size of the hostname buffer to allocate. Also make sure the string is properly zero-terminated in all cases, as in some cases it might be undefined whether a truncated string is properly terminated. Note: Also remove a TODO comment, as watching for hostname changes at runtime is outside the scope of llmnrd (also, avahi behaves the same). 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>
2016-08-02Add simple systemd service fileTobias Klauser1-0/+11
Add a simple example of a systemd service file as a base for e.g. distribution service files. Fixes #3 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnrd: Update copyrightTobias Klauser1-2/+2
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnr-query: Allow to set LLMNR transaction idTobias Klauser1-3/+8
Allow to override the transaction id in the LLMNR query header. Default value is 0. The id will be incremented for consecutive queries (i.e. count > 1). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnr-packet: Correct LLMNR RFC numberTobias Klauser1-4/+4
Fix typo in RFC number, make writing of "RFC NNNN" consistent. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnr-query: Make query type ANY the defaultSchimmelreiter1-2/+2
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnr-query: Set TTL values as suggested in RFC 4795, section 2.5Tobias Klauser1-2/+27
Follow commit 64644dde ("socket: Set TTL values as suggested in RFC 4795, section 2.5") and set the TTL of the IP header to 255 for UDP unicast and multicast packets, as recommended in RFC 4795, section 2.5. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02socket: Set TTL values as suggested in RFC 4795, section 2.5Tobias Klauser1-1/+24
Set the TTL of the IP header to 255 for UDP unicast and multicast packets, as recommended in RFC 4795, section 2.5. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-04-29iface: Close rtnl socket if address enumeration failsTobias Klauser1-2/+2
Fix a resource leak by closing the socket if iface_rtnl_enumerate() fails. Discovered by the Coverity scanner CID 99694. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-04-29iface: Fix memory leak in error caseTobias Klauser1-0/+3
If add from leaking in case the address was (unexpectedly) not found. This addresses CID 99695 discovered by the Coverity scanner. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-04-29iface: Use getnameinfo() to get address from struct sockaddr_storageTobias Klauser1-2/+5
Use getnameinfo() instead of inet_ntop() with weird (and incorrect) pointer arithmetics to get the numeric address from a struct sockaddr_storage. This addresses CID 99692 & 99696 discovered by the Coverity scanner. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-04-29llmnrd: Use SA_RESTART for installed signal handlersTobias Klauser1-0/+1
Make certain syscalls restartable after signal handler. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-04-29llmnrd: Add missing break in switchTobias Klauser1-0/+1
Discovered by the Coverity scanner CID 99693. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-04-28COPYING: Add verbatim copy of GPLv2Tobias Klauser1-0/+339
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-04-28build: travis: Set up Coverity scanTobias Klauser1-0/+14
Set up Travis CI integration for Coverity scan. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-26build: Fix install targets for use with DESTDIRTobias Klauser1-2/+2
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-07-28llmnr-query: Consistently name variables containing number of msecsTobias Klauser1-7/+7
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-07-01llmnr-query: Allow to specifiy query timeout on command lineTobias Klauser1-5/+10
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-04-08socket: Remove unused constantTobias Klauser1-1/+0
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-04-08util: Add attribute warn_unused_result to allocation functionsTobias Klauser2-4/+5
Add the warn_unused_result GCC function attribute to all allocation functions in xmalloc. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>