diff --git a/README.md b/README.md index 25acbf60afe04ec517a9809d2632cc63f4d6b6c5..aa1cd2d1098a4dddad3d70536547df5a86624ea9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,38 @@ # Knot DNS Resolver +## Preparation + +The Knot DNS Resolver depends on the Knot DNS library which is introduced in current master, and on the +reasonably recent version of the `libuv`. + +### libuv + +If the libuv with a version at least 1.0 is not present on your system, +compile and install the sources code from the Git repository. + +``` +$ git clone https://github.com/joyent/libuv.git +$ cd libuv +$ ./autogen.sh +$ make && make install +``` + ## Compilation -./configure -make +``` +$ export PKG_CONFIG_PATH="..." # Change, if you installed the libknot somewhere else +$ ./configure +$ autoreconf -if +$ make +``` + +## Running + +There is a separate resolver library in the `lib` directory, and a minimalistic daemon in +the `daemon` directory. The daemon accepts a few CLI parameters, and there's no support for configuration +right now. + +``` +$ ./daemon/kresolved -h +$ ./daemon/kresolved -a 127.0.0.1#53 +``` diff --git a/configure.ac b/configure.ac index 93fc7ef239b7eb0056f8903aa37332590350e7a6..0244bb04ea297a6175c07e6e298c6fb64d360313 100644 --- a/configure.ac +++ b/configure.ac @@ -30,13 +30,10 @@ LT_INIT PKG_PROG_PKG_CONFIG # Check for dependencies -AM_CHECK_CMOCKA -AM_CHECK_LIBUV +PKG_CHECK_MODULES([libuv], [libuv]) +PKG_CHECK_MODULES([libknot], [libknot]) -# Check headers -AC_CHECK_HEADERS([stdlib.h],,, [AC_INCLUDES_DEFAULT]) - -# Search libraries +# Search other libraries AC_SEARCH_LIBS([mdb_env_open], [lmdb]) # Config files @@ -53,9 +50,8 @@ AC_MSG_RESULT([ Target: $host_os $host_cpu Compiler: ${CC} - CFlags: ${CFLAGS} ${CPPFLAGS} - LDFlags: ${LDFLAGS} - Libs: ${LIBS} + CFlags: ${CFLAGS} ${CPPFLAGS} ${libuv_CFLAGS} ${libknot_CFLAGS} + LDFlags: ${LDFLAGS} ${libuv_LIBS} ${libknot_LIBS} Continue with 'make' command ]) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 5544b0f3ed7ced5141434e1c7af46868d1a38367..a9a6c15af4a6d7ec8cf6a53b58bc698ceea7edc0 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -1,8 +1,10 @@ AM_CPPFLAGS = \ -include $(top_builddir)/config.h \ - -I$(top_srcdir)/lib + -I$(top_srcdir)/lib \ + $(libuv_CFLAGS) \ + $(libknot_CFLAGS) -sbin_PROGRAMS = kresolved +sbin_PROGRAMS = kresolved kresolved_SOURCES = \ layer/query.h \ @@ -12,6 +14,4 @@ kresolved_SOURCES = \ main.c # sbin programs -kresolved_LDADD = $(top_builddir)/lib/libknotresolve.la \ - $(KNOT_LIBS) \ - $(libuv_LIBS) +kresolved_LDADD = $(top_builddir)/lib/libknotresolve.la diff --git a/daemon/main.c b/daemon/main.c index f18e976c69f019ebcab22865c653fccf6152dee1..3813c9d28f0e373c0d99bbc6318a3e51bd50bffc 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -4,7 +4,7 @@ #include <uv.h> -#include <common/sockaddr.h> +#include <libknot/internal/sockaddr.h> #include "lib/resolve.h" #include "worker.h" diff --git a/daemon/worker.c b/daemon/worker.c index 4c752882e56e501f7ff9620cd0bcc158a7f614d3..ffcca56ca280df5bafc135d3687110fa3108aa07 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -1,7 +1,7 @@ #include <uv.h> #include <libknot/packet/pkt.h> -#include <common/net.h> +#include <libknot/internal/net.h> #include "daemon/worker.h" #include "daemon/layer/query.h" diff --git a/daemon/worker.h b/daemon/worker.h index f4efd10f8206f70e86c4527e3f8b7554b68e786b..06589fa21cbf470d88c27726fe04a2eeab932c25 100644 --- a/daemon/worker.h +++ b/daemon/worker.h @@ -17,7 +17,7 @@ limitations under the License. #include <uv.h> -#include <common/mempattern.h> +#include <libknot/internal/mempattern.h> #include "lib/resolve.h" struct worker_ctx { diff --git a/lib/Makefile.am b/lib/Makefile.am index 7686f19dccdd74b2d829fe607059114eefbe8176..f02ae4e9eeb8547e9f91e8a95c7ce280bc1a2f3d 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -20,3 +20,6 @@ libknotresolve_la_SOURCES = \ rplan.c \ cache.h \ cache.c + +libknotresolve_la_CPPFLAGS = $(AM_CPPFLAGS) $(libknot_CFLAGS) $(libuv_CFLAGS) +libknotresolve_la_LDFLAGS = $(AM_LDFLAGS) $(libknot_LIBS) $(libuv_LIBS) diff --git a/lib/cache.c b/lib/cache.c index dcd345d19863e7c34f88310ec45a0beb65bc8f3b..40d1a83e42c84a68bd4ec63d7643e3c8d499362e 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -2,7 +2,7 @@ #include <time.h> #include <lmdb.h> -#include <common/mempattern.h> +#include <libknot/internal/mempattern.h> #include <libknot/descriptor.h> #include "lib/cache.h" diff --git a/lib/context.c b/lib/context.c index 823f64e98dd62138365d75b2b1064f453a1e36c0..11932edbd100733e57ea6e473f043525417cb064 100644 --- a/lib/context.c +++ b/lib/context.c @@ -1,7 +1,7 @@ #include <string.h> #include <sys/time.h> -#include <common/sockaddr.h> +#include <libknot/internal/sockaddr.h> #include "lib/context.h" #include "lib/rplan.h" diff --git a/lib/context.h b/lib/context.h index 1e8960cbd81324f6cc5337cc6534d31ab1d13fdd..17a8c20eeb3f3b4f2a7682e7de355051069b8d23 100644 --- a/lib/context.h +++ b/lib/context.h @@ -16,8 +16,9 @@ limitations under the License. #pragma once #include <stdint.h> -#include <common/mempattern.h> -#include <common/sockaddr.h> + +#include <libknot/internal/mempattern.h> +#include <libknot/internal/sockaddr.h> #include "lib/delegpt.h" #include "lib/rplan.h" diff --git a/lib/delegpt.c b/lib/delegpt.c index a101ddbdf23996ee0b8645e5de988ffe3de00584..681908538fed0104462dc1098684d6645d54c46e 100644 --- a/lib/delegpt.c +++ b/lib/delegpt.c @@ -1,6 +1,6 @@ #include "lib/delegpt.h" #include "lib/defines.h" -#include <common/mempool.h> +#include <libknot/internal/mempool.h> static void ns_free(struct kr_ns *ns, mm_ctx_t *mm) { @@ -135,4 +135,4 @@ void kr_ns_remove(struct kr_ns *ns, mm_ctx_t *mm) { rem_node((node_t *)ns); ns_free(ns, mm); -} \ No newline at end of file +} diff --git a/lib/delegpt.h b/lib/delegpt.h index a2841515f7acbc74ff534e368dcc0ee2a68abd77..35f97fde529df846b424bc3a9be66b86550a5af3 100644 --- a/lib/delegpt.h +++ b/lib/delegpt.h @@ -16,9 +16,9 @@ limitations under the License. #pragma once #include <libknot/packet/pkt.h> -#include <common/lists.h> -#include <common/sockaddr.h> -#include <common/trie/hat-trie.h> +#include <libknot/internal/lists.h> +#include <libknot/internal/sockaddr.h> +#include <libknot/internal/trie/hat-trie.h> /*! \brief Name server flag. */ enum kr_ns_flag { diff --git a/lib/layer.h b/lib/layer.h index c1ec9d194e4bba1c9ad1eec5c2613d9dbbb4cd16..780c09129b8c3efe9745ab82e89ba6e22546964e 100644 --- a/lib/layer.h +++ b/lib/layer.h @@ -16,6 +16,7 @@ limitations under the License. #pragma once #include <libknot/processing/layer.h> + #include "lib/context.h" /*! @@ -24,4 +25,4 @@ limitations under the License. struct kr_layer_param { struct kr_context *ctx; struct kr_result *result; -}; \ No newline at end of file +}; diff --git a/lib/layer/stats.c b/lib/layer/stats.c index e696f7641e534eb98064228a12427a48acdc8603..6da50ebf7040e1294fbd9f0f6c773e27ebd74410 100644 --- a/lib/layer/stats.c +++ b/lib/layer/stats.c @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -#include <common/print.h> +#include <libknot/internal/print.h> #include "lib/layer/stats.h" #include "lib/rplan.h" diff --git a/lib/rplan.h b/lib/rplan.h index d7fd5eb022aeacfc6a650499f9ec8ae7e517aa70..555dc1b810387b79696f822863a422a4e184e884 100644 --- a/lib/rplan.h +++ b/lib/rplan.h @@ -16,7 +16,7 @@ limitations under the License. #pragma once #include <libknot/dname.h> -#include <common/lists.h> +#include <libknot/internal/lists.h> enum { RESOLVE_QUERY = 0 << 0, diff --git a/m4/libcmocka.m4 b/m4/libcmocka.m4 deleted file mode 100644 index 539c0ac7ae6a02f53c3c295e8c491dc46029c2ea..0000000000000000000000000000000000000000 --- a/m4/libcmocka.m4 +++ /dev/null @@ -1,19 +0,0 @@ -dnl A macro to check presence of cmocka on the system -AC_DEFUN([AM_CHECK_CMOCKA], -[ - PKG_CHECK_EXISTS(cmocka, - [AC_CHECK_HEADERS([stdarg.h stddef.h setjmp.h], - [], dnl We are only intrested in action-if-not-found - [AC_MSG_WARN([Header files stdarg.h stddef.h setjmp.h are required by cmocka]) - cmocka_required_headers="no" - ] - ) - AS_IF([test x"$cmocka_required_headers" != x"no"], - [PKG_CHECK_MODULES([cmocka], [cmocka], [have_cmocka="yes"])] - )], - dnl PKG_CHECK_EXISTS ACTION-IF-NOT-FOUND - [AC_MSG_WARN([No libcmocka library found, cmocka tests will not be built])] - ) - AM_CONDITIONAL([HAVE_CMOCKA], [test x$have_cmocka = xyes]) -]) - diff --git a/m4/liblmdb.m4 b/m4/liblmdb.m4 deleted file mode 100644 index 6acfdd8ad4a6f55d4cec56e125b40158e3a255a2..0000000000000000000000000000000000000000 --- a/m4/liblmdb.m4 +++ /dev/null @@ -1,19 +0,0 @@ -dnl A macro to check presence of liblmdb on the system -AC_DEFUN([AM_CHECK_LMDB], -[ - PKG_CHECK_EXISTS(lmdb, - [AC_CHECK_HEADERS([lmdb.h], - [], dnl We are only intrested in action-if-not-found - [AC_MSG_WARN([Header file lmdb.h is required.]) - lmdb_required_headers="no" - ] - ) - AS_IF([test x"$lmdb_required_headers" != x"no"], - [PKG_CHECK_MODULES([lmdb], [lmdb], [have_lmdb="yes"])] - )], - dnl PKG_CHECK_EXISTS ACTION-IF-NOT-FOUND - [AC_MSG_WARN([No lmdb library found.])] - ) - AM_CONDITIONAL([HAVE_LMDB], [test x$have_lmdb = xyes]) -]) - diff --git a/m4/libuv.m4 b/m4/libuv.m4 deleted file mode 100644 index ab41a702a75292c695656c5519ffab23d1ffdc70..0000000000000000000000000000000000000000 --- a/m4/libuv.m4 +++ /dev/null @@ -1,7 +0,0 @@ -dnl A macro to check presence of libuv on the system -AC_DEFUN([AM_CHECK_LIBUV], -[ - AC_CHECK_HEADERS([uv.h], [], [AC_MSG_ERROR([Header file uv.h is required.])]) - AC_CHECK_LIB([uv], [uv_version], [], [AC_MSG_ERROR([libuv is required.])]) -]) - diff --git a/tests/Makefile.am b/tests/Makefile.am index dab72e6d4355748d5d76a57cda0d59c483765d2b..544cf3c93df2034fa79c78764d3bc6010b83fd49 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,8 +4,6 @@ AM_CPPFLAGS = \ LDADD = \ $(top_builddir)/lib/libknotresolve.la \ - $(KNOT_LIBS) \ - $(libuv_LIBS) \ $(cmocka_LIBS) check_PROGRAMS = \