]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
better libknot-2.4 fixup
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 19 Jan 2017 10:00:01 +0000 (11:00 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 19 Jan 2017 10:00:01 +0000 (11:00 +0100)
lib/utils.c
modules/cookies/cookiemonster.c
modules/cookies/cookies.mk

index 4c196a067976dbe45719046ead21b6b17599309f..76e01b7e6529e84041db0edf3e4e1ff5c104190b 100644 (file)
@@ -26,6 +26,7 @@
 #include <libknot/dname.h>
 #include <libknot/rrtype/rrsig.h>
 #include <libknot/rrset-dump.h>
+#include <libknot/version.h>
 
 #include "lib/defines.h"
 #include "lib/utils.h"
@@ -509,9 +510,17 @@ char *kr_module_call(struct kr_context *ctx, const char *module, const char *pro
 
 void kr_rrset_print(const knot_rrset_t *rr)
 {
+#if KNOT_VERSION_HEX < ((2 << 16) | (4 << 8))
        char rrtext[KNOT_DNAME_MAXLEN * 2] = {0};
        knot_rrset_txt_dump(rr, rrtext, sizeof(rrtext), &KNOT_DUMP_STYLE_DEFAULT);
        printf("%s", rrtext);
+#else
+       size_t size = 4000;
+       char *rrtext = malloc(size);
+       knot_rrset_txt_dump(rr, &rrtext, &size, &KNOT_DUMP_STYLE_DEFAULT);
+       printf("%s", rrtext);
+       free(rrtext);
+#endif
 }
 
 void kr_pkt_print(knot_pkt_t *pkt)
index fcc0489f2a07c195f640080bfd85c5ee9f4a44b0..92c170d8b02e1fe749f0edf4681f13bbd789f3aa 100644 (file)
@@ -20,6 +20,7 @@
 #include <libknot/error.h>
 #include <libknot/mm_ctx.h>
 #include <libknot/rrtype/opt-cookie.h>
+#include <libknot/version.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -259,7 +260,11 @@ int check_response(kr_layer_t *ctx, knot_pkt_t *pkt)
                return KR_STATE_FAIL;
        }
 
+#if KNOT_VERSION_HEX >= ((2 << 16) | (4 << 8)) // just renamed function since 2.4.0
        uint16_t rcode = knot_pkt_ext_rcode(pkt);
+#else
+       uint16_t rcode = knot_pkt_get_ext_rcode(pkt);
+#endif
        if (rcode == KNOT_RCODE_BADCOOKIE) {
                struct kr_query *next = NULL;
                if (!(qry->flags & QUERY_BADCOOKIE_AGAIN)) {
index 59496bcb69a674c7bc21804876c9c5714b2662c5..37c1df2b6173eea3e21a28d013ae9183a574a897 100644 (file)
@@ -1,8 +1,4 @@
 cookies_CFLAGS := -fvisibility=hidden -fPIC
-# Compat with libknot < 2.4; the identifier got renamed since 2.4.0.
-cookies_CFLAGS += $(shell pkg-config --atleast-version=2.4.0 libknot \
-                                   || echo -Dknot_pkt_ext_rcode=knot_pkt_get_ext_rcode)
-
 cookies_SOURCES := \
        modules/cookies/cookiectl.c \
        modules/cookies/cookiemonster.c \