uint16_t compress_ptr[16];
} knot_rrinfo_t;
typedef unsigned char knot_dname_t;
+typedef struct {
+ uint16_t len;
+ uint8_t data[];
+} knot_rdata_t;
+typedef struct {
+ uint16_t count;
+ uint32_t size;
+ knot_rdata_t *rdata;
+} knot_rdataset_t;
typedef struct knot_mm {
void *ctx, *alloc, *free;
knot_section_t
knot_rrinfo_t
knot_dname_t
- #knot_rdata_t
- #knot_rdataset_t
+ knot_rdata_t
+ knot_rdataset_t
EOF
# The generator doesn't work well with typedefs of functions.
uint16_t sa_family;
uint8_t _stub[]; /* Do not touch */
};
+
struct knot_error {
int code;
};
int gettimeofday(struct timeval *tv, struct timezone *tz);
]]
-
--- TMP: compatibility with both libknot 2.8 and 2.9
-local knot_rdataset_t_cdef
-local sover_pos = string.find(libknot_SONAME, '%d')
-if not sover_pos then
- error('unexpected libknot soname: ' .. libknot_SONAME)
-end
-local sover = string.sub(libknot_SONAME, sover_pos , sover_pos)
-if sover == '9' then
- knot_rdataset_t_cdef = [[
- typedef struct {
- uint16_t count;
- knot_rdata_t *rdata;
- } knot_rdataset_t;
- ]]
-elseif sover == '1' then -- it's 10 really, but this is simpler
- knot_rdataset_t_cdef = [[
- typedef struct {
- uint16_t count;
- uint32_t size;
- knot_rdata_t *rdata;
- } knot_rdataset_t;
- ]]
-else
- error('unexpected libknot version: ' .. sover)
-end
-ffi.cdef([[
- typedef struct {
- uint16_t len;
- uint8_t data[];
- } knot_rdata_t;
- ]] .. knot_rdataset_t_cdef)
-
-
require('kres-gen')
-- Error code representation
libedit-dev,
libfstrm-dev,
libgnutls28-dev,
- libknot-dev (>= 2.8),
+ libknot-dev (>= 2.9),
liblmdb-dev,
libluajit-5.1-dev,
libnghttp2-dev,
BuildRequires: pkgconfig(cmocka)
BuildRequires: pkgconfig(gnutls)
BuildRequires: pkgconfig(libedit)
-BuildRequires: pkgconfig(libknot) >= 2.8
-BuildRequires: pkgconfig(libzscanner) >= 2.8
-BuildRequires: pkgconfig(libdnssec) >= 2.8
+BuildRequires: pkgconfig(libknot) >= 2.9
+BuildRequires: pkgconfig(libzscanner) >= 2.9
+BuildRequires: pkgconfig(libdnssec) >= 2.9
BuildRequires: pkgconfig(libnghttp2)
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(libcap-ng)
"meson >= 0.46", "*build only* [#]_"
"C and C++ compiler", "*build only* [#]_"
"`pkg-config`_", "*build only* [#]_"
- "libknot_ 2.8+", "Knot DNS libraries"
+ "libknot_ 2.9+", "Knot DNS libraries"
"LuaJIT_ 2.0+", "Embedded scripting language"
"libuv_ 1.7+", "Multiplatform I/O and services"
"lmdb", "Memory-mapped database for cache"
* Module ``dnstap``: option ``log_responses`` has been moved inside a new ``client`` section. Refer to the configuration example in :ref:`mod-dnstap`.
+Packagers & Developers
+----------------------
+
+* Knot DNS >= 2.9 is required.
5.1 to 5.2
==========
memcpy(data, &rr_count, sizeof(rr_count));
data += sizeof(rr_count);
if (rr_count) {
- size_t size = knot_rdataset_size(rds);
- memcpy(data, rds->rdata, size);
- data += size;
+ memcpy(data, rds->rdata, rds->size);
+ data += rds->size;
}
//VERBOSE_MSG(NULL, "dematerialized to %d B\n", (int)(data - data0));
(void)data;
const uint8_t *d = data; /* iterates over the cache data */
/* First sum up the sizes for wire format length. */
/* TODO: we might overrun here already, but we need to trust cache anyway...*/
- const uint32_t rds_size = rdataset_dematerialized_size(d, &rds->count);
+ rds->size = rdataset_dematerialized_size(d, &rds->count);
d += KR_CACHE_RR_COUNT_SIZE;
- #if KNOT_VERSION_HEX >= 0x020900
- rds->size = rds_size;
- #endif
- if (d + rds_size > data_bound) {
+ if (d + rds->size > data_bound) {
VERBOSE_MSG(NULL, "materialize: EILSEQ!\n");
return kr_error(EILSEQ);
}
rds->rdata = NULL;
return d - data;
}
- rds->rdata = mm_alloc(pool, rds_size);
+ rds->rdata = mm_alloc(pool, rds->size);
if (!rds->rdata) {
return kr_error(ENOMEM);
}
- memcpy(rds->rdata, d, rds_size);
- d += rds_size;
+ memcpy(rds->rdata, d, rds->size);
+ d += rds->size;
//VERBOSE_MSG(NULL, "materialized from %d B\n", (int)(d - data));
return d - data;
}
/** Compute size of serialized rdataset. NULL is accepted as empty set. */
static inline int rdataset_dematerialize_size(const knot_rdataset_t *rds)
{
- return KR_CACHE_RR_COUNT_SIZE + (rds == NULL ? 0 : knot_rdataset_size(rds));
+ return KR_CACHE_RR_COUNT_SIZE + (rds == NULL ? 0 : rds->size);
}
/** Analyze the length of a dematerialized rdataset.
}
}
/* Prepare rdataset, except rdata contents. */
- int size_sum = 0;
+ knot_rdataset_t *rds = &stashed->rr->rrs;
+ rds->size = 0;
for (int i = 0; i < ra->len; ++i) {
if (ra->at[i]) {
- size_sum += knot_rdata_size(ra->at[i]->len);
+ rds->size += knot_rdata_size(ra->at[i]->len);
}
}
- knot_rdataset_t *rds = &stashed->rr->rrs;
rds->count = ra->len - dup_count;
- #if KNOT_VERSION_HEX >= 0x020900
- rds->size = size_sum;
- #endif
- if (size_sum) {
- rds->rdata = mm_alloc(pool, size_sum);
+ if (rds->size) {
+ rds->rdata = mm_alloc(pool, rds->size);
if (!rds->rdata) {
return kr_error(ENOMEM);
}
/* Everything is ready; now just copy all the rdata. */
uint8_t *raw_it = (uint8_t *)rds->rdata;
for (int i = 0; i < ra->len; ++i) {
- if (ra->at[i] && size_sum/*linters*/) {
+ if (ra->at[i] && rds->size/*linters*/) {
const int size = knot_rdata_size(ra->at[i]->len);
memcpy(raw_it, ra->at[i], size);
raw_it += size;
}
}
- assert(raw_it == (uint8_t *)rds->rdata + size_sum);
+ assert(raw_it == (uint8_t *)rds->rdata + rds->size);
}
stashed->in_progress = false;
}
/* Reserve memory in *addrs. Implementation detail:
* pack_t cares for lengths, so we don't store those in the data. */
- const size_t pack_extra_size = knot_rdataset_size(&cached_rr.rrs)
+ const size_t pack_extra_size = cached_rr.rrs.size
- cached_rr.rrs.count * offsetof(knot_rdata_t, len);
int ret = pack_reserve_mm(*addrs, cached_rr.rrs.count, pack_extra_size,
kr_memreserve, mm_pool);
#include "lib/generic/trie.h"
-/* TMP: compatibility for using libknot 2.8 API with 2.9. */
-#if KNOT_VERSION_HEX >= 0x020900
-static inline size_t knot_rdataset_size(const knot_rdataset_t *rrs)
-{
- return rrs->size;
-}
-#endif
-
struct kr_rplan;
struct kr_context;
*
* @note This can be used for membership test, a non-null pack is returned
* if the nameserver name exists.
- *
+ *
* @param cut
* @param ns name server name
* @return pack of addresses or NULL
message('--- required dependencies ---')
-knot_version = '>=2.8'
+knot_version = '>=2.9'
libknot = dependency('libknot', version: knot_version)
libdnssec = dependency('libdnssec', version: knot_version)
libzscanner = dependency('libzscanner', version: knot_version)
const bool ka_want =
req->qsource.flags.tcp &&
src_opt != NULL &&
- knot_edns_get_option(src_opt, KNOT_EDNS_OPTION_TCP_KEEPALIVE
- #if KNOT_VERSION_HEX >= 0x020900
- , NULL
- #endif
- ) &&
+ knot_edns_get_option(src_opt, KNOT_EDNS_OPTION_TCP_KEEPALIVE, NULL) &&
answ_opt != NULL;
if (!ka_want) {
return ctx->state;
if (src_opt == NULL)
return ctx->state;
- const uint8_t *req_nsid = knot_edns_get_option(src_opt, KNOT_EDNS_OPTION_NSID
- #if KNOT_VERSION_HEX >= 0x020900
- , NULL
- #endif
- );
+ const uint8_t *req_nsid = knot_edns_get_option(src_opt, KNOT_EDNS_OPTION_NSID, NULL);
/* NSID option must be explicitly requested */
if (req_nsid == NULL)
return ctx->state;