Commit 7e1bf96b authored by Daniel Salzman's avatar Daniel Salzman

Merge branch 'public-libs-common' into 'master'

Moved common/ to libknot/internal/

2nd step in separating libknot into an independent library. As we agreed, I moved all files from `common/` to `libknot/internal/`.

Also some renaming was done: symbols in `libknot/internal/` should not be prefixed with `knot_` unless they are system symbol replacements. Unified the prefixing of `namedb` symbols.

Fixes #305
Following: #301

See merge request !303
parents 9de0e69e ab293b70
......@@ -39,47 +39,6 @@ src/common-knot/strlcat.c
src/common-knot/strlcat.h
src/common-knot/strtonum.h
src/common-knot/trim.h
src/common/array-sort.h
src/common/base32hex.c
src/common/base32hex.h
src/common/base64.c
src/common/base64.h
src/common/binsearch.h
src/common/debug.h
src/common/errors.c
src/common/errors.h
src/common/getline.c
src/common/getline.h
src/common/hhash.c
src/common/hhash.h
src/common/lists.c
src/common/lists.h
src/common/log.c
src/common/log.h
src/common/macros.h
src/common/mem.c
src/common/mem.h
src/common/mempattern.c
src/common/mempattern.h
src/common/mempool.c
src/common/mempool.h
src/common/namedb/namedb.h
src/common/namedb/namedb_lmdb.c
src/common/namedb/namedb_lmdb.h
src/common/namedb/namedb_trie.c
src/common/namedb/namedb_trie.h
src/common/net.c
src/common/net.h
src/common/print.c
src/common/print.h
src/common/sockaddr.c
src/common/sockaddr.h
src/common/strlcpy.c
src/common/strlcpy.h
src/common/trie/hat-trie.c
src/common/trie/hat-trie.h
src/common/trie/murmurhash3.c
src/common/trie/murmurhash3.h
src/dnstap/Makefile.am
src/dnstap/convert.c
src/dnstap/convert.h
......@@ -232,6 +191,52 @@ src/libknot/dnssec/sign.c
src/libknot/dnssec/sign.h
src/libknot/errcode.c
src/libknot/errcode.h
src/libknot/internal/array-sort.h
src/libknot/internal/base32hex.c
src/libknot/internal/base32hex.h
src/libknot/internal/base64.c
src/libknot/internal/base64.h
src/libknot/internal/binsearch.h
src/libknot/internal/debug.h
src/libknot/internal/endian.h
src/libknot/internal/errors.c
src/libknot/internal/errors.h
src/libknot/internal/getline.c
src/libknot/internal/getline.h
src/libknot/internal/hhash.c
src/libknot/internal/hhash.h
src/libknot/internal/lists.c
src/libknot/internal/lists.h
src/libknot/internal/log.c
src/libknot/internal/log.h
src/libknot/internal/macros.h
src/libknot/internal/mem.c
src/libknot/internal/mem.h
src/libknot/internal/mempattern.c
src/libknot/internal/mempattern.h
src/libknot/internal/mempool.c
src/libknot/internal/mempool.h
src/libknot/internal/namedb/namedb.h
src/libknot/internal/namedb/namedb_lmdb.c
src/libknot/internal/namedb/namedb_lmdb.h
src/libknot/internal/namedb/namedb_trie.c
src/libknot/internal/namedb/namedb_trie.h
src/libknot/internal/net.c
src/libknot/internal/net.h
src/libknot/internal/print.c
src/libknot/internal/print.h
src/libknot/internal/sockaddr.c
src/libknot/internal/sockaddr.h
src/libknot/internal/strlcpy.c
src/libknot/internal/strlcpy.h
src/libknot/internal/tolower.c
src/libknot/internal/tolower.h
src/libknot/internal/trie/hat-trie.c
src/libknot/internal/trie/hat-trie.h
src/libknot/internal/trie/murmurhash3.c
src/libknot/internal/trie/murmurhash3.h
src/libknot/internal/utils.c
src/libknot/internal/utils.h
src/libknot/libknot.h
src/libknot/packet/compr.c
src/libknot/packet/compr.h
......@@ -271,11 +276,6 @@ src/libknot/rrtype/tsig.c
src/libknot/rrtype/tsig.h
src/libknot/tsig-op.c
src/libknot/tsig-op.h
src/libknot/util/endian.h
src/libknot/util/tolower.c
src/libknot/util/tolower.h
src/libknot/util/utils.c
src/libknot/util/utils.h
src/utils/common/exec.c
src/utils/common/exec.h
src/utils/common/msg.c
......
......@@ -80,47 +80,47 @@ libknots_la_SOURCES = \
# static: common shared (also in libknot)
libknotcs_la_SOURCES = \
common/array-sort.h \
common/base32hex.c \
common/base32hex.h \
common/base64.c \
common/base64.h \
common/binsearch.h \
common/debug.h \
common/errors.c \
common/errors.h \
common/getline.c \
common/getline.h \
common/hhash.c \
common/hhash.h \
common/lists.c \
common/lists.h \
common/log.c \
common/log.h \
common/macros.h \
common/mem.c \
common/mem.h \
common/mempattern.c \
common/mempattern.h \
common/mempool.c \
common/mempool.h \
common/namedb/namedb.h \
common/namedb/namedb_lmdb.c \
common/namedb/namedb_lmdb.h \
common/namedb/namedb_trie.c \
common/namedb/namedb_trie.h \
common/net.c \
common/net.h \
common/print.c \
common/print.h \
common/sockaddr.c \
common/sockaddr.h \
common/strlcpy.c \
common/strlcpy.h \
common/trie/hat-trie.c \
common/trie/hat-trie.h \
common/trie/murmurhash3.c \
common/trie/murmurhash3.h
libknot/internal/array-sort.h \
libknot/internal/base32hex.c \
libknot/internal/base32hex.h \
libknot/internal/base64.c \
libknot/internal/base64.h \
libknot/internal/binsearch.h \
libknot/internal/debug.h \
libknot/internal/errors.c \
libknot/internal/errors.h \
libknot/internal/getline.c \
libknot/internal/getline.h \
libknot/internal/hhash.c \
libknot/internal/hhash.h \
libknot/internal/lists.c \
libknot/internal/lists.h \
libknot/internal/log.c \
libknot/internal/log.h \
libknot/internal/macros.h \
libknot/internal/mem.c \
libknot/internal/mem.h \
libknot/internal/mempattern.c \
libknot/internal/mempattern.h \
libknot/internal/mempool.c \
libknot/internal/mempool.h \
libknot/internal/namedb/namedb.h \
libknot/internal/namedb/namedb_lmdb.c \
libknot/internal/namedb/namedb_lmdb.h \
libknot/internal/namedb/namedb_trie.c \
libknot/internal/namedb/namedb_trie.h \
libknot/internal/net.c \
libknot/internal/net.h \
libknot/internal/print.c \
libknot/internal/print.h \
libknot/internal/sockaddr.c \
libknot/internal/sockaddr.h \
libknot/internal/strlcpy.c \
libknot/internal/strlcpy.h \
libknot/internal/trie/hat-trie.c \
libknot/internal/trie/hat-trie.h \
libknot/internal/trie/murmurhash3.c \
libknot/internal/trie/murmurhash3.h
# static: utilities shared
libknotus_la_SOURCES = \
......@@ -210,11 +210,11 @@ libknot_la_SOURCES = \
libknot/rrtype/tsig.h \
libknot/tsig-op.c \
libknot/tsig-op.h \
libknot/util/endian.h \
libknot/util/tolower.c \
libknot/util/tolower.h \
libknot/util/utils.c \
libknot/util/utils.h
libknot/internal/endian.h \
libknot/internal/tolower.c \
libknot/internal/tolower.h \
libknot/internal/utils.c \
libknot/internal/utils.h
# static: server shared
libknotd_la_SOURCES = \
......
......@@ -33,11 +33,11 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "common/sockaddr.h"
#include "libknot/internal/sockaddr.h"
#include "knot/conf/conf.h"
#include "knot/conf/includes.h"
#include "knot/conf/extra.h"
#include "common/log.h"
#include "libknot/internal/log.h"
#include "libknotd_la-cf-parse.h" /* Automake generated header. */
/* Imported symbols. */
......
......@@ -30,9 +30,9 @@
#include <stdlib.h>
#include <pwd.h>
#include <grp.h>
#include "common/sockaddr.h"
#include "libknot/internal/sockaddr.h"
#include "common-knot/strlcat.h"
#include "common/strlcpy.h"
#include "libknot/internal/strlcpy.h"
#include "libknot/dname.h"
#include "libknot/binary.h"
#include "libknot/rrtype/opt.h"
......
......@@ -26,9 +26,9 @@
#include <urcu.h>
#include "common-knot/strlcat.h"
#include "common/strlcpy.h"
#include "common/macros.h"
#include "common/mem.h"
#include "libknot/internal/strlcpy.h"
#include "libknot/internal/mem.h"
#include "libknot/internal/macros.h"
#include "knot/conf/conf.h"
#include "knot/conf/extra.h"
#include "knot/knot.h"
......@@ -663,7 +663,7 @@ void conf_truncate(conf_t *conf, int unload_hooks)
// Free logs
WALK_LIST_DELSAFE(n, nxt, conf->logs) {
conf_free_log((conf_log_t*)n);
log_free((conf_log_t*)n);
}
init_list(&conf->logs);
......@@ -993,20 +993,3 @@ void conf_free_group(conf_group_t *group)
free(group->name);
free(group);
}
void conf_free_log(conf_log_t *log)
{
if (!log) {
return;
}
free(log->file);
/* Free loglevel mapping. */
node_t *n = NULL, *nxt = NULL;
WALK_LIST_DELSAFE(n, nxt, log->map) {
free((conf_log_map_t*)n);
}
free(log);
}
......@@ -37,12 +37,12 @@
#include "libknot/rrtype/tsig.h"
#include "libknot/dnssec/key.h"
#include "libknot/dnssec/policy.h"
#include "common/lists.h"
#include "common/namedb/namedb.h"
#include "common/log.h"
#include "libknot/internal/lists.h"
#include "libknot/internal/namedb/namedb.h"
#include "libknot/internal/log.h"
#include "knot/updates/acl.h"
#include "common/sockaddr.h"
#include "common/trie/hat-trie.h"
#include "libknot/internal/sockaddr.h"
#include "libknot/internal/trie/hat-trie.h"
#include "knot/nameserver/query_module.h"
/* Constants. */
......@@ -148,25 +148,6 @@ typedef enum conf_serial_policy_t {
CONF_SERIAL_UNIXTIME = 1 << 1
} conf_serial_policy_t;
/*!
* \brief Mapping of loglevels to message sources.
*/
typedef struct conf_log_map_t {
node_t n;
int source; /*!< Log message source mask. */
int prios; /*!< Log priorities mask. */
} conf_log_map_t;
/*!
* \brief Log facility descriptor.
*/
typedef struct conf_log_t {
node_t n;
logtype_t type; /*!< Type of the log (SYSLOG/STDERR/FILE). */
char *file; /*!< Filename in case of LOG_FILE, else NULL. */
list_t map; /*!< Log levels mapping. */
} conf_log_t;
/*!
* \brief Configuration sections.
*/
......@@ -422,7 +403,10 @@ void conf_free_remote(conf_remote_t *r);
/*! \brief Free group config. */
void conf_free_group(conf_group_t *group);
/*! \brief Free log config. */
void conf_free_log(conf_log_t *log);
/*! \brief Log reconfiguration wrapper. */
static inline int conf_log_reconfigure(const conf_t *conf, void *data)
{
return log_reconfigure(&conf->logs, data);
}
/*! @} */
......@@ -18,9 +18,9 @@
#include "knot/ctl/estimator.h"
#include "libknot/dname.h"
#include "common/lists.h"
#include "common/macros.h"
#include "common/mem.h"
#include "libknot/internal/lists.h"
#include "libknot/internal/mem.h"
#include "libknot/internal/macros.h"
#include "knot/zone/node.h"
#include "libknot/descriptor.h"
......
......@@ -26,7 +26,7 @@
#pragma once
#include "common/trie/hat-trie.h"
#include "libknot/internal/trie/hat-trie.h"
#include "zscanner/scanner.h"
// Mutiplicative constant, needed because of malloc's fragmentation
......
......@@ -26,8 +26,8 @@
#endif
#include "knot/knot.h"
#include "common/macros.h"
#include "common/mem.h"
#include "libknot/internal/mem.h"
#include "libknot/internal/macros.h"
#include "libknot/descriptor.h"
#include "knot/ctl/process.h"
#include "knot/ctl/remote.h"
......@@ -307,8 +307,8 @@ static int tsig_parse_str(knot_tsig_key_t *key, const char *str)
int algorithm = KNOT_TSIG_ALG_HMAC_MD5;
if (s) {
*s++ = '\0'; /* Last part separator */
knot_lookup_table_t *alg = NULL;
alg = knot_lookup_by_name(knot_tsig_alg_names, h);
lookup_table_t *alg = NULL;
alg = lookup_by_name(knot_tsig_alg_names, h);
if (alg) {
algorithm = alg->id;
} else {
......@@ -357,8 +357,8 @@ static int tsig_parse_line(knot_tsig_key_t *k, char *l)
}
/* Lookup algorithm. */
knot_lookup_table_t *alg;
alg = knot_lookup_by_name(knot_tsig_alg_names, a);
lookup_table_t *alg;
alg = lookup_by_name(knot_tsig_alg_names, a);
if (!alg) {
return KNOT_EMALF;
......
......@@ -29,7 +29,7 @@
#include <sys/types.h>
#include <pwd.h>
#include "common/mem.h"
#include "libknot/internal/mem.h"
#include "knot/knot.h"
#include "knot/ctl/process.h"
#include "knot/conf/conf.h"
......
......@@ -17,17 +17,17 @@
#include <assert.h>
#include <sys/stat.h>
#include "knot/ctl/remote.h"
#include "common/log.h"
#include "common/macros.h"
#include "common/mem.h"
#include "libknot/internal/log.h"
#include "libknot/internal/mem.h"
#include "libknot/internal/macros.h"
#include "common-knot/fdset.h"
#include "knot/knot.h"
#include "knot/conf/conf.h"
#include "common/net.h"
#include "libknot/internal/net.h"
#include "knot/server/tcp-handler.h"
#include "libknot/packet/wire.h"
#include "libknot/descriptor.h"
#include "common/strlcpy.h"
#include "libknot/internal/strlcpy.h"
#include "libknot/tsig-op.h"
#include "libknot/rrtype/rdname.h"
#include "libknot/rrtype/soa.h"
......
......@@ -17,7 +17,7 @@
#include <assert.h>
#include <stdint.h>
#include "common/debug.h"
#include "libknot/internal/debug.h"
#include "knot/dnssec/nsec-chain.h"
#include "knot/dnssec/zone-sign.h"
#include "libknot/dnssec/rrset-sign.h"
......
......@@ -16,8 +16,8 @@
#include <assert.h>
#include "common/base32hex.h"
#include "common/macros.h"
#include "libknot/internal/base32hex.h"
#include "libknot/internal/macros.h"
#include "knot/dnssec/nsec3-chain.h"
#include "libknot/dname.h"
#include "libknot/packet/wire.h"
......@@ -222,7 +222,7 @@ static void nsec3_fill_rdata(uint8_t *rdata, const knot_nsec3_params_t *params,
rdata += 1;
*rdata = 0; // flags
rdata += 1;
knot_wire_write_u16(rdata, params->iterations); // iterations
wire_write_u16(rdata, params->iterations); // iterations
rdata += 2;
*rdata = params->salt_length; // salt length
rdata += 1;
......@@ -235,7 +235,7 @@ static void nsec3_fill_rdata(uint8_t *rdata, const knot_nsec3_params_t *params,
memcpy(rdata, next_hashed, hash_length);
}
rdata += hash_length;
knot_bitmap_write(rr_types, rdata); // RR types bit map
knot_bitmap_write(rr_types, rdata); // RR types bit map
}
/*!
......
......@@ -17,14 +17,14 @@
#include <assert.h>
#include <time.h>
#include "common/mem.h"
#include "libknot/internal/mem.h"
#include "knot/conf/conf.h"
#include "libknot/dnssec/policy.h"
#include "knot/dnssec/zone-events.h"
#include "knot/dnssec/zone-keys.h"
#include "knot/dnssec/zone-nsec.h"
#include "knot/dnssec/zone-sign.h"
#include "common/debug.h"
#include "libknot/internal/debug.h"
#include "knot/zone/zone.h"
static int init_dnssec_structs(const zone_contents_t *zone,
......
......@@ -19,9 +19,9 @@
#include <stdbool.h>
#include <inttypes.h>
#include "common/debug.h"
#include "common/macros.h"
#include "common/mem.h"
#include "libknot/internal/debug.h"
#include "libknot/internal/mem.h"
#include "libknot/internal/macros.h"
#include "libknot/errcode.h"
#include "libknot/dname.h"
#include "libknot/consts.h"
......
......@@ -30,7 +30,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "common/lists.h"
#include "libknot/internal/lists.h"
#include "libknot/dname.h"
#include "libknot/dnssec/sign.h"
......
......@@ -20,11 +20,11 @@
#include <string.h>
#include <limits.h>
#include "common/base32hex.h"
#include "common/debug.h"
#include "libknot/internal/base32hex.h"
#include "libknot/internal/debug.h"
#include "libknot/descriptor.h"
#include "libknot/dnssec/bitmap.h"
#include "libknot/util/utils.h"
#include "libknot/internal/utils.h"
#include "libknot/packet/wire.h"
#include "libknot/rrtype/soa.h"
#include "libknot/rrtype/nsec3.h"
......
......@@ -20,11 +20,11 @@
#include <sys/types.h>
#include <time.h>
#include "common/debug.h"
#include "common/macros.h"
#include "libknot/internal/debug.h"
#include "libknot/descriptor.h"
#include "libknot/errcode.h"
#include "common/trie/hat-trie.h"
#include "libknot/internal/trie/hat-trie.h"
#include "libknot/internal/macros.h"
#include "libknot/dname.h"
#include "libknot/rrset.h"
#include "libknot/dnssec/key.h"
......
......@@ -29,8 +29,8 @@
#include <signal.h>
#include <stdint.h>
#include "common/print.h"
#include "common/log.h"
#include "libknot/internal/print.h"
#include "libknot/internal/log.h"
#include "libknot/errcode.h"
#include "knot/other/debug.h"
......
......@@ -274,8 +274,8 @@ int main(int argc, char **argv)
/* Initialize logging subsystem.
* @note We're logging since now. */
log_reconfigure(config, NULL);
conf_add_hook(config, CONF_LOG, log_reconfigure, NULL);
conf_log_reconfigure(config, NULL);
conf_add_hook(config, CONF_LOG, conf_log_reconfigure, NULL);
/* Initialize server. */
server_t server;
......
......@@ -20,9 +20,9 @@
#include "knot/nameserver/process_answer.h"
#include "knot/updates/apply.h"
#include "knot/zone/zonefile.h"
#include "common/debug.h"
#include "libknot/internal/debug.h"
#include "libknot/descriptor.h"
#include "common/lists.h"
#include "libknot/internal/lists.h"
/* AXFR context. @note aliasing the generic xfr_proc */
struct axfr_proc {
......@@ -380,7 +380,7 @@ int axfr_answer_process(knot_pkt_t *pkt, struct answer_data *adata)
/* Check RCODE. */
uint8_t rcode = knot_wire_get_rcode(pkt->wire);
if (rcode != KNOT_RCODE_NOERROR) {
knot_lookup_table_t *lut = knot_lookup_by_id(knot_rcode_names, rcode);
lookup_table_t *lut = lookup_by_id(knot_rcode_names, rcode);
if (lut != NULL) {
AXFRIN_LOG(LOG_ERR, "server responded with %s", lut->name);
}
......
......@@ -14,7 +14,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/debug.h"
#include "libknot/internal/debug.h"
#include "libknot/descriptor.h"
#include "libknot/rrtype/rdname.h"
#include "libknot/rrtype/soa.h"
......@@ -880,7 +880,7 @@ static int process_soa_answer(knot_pkt_t *pkt, struct answer_data *data)
knot_rdataset_t *soa = node_rdataset(zone->contents->apex, KNOT_RRTYPE_SOA);
uint32_t our_serial = knot_soa_serial(soa);
uint32_t their_serial = knot_soa_serial(&answer->rr[0].rrs);
if (knot_serial_compare(our_serial, their_serial) >= 0) {
if (serial_compare(our_serial, their_serial) >= 0) {
ANSWER_LOG(LOG_INFO, data, "refresh, outgoing", "zone is up-to-date");
zone_events_cancel(zone, ZONE_EVENT_EXPIRE);
return KNOT_NS_PROC_DONE; /* Our zone is up to date. */
......
......@@ -20,9 +20,9 @@
#include "knot/nameserver/process_query.h"
#include "knot/nameserver/process_answer.h"
#include "knot/updates/apply.h"
#include "common/debug.h"
#include "libknot/internal/debug.h"
#include "libknot/descriptor.h"
#include "libknot/util/utils.h"
#include "libknot/internal/utils.h"
#include "libknot/rrtype/soa.h"
/* ------------------------ IXFR-out processing ----------------------------- */
......@@ -171,7 +171,7 @@ static int ixfr_load_chsets(list_t *chgsets, const zone_t *zone,
/* Compare serials. */
uint32_t serial_to = zone_contents_serial(zone->contents);
uint32_t serial_from = knot_soa_serial(&their_soa->rrs);
int ret = knot_serial_compare(serial_to, serial_from);
int ret = serial_compare(serial_to, serial_from);
if (ret <= 0) { /* We have older/same age zone. */
return KNOT_EUPTODATE;
}
......@@ -695,7 +695,7 @@ int ixfr_process_answer(knot_pkt_t *pkt, struct answer_data *adata)
/* Check RCODE. */
uint8_t rcode = knot_wire_get_rcode(pkt->wire);
if (rcode != KNOT_RCODE_NOERROR) {
knot_lookup_table_t *lut = knot_lookup_by_id(knot_rcode_names, rcode);
lookup_table_t *lut = lookup_by_id(knot_rcode_names, rcode);
if (lut != NULL) {
IXFRIN_LOG(LOG_WARNING, "server responded with %s", lut->name);
}
......
......@@ -31,7 +31,7 @@
#include "knot/other/debug.h"
#include "knot/server/server.h"
#include "knot/nameserver/internet.h"
#include "common/debug.h"
#include "libknot/internal/debug.h"
#include "knot/nameserver/process_query.h"
#include "knot/nameserver/tsig_ctx.h"
#include "knot/nameserver/process_answer.h"
......@@ -122,7 +122,7 @@ int notify_process_answer(knot_pkt_t *pkt, struct answer_data *adata)
/* Check RCODE. */
uint8_t rcode = knot_wire_get_rcode(pkt->wire);
if (rcode != KNOT_RCODE_NOERROR) {
knot_lookup_table_t *lut = knot_lookup_by_id(knot_rcode_names, rcode);
lookup_table_t *lut = lookup_by_id(knot_rcode_names, rcode);
if (lut != NULL) {
NOTIFY_RLOG(LOG_WARNING, "server responded with %s", lut->name);
}
......
......@@ -3,7 +3,7 @@
#include "knot/nameserver/internet.h"
#include "knot/dnssec/zone-nsec.h"
#include "common/debug.h"
#include "libknot/internal/debug.h"
#define DNSSEC_ENABLED 1
......
......@@ -16,8 +16,8 @@
#include "libknot/rrtype/opt.h"
#include "libknot/tsig-op.h"
#include "libknot/descriptor.h"
#include "common/debug.h"
#include "common/mac