From fa84b4c35bdf08c04c5a44d02578c23a83babf53 Mon Sep 17 00:00:00 2001 From: Jan Vcelak <jan.vcelak@nic.cz> Date: Fri, 21 Mar 2014 17:41:01 +0100 Subject: [PATCH] zones: remove knot_ from zone contents, rename zone-create.c --- src/Makefile.am | 10 +- src/knot/ctl/knotc_main.c | 4 +- src/knot/dnssec/nsec-chain.c | 20 +- src/knot/dnssec/nsec-chain.h | 8 +- src/knot/dnssec/nsec3-chain.c | 56 ++--- src/knot/dnssec/nsec3-chain.h | 2 +- src/knot/dnssec/zone-events.c | 10 +- src/knot/dnssec/zone-events.h | 6 +- src/knot/dnssec/zone-nsec.c | 12 +- src/knot/dnssec/zone-nsec.h | 8 +- src/knot/dnssec/zone-sign.c | 14 +- src/knot/dnssec/zone-sign.h | 8 +- src/knot/nameserver/axfr.c | 10 +- src/knot/nameserver/internet.c | 10 +- src/knot/nameserver/nsec_proofs.c | 38 +-- src/knot/nameserver/update.c | 14 +- src/knot/server/notify.c | 2 +- src/knot/server/xfr-handler.c | 10 +- src/knot/server/xfr-handler.h | 2 +- src/knot/server/zones.c | 32 +-- src/knot/server/zones.h | 10 +- src/knot/updates/ddns.c | 58 ++--- src/knot/updates/ddns.h | 6 +- src/knot/updates/xfr-in.c | 120 +++++----- src/knot/updates/xfr-in.h | 28 +-- src/knot/zone/{zone-contents.c => contents.c} | 216 +++++++++--------- src/knot/zone/{zone-contents.h => contents.h} | 143 ++++++------ src/knot/zone/semantic-check.c | 46 ++-- src/knot/zone/semantic-check.h | 8 +- src/knot/zone/zone-diff.c | 22 +- src/knot/zone/zone-diff.h | 6 +- src/knot/zone/zone-dump.c | 16 +- src/knot/zone/zone-dump.h | 2 +- src/knot/zone/zone.c | 12 +- src/knot/zone/zone.h | 8 +- src/knot/zone/zonedb.h | 2 +- src/knot/zone/{zone-create.c => zonefile.c} | 35 +-- src/knot/zone/{zone-create.h => zonefile.h} | 12 +- tests/process_query.c | 4 +- 39 files changed, 516 insertions(+), 514 deletions(-) rename src/knot/zone/{zone-contents.c => contents.c} (83%) rename src/knot/zone/{zone-contents.h => contents.h} (76%) rename src/knot/zone/{zone-create.c => zonefile.c} (90%) rename src/knot/zone/{zone-create.h => zonefile.h} (87%) diff --git a/src/Makefile.am b/src/Makefile.am index dfeadaf8bb..2470b85f12 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -258,6 +258,8 @@ libknotd_la_SOURCES = \ knot/worker/queue.h \ knot/worker/task.c \ knot/worker/task.h \ + knot/zone/contents.c \ + knot/zone/contents.h \ knot/zone/estimator.c \ knot/zone/estimator.h \ knot/zone/events.c \ @@ -266,10 +268,6 @@ libknotd_la_SOURCES = \ knot/zone/node.h \ knot/zone/semantic-check.c \ knot/zone/semantic-check.h \ - knot/zone/zone-contents.c \ - knot/zone/zone-contents.h \ - knot/zone/zone-create.c \ - knot/zone/zone-create.h \ knot/zone/zone-diff.c \ knot/zone/zone-diff.h \ knot/zone/zone-dump.c \ @@ -279,7 +277,9 @@ libknotd_la_SOURCES = \ knot/zone/zone.c \ knot/zone/zone.h \ knot/zone/zonedb.c \ - knot/zone/zonedb.h + knot/zone/zonedb.h \ + knot/zone/zonefile.c \ + knot/zone/zonefile.h # libraries libknot_la_LIBADD = libknots.la zscanner/libzscanner.la diff --git a/src/knot/ctl/knotc_main.c b/src/knot/ctl/knotc_main.c index 814ff14c65..6b748b4bfa 100644 --- a/src/knot/ctl/knotc_main.c +++ b/src/knot/ctl/knotc_main.c @@ -31,7 +31,7 @@ #include "knot/ctl/process.h" #include "knot/ctl/remote.h" #include "knot/conf/conf.h" -#include "knot/zone/zone-create.h" +#include "knot/zone/zonefile.h" #include "knot/server/tcp-handler.h" #include "libknot/packet/wire.h" #include "knot/server/zone-load.h" @@ -687,7 +687,7 @@ static int cmd_checkzone(int argc, char *argv[], unsigned flags) } /* Create zone loader context. */ - zone_t *loaded_zone = load_zone_file(zone); + zone_t *loaded_zone = NULL; // TODO load_zone_file(zone); if (loaded_zone == NULL) { rc = 1; continue; diff --git a/src/knot/dnssec/nsec-chain.c b/src/knot/dnssec/nsec-chain.c index ebd59af89e..92b322e95c 100644 --- a/src/knot/dnssec/nsec-chain.c +++ b/src/knot/dnssec/nsec-chain.c @@ -315,7 +315,7 @@ static int handle_nsec_next_dname(chain_fix_data_t *fix_data, knot_node_rrset(a_node, KNOT_RRTYPE_NSEC); assert(nsec_rrset); const knot_node_t *next_node = - knot_zone_contents_find_node(fix_data->zone, + zone_contents_find_node(fix_data->zone, knot_rdata_nsec_next(nsec_rrset)); assert(next_node); update_last_used(fix_data, next_node->owner, next_node); @@ -324,7 +324,7 @@ static int handle_nsec_next_dname(chain_fix_data_t *fix_data, } else { // We have no immediate previous node, connect broken chain const knot_node_t *next_node = - knot_zone_contents_find_node(fix_data->zone, + zone_contents_find_node(fix_data->zone, fix_data->next_dname); assert(next_node); update_last_used(fix_data, next_node->owner, next_node); @@ -343,18 +343,18 @@ static int handle_nsec_next_dname(chain_fix_data_t *fix_data, * * \return Previous NSEC node for 'd'. */ -static const knot_node_t *find_prev_nsec_node(const knot_zone_contents_t *z, +static const knot_node_t *find_prev_nsec_node(const zone_contents_t *z, const knot_dname_t *d) { // Find previous node for the dname, return node that will be used later - const knot_node_t *prev_zone_node = knot_zone_contents_find_previous(z, + const knot_node_t *prev_zone_node = zone_contents_find_previous(z, d); bool nsec_node_found = !knot_node_is_non_auth(prev_zone_node) && !only_nsec_in_node(prev_zone_node); while (!nsec_node_found) { // Get previous node from zone tree prev_zone_node = - knot_zone_contents_find_previous(z, + zone_contents_find_previous(z, prev_zone_node->owner); assert(prev_zone_node); // Infinite loop check @@ -383,14 +383,14 @@ static int fix_nsec_chain(knot_dname_t *a, knot_dname_t *b, assert(b); assert(fix_data); // Get changed nodes from zone - const knot_node_t *b_node = knot_zone_contents_find_node(fix_data->zone, + const knot_node_t *b_node = zone_contents_find_node(fix_data->zone, b); assert(b_node); if (knot_node_is_non_auth(b_node)) { // Nothing to fix in this node return NSEC_NODE_SKIP; } - const knot_node_t *a_node = knot_zone_contents_find_node(fix_data->zone, + const knot_node_t *a_node = zone_contents_find_node(fix_data->zone, a); // Find previous node in zone const knot_node_t *prev_zone_node = find_prev_nsec_node(fix_data->zone, @@ -482,11 +482,11 @@ static int chain_finalize_nsec(chain_fix_data_t *fix_data) // NSEC cannot point to itself (except for the case above) const knot_rrset_t *nsec_rrset = knot_node_rrset(from, KNOT_RRTYPE_NSEC); - to = knot_zone_contents_find_node(fix_data->zone, + to = zone_contents_find_node(fix_data->zone, knot_rdata_nsec_next(nsec_rrset)); } else { // Normal case - to = knot_zone_contents_find_node(fix_data->zone, + to = zone_contents_find_node(fix_data->zone, fix_data->next_dname); } assert(to); @@ -693,7 +693,7 @@ bool knot_nsec_only_nsec_and_rrsigs_in_node(const knot_node_t *n) /*! * \brief Create new NSEC chain, add differences from current into a changeset. */ -int knot_nsec_create_chain(const knot_zone_contents_t *zone, uint32_t ttl, +int knot_nsec_create_chain(const zone_contents_t *zone, uint32_t ttl, knot_changeset_t *changeset) { assert(zone); diff --git a/src/knot/dnssec/nsec-chain.h b/src/knot/dnssec/nsec-chain.h index 39f0ac7304..aa827aeee3 100644 --- a/src/knot/dnssec/nsec-chain.h +++ b/src/knot/dnssec/nsec-chain.h @@ -31,7 +31,7 @@ #include <stdbool.h> #include <stdint.h> -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "knot/updates/changesets.h" #include "libknot/dnssec/bitmap.h" @@ -39,7 +39,7 @@ * \brief Parameters to be used when fixing NSEC(3) chain. */ typedef struct chain_fix_data { - const knot_zone_contents_t *zone; // Zone to fix + const zone_contents_t *zone; // Zone to fix knot_changeset_t *out_ch; // Outgoing changes const knot_dname_t *chain_start; // Possible new starting node bool old_connected; // Marks old start connection @@ -56,7 +56,7 @@ typedef struct chain_fix_data { typedef struct { uint32_t ttl; // TTL for NSEC(3) records knot_changeset_t *changeset; // Changeset for NSEC(3) changes - const knot_zone_contents_t *zone; // Updated zone + const zone_contents_t *zone; // Updated zone } nsec_chain_iterate_data_t; /*! @@ -166,7 +166,7 @@ bool knot_nsec_only_nsec_and_rrsigs_in_node(const knot_node_t *n); * * \return Error code, KNOT_EOK if successful. */ -int knot_nsec_create_chain(const knot_zone_contents_t *zone, uint32_t ttl, +int knot_nsec_create_chain(const zone_contents_t *zone, uint32_t ttl, knot_changeset_t *changeset); /*! diff --git a/src/knot/dnssec/nsec3-chain.c b/src/knot/dnssec/nsec3-chain.c index aa4a9946a6..dcc214fe55 100644 --- a/src/knot/dnssec/nsec3-chain.c +++ b/src/knot/dnssec/nsec3-chain.c @@ -21,7 +21,7 @@ #include "libknot/dname.h" #include "libknot/rdata.h" #include "libknot/packet/wire.h" -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "knot/zone/zone-diff.h" #include "knot/dnssec/nsec-chain.h" #include "knot/dnssec/zone-sign.h" @@ -161,7 +161,7 @@ static void update_next_nsec3_dname(chain_fix_data_t *fix_data, fix_data->next_dname = NULL; } else { const knot_node_t *nsec3_node = - knot_zone_contents_find_nsec3_node(fix_data->zone, d); + zone_contents_find_nsec3_node(fix_data->zone, d); assert(nsec3_node); const knot_rrset_t *nsec3_rrset = knot_node_rrset(nsec3_node, KNOT_RRTYPE_NSEC3); @@ -177,7 +177,7 @@ static void update_next_nsec3_dname(chain_fix_data_t *fix_data, /*! * \brief Helper function - sets variables by looking for data in the zone. */ -static void fetch_nodes_from_zone(const knot_zone_contents_t *z, +static void fetch_nodes_from_zone(const zone_contents_t *z, const knot_dname_t *a, const knot_dname_t *b, const knot_dname_t *a_hash, @@ -187,10 +187,10 @@ static void fetch_nodes_from_zone(const knot_zone_contents_t *z, const knot_node_t **a_nsec3_node, const knot_node_t **b_nsec3_node) { - *a_node = knot_zone_contents_find_node(z, a); - *b_node = knot_zone_contents_find_node(z, b); - *a_nsec3_node = knot_zone_contents_find_nsec3_node(z, a_hash); - *b_nsec3_node = knot_zone_contents_find_nsec3_node(z, b_hash); + *a_node = zone_contents_find_node(z, a); + *b_node = zone_contents_find_node(z, b); + *a_nsec3_node = zone_contents_find_nsec3_node(z, a_hash); + *b_nsec3_node = zone_contents_find_nsec3_node(z, b_hash); } /*! @@ -202,7 +202,7 @@ static void fetch_nodes_from_zone(const knot_zone_contents_t *z, * * \return True if this node can be used, false otherwise. */ -static bool covered_node_usable(const knot_zone_contents_t *z, +static bool covered_node_usable(const zone_contents_t *z, const knot_dname_t *d_hashed, const hattrie_t *sorted_changes) { @@ -217,7 +217,7 @@ static bool covered_node_usable(const knot_zone_contents_t *z, assert(knot_dname_is_equal(info->hashed_dname, d_hashed)); // Get normal node const knot_node_t *normal_node = - knot_zone_contents_find_node(z, info->dname); + zone_contents_find_node(z, info->dname); // Usable if not deleted and not non-auth return normal_node != NULL && !knot_node_is_non_auth(normal_node); @@ -268,11 +268,11 @@ static bool node_should_be_signed_nsec3(const knot_node_t *n) static int update_nsec3(const knot_dname_t *from, const knot_dname_t *to, const knot_node_t *covered_node, knot_changeset_t *out_ch, - const knot_zone_contents_t *zone, uint32_t soa_min) + const zone_contents_t *zone, uint32_t soa_min) { assert(from && to && out_ch && zone); // Get old NSEC3 RR (there might not be any) - const knot_node_t *from_node = knot_zone_contents_find_nsec3_node(zone, + const knot_node_t *from_node = zone_contents_find_nsec3_node(zone, from); const knot_rrset_t *old_nsec3 = from_node ? knot_node_rrset(from_node, @@ -378,7 +378,7 @@ static int update_nsec3(const knot_dname_t *from, const knot_dname_t *to, * * \return first NSEC3 node on success, NULL otherwise. */ -static const knot_node_t *zone_first_nsec3_node(const knot_zone_contents_t *z) +static const knot_node_t *zone_first_nsec3_node(const zone_contents_t *z) { assert(z && hattrie_weight(z->nsec3_nodes) > 0); hattrie_iter_t *i = hattrie_iter_begin(z->nsec3_nodes, true); @@ -398,7 +398,7 @@ static const knot_node_t *zone_first_nsec3_node(const knot_zone_contents_t *z) * * \return last NSEC3 node on success, NULL otherwise. */ -static const knot_node_t *zone_last_nsec3_node(const knot_zone_contents_t *z) +static const knot_node_t *zone_last_nsec3_node(const zone_contents_t *z) { // Get first node const knot_node_t *first_node = zone_first_nsec3_node(z); @@ -406,7 +406,7 @@ static const knot_node_t *zone_last_nsec3_node(const knot_zone_contents_t *z) return NULL; } // Get node previous to first = last node - return knot_zone_contents_find_previous_nsec3(z, first_node->owner); + return zone_contents_find_previous_nsec3(z, first_node->owner); } /* - RRSIGs handling for NSEC3 ---------------------------------------------- */ @@ -720,7 +720,7 @@ static int connect_nsec3_nodes(knot_node_t *a, knot_node_t *b, * * \return Error code, KNOT_EOK if successful. */ -static int create_nsec3_nodes(const knot_zone_contents_t *zone, uint32_t ttl, +static int create_nsec3_nodes(const zone_contents_t *zone, uint32_t ttl, knot_zone_tree_t *nsec3_nodes, knot_changeset_t *chgset) { @@ -794,7 +794,7 @@ static int create_nsec3_nodes(const knot_zone_contents_t *zone, uint32_t ttl, * \return KNOT_E* */ static int walk_dname_and_store_empty_nonterminals(const knot_dname_t *dname, - const knot_zone_contents_t *zone, + const zone_contents_t *zone, hattrie_t *t) { assert(dname); @@ -815,7 +815,7 @@ static int walk_dname_and_store_empty_nonterminals(const knot_dname_t *dname, const knot_dname_t *cut = knot_wire_next_label(dname, NULL); while (*cut != '\0' && !knot_dname_is_equal(cut, zone->apex->owner)) { // Search for name in the zone - const knot_node_t *n = knot_zone_contents_find_node(zone, cut); + const knot_node_t *n = zone_contents_find_node(zone, cut); if (n == NULL || n->rrset_count == 0) { /*! * n == NULL: @@ -842,7 +842,7 @@ static int walk_dname_and_store_empty_nonterminals(const knot_dname_t *dname, * * \return KNOT_E* */ -static int update_changes_with_empty_non_terminals(const knot_zone_contents_t *zone, +static int update_changes_with_empty_non_terminals(const zone_contents_t *zone, hattrie_t *sorted_changes) { assert(zone); @@ -924,7 +924,7 @@ static int update_changes_with_empty_non_terminals(const knot_zone_contents_t *z * \return KNOT_E* */ static int create_nsec3_hashes_from_trie(const hattrie_t *sorted_changes, - const knot_zone_contents_t *zone, + const zone_contents_t *zone, hattrie_t **out) { assert(sorted_changes); @@ -988,7 +988,7 @@ static const knot_node_t *fetch_covered_node(chain_fix_data_t *fix_data, return NULL; } else { signed_info_t *info = (signed_info_t *)*val; - return knot_zone_contents_find_node(fix_data->zone, + return zone_contents_find_node(fix_data->zone, info->dname); } } @@ -1023,7 +1023,7 @@ static int handle_nsec3_next_dname(chain_fix_data_t *fix_data, return KNOT_ENOMEM; } const knot_node_t *next_node = - knot_zone_contents_find_nsec3_node(fix_data->zone, + zone_contents_find_nsec3_node(fix_data->zone, rr_next_dname); assert(next_node); knot_dname_free(&rr_next_dname); @@ -1175,19 +1175,19 @@ static bool use_prev_from_changeset(const knot_dname_t *a_hash, * * \return Previous NSEC3 node for 'd_hashed'. */ -static const knot_node_t *find_prev_nsec3_node(const knot_zone_contents_t *z, +static const knot_node_t *find_prev_nsec3_node(const zone_contents_t *z, const knot_dname_t *d_hashed, const hattrie_t *sorted_changes) { // Find previous node for the node const knot_node_t *prev_nsec3_node = - knot_zone_contents_find_previous_nsec3(z, d_hashed); + zone_contents_find_previous_nsec3(z, d_hashed); assert(prev_nsec3_node); bool prev_nsec3_found = !covered_node_usable(z, prev_nsec3_node->owner, sorted_changes); while (!prev_nsec3_found) { prev_nsec3_node = - knot_zone_contents_find_previous_nsec3(z, + zone_contents_find_previous_nsec3(z, prev_nsec3_node->owner); assert(prev_nsec3_node); // Either the node is usable, or there's nothing more to find @@ -1356,7 +1356,7 @@ static int chain_finalize_nsec3(chain_fix_data_t *fix_data) } else if (knot_dname_is_equal(from, fix_data->next_dname)) { // We do not want to point it to itself, extract next const knot_node_t *nsec3_node = - knot_zone_contents_find_nsec3_node(fix_data->zone, + zone_contents_find_nsec3_node(fix_data->zone, from); assert(nsec3_node); const knot_rrset_t *nsec3_rrset = @@ -1442,7 +1442,7 @@ static int nsec3_mark_empty(knot_node_t **node_p, void *data) * This is only temporary for the time of NSEC3 generation. Afterwards it must * be reset (removed flag and fixed children counts). */ -static void mark_empty_nodes_tmp(const knot_zone_contents_t *zone) +static void mark_empty_nodes_tmp(const zone_contents_t *zone) { assert(zone); @@ -1482,7 +1482,7 @@ static int nsec3_reset(knot_node_t **node_p, void *data) * This function must be called after NSEC3 generation, so that flags and * children count are back to normal before further processing. */ -static void reset_nodes(const knot_zone_contents_t *zone) +static void reset_nodes(const zone_contents_t *zone) { assert(zone); @@ -1496,7 +1496,7 @@ static void reset_nodes(const knot_zone_contents_t *zone) /*! * \brief Create new NSEC3 chain, add differences from current into a changeset. */ -int knot_nsec3_create_chain(const knot_zone_contents_t *zone, uint32_t ttl, +int knot_nsec3_create_chain(const zone_contents_t *zone, uint32_t ttl, knot_changeset_t *changeset) { assert(zone); diff --git a/src/knot/dnssec/nsec3-chain.h b/src/knot/dnssec/nsec3-chain.h index d2f1f072ed..603c723edf 100644 --- a/src/knot/dnssec/nsec3-chain.h +++ b/src/knot/dnssec/nsec3-chain.h @@ -40,7 +40,7 @@ * * \return KNOT_E* */ -int knot_nsec3_create_chain(const knot_zone_contents_t *zone, uint32_t ttl, +int knot_nsec3_create_chain(const zone_contents_t *zone, uint32_t ttl, knot_changeset_t *changeset); /*! diff --git a/src/knot/dnssec/zone-events.c b/src/knot/dnssec/zone-events.c index dcf56d712d..79db9a4c97 100644 --- a/src/knot/dnssec/zone-events.c +++ b/src/knot/dnssec/zone-events.c @@ -27,7 +27,7 @@ #include "common/debug.h" #include "knot/zone/zone.h" -static int init_dnssec_structs(const knot_zone_contents_t *zone, +static int init_dnssec_structs(const zone_contents_t *zone, conf_zone_t *config, knot_zone_keys_t *zone_keys, knot_dnssec_policy_t *policy, @@ -65,7 +65,7 @@ static int init_dnssec_structs(const knot_zone_contents_t *zone, return KNOT_EOK; } -static int zone_sign(knot_zone_contents_t *zone, conf_zone_t *zone_config, +static int zone_sign(zone_contents_t *zone, conf_zone_t *zone_config, knot_changeset_t *out_ch, bool force, knot_update_serial_t soa_up, uint32_t *refresh_at, uint32_t new_serial) @@ -152,7 +152,7 @@ static int zone_sign(knot_zone_contents_t *zone, conf_zone_t *zone_config, return KNOT_EOK; } -int knot_dnssec_zone_sign(knot_zone_contents_t *zone, conf_zone_t *zone_config, +int knot_dnssec_zone_sign(zone_contents_t *zone, conf_zone_t *zone_config, knot_changeset_t *out_ch, knot_update_serial_t soa_up, uint32_t *refresh_at, uint32_t new_serial) @@ -164,7 +164,7 @@ int knot_dnssec_zone_sign(knot_zone_contents_t *zone, conf_zone_t *zone_config, return zone_sign(zone, zone_config, out_ch, false, soa_up, refresh_at, new_serial); } -int knot_dnssec_zone_sign_force(knot_zone_contents_t *zone, conf_zone_t *zone_config, +int knot_dnssec_zone_sign_force(zone_contents_t *zone, conf_zone_t *zone_config, knot_changeset_t *out_ch, uint32_t *refresh_at, uint32_t new_serial) { @@ -176,7 +176,7 @@ int knot_dnssec_zone_sign_force(knot_zone_contents_t *zone, conf_zone_t *zone_co new_serial); } -int knot_dnssec_sign_changeset(const knot_zone_contents_t *zone, +int knot_dnssec_sign_changeset(const zone_contents_t *zone, conf_zone_t *zone_config, const knot_changeset_t *in_ch, knot_changeset_t *out_ch, diff --git a/src/knot/dnssec/zone-events.h b/src/knot/dnssec/zone-events.h index cb94526f37..5f3e3fa2e6 100644 --- a/src/knot/dnssec/zone-events.h +++ b/src/knot/dnssec/zone-events.h @@ -44,7 +44,7 @@ * * \return Error code, KNOT_EOK if successful. */ -int knot_dnssec_zone_sign(knot_zone_contents_t *zone, conf_zone_t *zone_config, +int knot_dnssec_zone_sign(zone_contents_t *zone, conf_zone_t *zone_config, knot_changeset_t *out_ch, knot_update_serial_t soa_up, uint32_t *refresh_at, uint32_t new_serial); @@ -61,7 +61,7 @@ int knot_dnssec_zone_sign(knot_zone_contents_t *zone, conf_zone_t *zone_config, * * \return Error code, KNOT_EOK if successful. */ -int knot_dnssec_zone_sign_force(knot_zone_contents_t *zone, conf_zone_t *zone_config, +int knot_dnssec_zone_sign_force(zone_contents_t *zone, conf_zone_t *zone_config, knot_changeset_t *out_ch, uint32_t *refresh_at, uint32_t new_serial); @@ -79,7 +79,7 @@ int knot_dnssec_zone_sign_force(knot_zone_contents_t *zone, conf_zone_t *zone_co * * \return Error code, KNOT_EOK if successful. */ -int knot_dnssec_sign_changeset(const knot_zone_contents_t *zone, +int knot_dnssec_sign_changeset(const zone_contents_t *zone, conf_zone_t *zone_config, const knot_changeset_t *in_ch, knot_changeset_t *out_ch, diff --git a/src/knot/dnssec/zone-nsec.c b/src/knot/dnssec/zone-nsec.c index 50902224f3..e0580b02b9 100644 --- a/src/knot/dnssec/zone-nsec.c +++ b/src/knot/dnssec/zone-nsec.c @@ -34,7 +34,7 @@ #include "common/debug.h" #include "libknot/util/utils.h" #include "libknot/packet/wire.h" -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "knot/zone/zone-diff.h" /*! @@ -44,7 +44,7 @@ * \param changeset Changeset to be used. * \return KNOT_E* */ -static int delete_nsec3_chain(const knot_zone_contents_t *zone, +static int delete_nsec3_chain(const zone_contents_t *zone, knot_changeset_t *changeset) { assert(zone); @@ -74,7 +74,7 @@ static int delete_nsec3_chain(const knot_zone_contents_t *zone, /*! * \brief Check if NSEC3 is enabled for given zone. */ -bool knot_is_nsec3_enabled(const knot_zone_contents_t *zone) +bool knot_is_nsec3_enabled(const zone_contents_t *zone) { if (!zone) { return false; @@ -87,7 +87,7 @@ bool knot_is_nsec3_enabled(const knot_zone_contents_t *zone) * \brief Get minimum TTL from zone SOA. * \note Value should be used for NSEC records. */ -static bool get_zone_soa_min_ttl(const knot_zone_contents_t *zone, +static bool get_zone_soa_min_ttl(const zone_contents_t *zone, uint32_t *ttl) { assert(zone); @@ -193,7 +193,7 @@ knot_dname_t *knot_nsec3_hash_to_dname(const uint8_t *hash, size_t hash_size, /*! * \brief Create NSEC or NSEC3 chain in the zone. */ -int knot_zone_create_nsec_chain(const knot_zone_contents_t *zone, +int knot_zone_create_nsec_chain(const zone_contents_t *zone, knot_changeset_t *changeset, const knot_zone_keys_t *zone_keys, const knot_dnssec_policy_t *policy) @@ -231,7 +231,7 @@ int knot_zone_create_nsec_chain(const knot_zone_contents_t *zone, /*! * \brief Fix NSEC or NSEC3 chain in the zone. */ -int knot_zone_fix_nsec_chain(const knot_zone_contents_t *zone, +int knot_zone_fix_nsec_chain(const zone_contents_t *zone, hattrie_t *sorted_changes, knot_changeset_t *out_ch, const knot_zone_keys_t *zone_keys, diff --git a/src/knot/dnssec/zone-nsec.h b/src/knot/dnssec/zone-nsec.h index aa7f539563..c8b6dc217f 100644 --- a/src/knot/dnssec/zone-nsec.h +++ b/src/knot/dnssec/zone-nsec.h @@ -31,7 +31,7 @@ #include <stdbool.h> #include "knot/updates/changesets.h" -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "libknot/dnssec/policy.h" #include "knot/dnssec/zone-keys.h" #include "libknot/dnssec/bitmap.h" @@ -43,7 +43,7 @@ * * \return NSEC3 is enabled. */ -bool knot_is_nsec3_enabled(const knot_zone_contents_t *zone); +bool knot_is_nsec3_enabled(const zone_contents_t *zone); /*! * \brief Create NSEC3 owner name from hash and zone apex. @@ -80,7 +80,7 @@ knot_dname_t *knot_create_nsec3_owner(const knot_dname_t *owner, * * \return Error code, KNOT_EOK if successful. */ -int knot_zone_create_nsec_chain(const knot_zone_contents_t *zone, +int knot_zone_create_nsec_chain(const zone_contents_t *zone, knot_changeset_t *changeset, const knot_zone_keys_t *zone_keys, const knot_dnssec_policy_t *policy); @@ -98,7 +98,7 @@ int knot_zone_create_nsec_chain(const knot_zone_contents_t *zone, * * \return Error code, KNOT_EOK if successful. */ -int knot_zone_fix_nsec_chain(const knot_zone_contents_t *zone, +int knot_zone_fix_nsec_chain(const zone_contents_t *zone, hattrie_t *sorted_changes, knot_changeset_t *out_ch, const knot_zone_keys_t *zone_keys, diff --git a/src/knot/dnssec/zone-sign.c b/src/knot/dnssec/zone-sign.c index ba0d3f0e60..ff53535118 100644 --- a/src/knot/dnssec/zone-sign.c +++ b/src/knot/dnssec/zone-sign.c @@ -36,7 +36,7 @@ #include "knot/updates/changesets.h" #include "common/debug.h" #include "knot/zone/node.h" -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" /*- private API - common functions -------------------------------------------*/ @@ -605,7 +605,7 @@ static int zone_tree_sign(knot_zone_tree_t *tree, * \brief Struct to carry data for 'add_rrsigs_for_nsec' callback function. */ typedef struct { - const knot_zone_contents_t *zone; + const zone_contents_t *zone; const knot_zone_keys_t *zone_keys; const knot_dnssec_policy_t *policy; knot_changeset_t *changeset; @@ -974,7 +974,7 @@ fail: * * \return Error code, KNOT_EOK if successful. */ -static int update_dnskeys(const knot_zone_contents_t *zone, +static int update_dnskeys(const zone_contents_t *zone, const knot_zone_keys_t *zone_keys, const knot_dnssec_policy_t *policy, knot_changeset_t *changeset) @@ -1155,7 +1155,7 @@ static int sign_changeset_wrap(knot_rrset_t *chg_rrset, void *data) bool rr_signed = false; // Find RR's node in zone, find out if we need to sign this RR const knot_node_t *node = - knot_zone_contents_find_node(args->zone, chg_rrset->owner); + zone_contents_find_node(args->zone, chg_rrset->owner); // If node is not in zone, all its RRSIGs were dropped - no-op if (node) { const knot_rrset_t *rrsigs = knot_node_rrset(node, KNOT_RRTYPE_RRSIG); @@ -1223,7 +1223,7 @@ static int free_helper_trie_node(value_t *val, void *d) /*! * \brief Update zone signatures and store performed changes in changeset. */ -int knot_zone_sign(const knot_zone_contents_t *zone, +int knot_zone_sign(const zone_contents_t *zone, const knot_zone_keys_t *zone_keys, const knot_dnssec_policy_t *policy, knot_changeset_t *changeset, @@ -1272,7 +1272,7 @@ int knot_zone_sign(const knot_zone_contents_t *zone, /*! * \brief Check if zone SOA signatures are expired. */ -bool knot_zone_sign_soa_expired(const knot_zone_contents_t *zone, +bool knot_zone_sign_soa_expired(const zone_contents_t *zone, const knot_zone_keys_t *zone_keys, const knot_dnssec_policy_t *policy) { @@ -1366,7 +1366,7 @@ int knot_zone_sign_update_soa(const knot_rrset_t *soa, /*! * \brief Sign changeset created by DDNS or zone-diff. */ -int knot_zone_sign_changeset(const knot_zone_contents_t *zone, +int knot_zone_sign_changeset(const zone_contents_t *zone, const knot_changeset_t *in_ch, knot_changeset_t *out_ch, hattrie_t **sorted_changes, diff --git a/src/knot/dnssec/zone-sign.h b/src/knot/dnssec/zone-sign.h index 752e63f874..d8203c270d 100644 --- a/src/knot/dnssec/zone-sign.h +++ b/src/knot/dnssec/zone-sign.h @@ -31,7 +31,7 @@ #include "knot/updates/changesets.h" #include "knot/zone/zone.h" -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "knot/dnssec/zone-keys.h" #include "libknot/dnssec/policy.h" @@ -59,7 +59,7 @@ typedef struct signed_info { * * \return Error code, KNOT_EOK if successful. */ -int knot_zone_sign(const knot_zone_contents_t *zone, +int knot_zone_sign(const zone_contents_t *zone, const knot_zone_keys_t *zone_keys, const knot_dnssec_policy_t *policy, knot_changeset_t *out_ch, uint32_t *refresh_at); @@ -89,7 +89,7 @@ int knot_zone_sign_update_soa(const knot_rrset_t *soa, const knot_rrset_t *rrsig * * \return True if zone SOA signatures need update, false othewise. */ -bool knot_zone_sign_soa_expired(const knot_zone_contents_t *zone, +bool knot_zone_sign_soa_expired(const zone_contents_t *zone, const knot_zone_keys_t *zone_keys, const knot_dnssec_policy_t *policy); @@ -105,7 +105,7 @@ bool knot_zone_sign_soa_expired(const knot_zone_contents_t *zone, * * \return Error code, KNOT_EOK if successful. */ -int knot_zone_sign_changeset(const knot_zone_contents_t *zone, +int knot_zone_sign_changeset(const zone_contents_t *zone, const knot_changeset_t *in_ch, knot_changeset_t *out_ch, hattrie_t **sorted_changes, diff --git a/src/knot/nameserver/axfr.c b/src/knot/nameserver/axfr.c index a35d9cfb2f..907e41bbf4 100644 --- a/src/knot/nameserver/axfr.c +++ b/src/knot/nameserver/axfr.c @@ -103,7 +103,7 @@ static int axfr_answer_init(struct query_data *qdata) /* Create transfer processing context. */ mm_ctx_t *mm = qdata->mm; - knot_zone_contents_t *zone = qdata->zone->contents; + zone_contents_t *zone = qdata->zone->contents; struct xfr_proc *xfer = mm->alloc(mm->ctx, sizeof(struct axfr_proc)); if (xfer == NULL) { return KNOT_ENOMEM; @@ -132,7 +132,7 @@ int xfr_process_list(knot_pkt_t *pkt, xfr_put_cb process_item, struct query_data int ret = KNOT_EOK; mm_ctx_t *mm = qdata->mm; struct xfr_proc *xfer = qdata->ext; - knot_zone_contents_t *zone = qdata->zone->contents; + zone_contents_t *zone = qdata->zone->contents; knot_rrset_t *soa_rr = knot_node_get_rrset(zone->apex, KNOT_RRTYPE_SOA); /* Prepend SOA on first packet. */ @@ -236,7 +236,7 @@ int axfr_process_answer(knot_ns_xfr_t *xfr) dbg_ns("ns_process_axfrin: incoming packet, wire size: %zu\n", xfr->wire_size); int ret = xfrin_process_axfr_packet(xfr, - (knot_zone_contents_t **)&xfr->data); + (zone_contents_t **)&xfr->data); if (ret > 0) { // transfer finished dbg_ns("ns_process_axfrin: AXFR finished, zone created.\n"); @@ -246,14 +246,14 @@ int axfr_process_answer(knot_ns_xfr_t *xfr) * Adjust zone so that node count is set properly and nodes are * marked authoritative / delegation point. */ - knot_zone_contents_t *zone = (knot_zone_contents_t *)xfr->data; + zone_contents_t *zone = (zone_contents_t *)xfr->data; assert(zone != NULL); log_zone_info("%s Serial %u -> %u\n", xfr->msg, knot_zone_serial(xfr->zone->contents), knot_zone_serial(zone)); dbg_ns_verb("ns_process_axfrin: adjusting zone.\n"); - int rc = knot_zone_contents_adjust_full(zone, NULL, NULL); + int rc = zone_contents_adjust_full(zone, NULL, NULL); if (rc != KNOT_EOK) { return rc; } diff --git a/src/knot/nameserver/internet.c b/src/knot/nameserver/internet.c index 99fc14d76e..ce96116a07 100644 --- a/src/knot/nameserver/internet.c +++ b/src/knot/nameserver/internet.c @@ -116,7 +116,7 @@ static bool dname_cname_cannot_synth(const knot_rrset_t *rrset, const knot_dname static bool have_dnssec(struct query_data *qdata) { return knot_pkt_have_dnssec(qdata->query) && - knot_zone_contents_is_signed(qdata->zone->contents); + zone_contents_is_signed(qdata->zone->contents); } /*! \brief Synthesize RRSIG for given parameters, store in 'qdata' for later use */ @@ -199,7 +199,7 @@ static int put_answer(knot_pkt_t *pkt, uint16_t type, struct query_data *qdata) /*! \brief Puts optional NS RRSet to the Authority section of the response. */ static int put_authority_ns(knot_pkt_t *pkt, struct query_data *qdata) { - const knot_zone_contents_t *zone = qdata->zone->contents; + const zone_contents_t *zone = qdata->zone->contents; dbg_ns("%s(%p, %p)\n", __func__, pkt, qdata); /* DS/DNSKEY queries are not referrals. NS is optional. @@ -227,7 +227,7 @@ static int put_authority_ns(knot_pkt_t *pkt, struct query_data *qdata) /*! \brief Puts optional SOA RRSet to the Authority section of the response. */ static int put_authority_soa(knot_pkt_t *pkt, struct query_data *qdata, - const knot_zone_contents_t *zone) + const zone_contents_t *zone) { dbg_ns("%s(%p, %p)\n", __func__, pkt, zone); knot_rrset_t *soa_rrset = knot_node_get_rrset(zone->apex, KNOT_RRTYPE_SOA); @@ -479,7 +479,7 @@ static int name_not_found(knot_pkt_t *pkt, struct query_data *qdata) static int solve_name(int state, knot_pkt_t *pkt, struct query_data *qdata) { dbg_ns("%s(%d, %p, %p)\n", __func__, state, pkt, qdata); - int ret = knot_zone_contents_find_dname(qdata->zone->contents, qdata->name, + int ret = zone_contents_find_dname(qdata->zone->contents, qdata->name, &qdata->node, &qdata->encloser, &qdata->previous); @@ -533,7 +533,7 @@ static int solve_answer_dnssec(int state, knot_pkt_t *pkt, struct query_data *qd static int solve_authority(int state, knot_pkt_t *pkt, struct query_data *qdata) { int ret = KNOT_ERROR; - const knot_zone_contents_t *zone_contents = qdata->zone->contents; + const zone_contents_t *zone_contents = qdata->zone->contents; switch (state) { case HIT: /* Positive response, add (optional) AUTHORITY NS. */ diff --git a/src/knot/nameserver/nsec_proofs.c b/src/knot/nameserver/nsec_proofs.c index 6ecbc56e7c..06fb85bb8f 100644 --- a/src/knot/nameserver/nsec_proofs.c +++ b/src/knot/nameserver/nsec_proofs.c @@ -92,14 +92,14 @@ static int ns_put_nsec3_from_node(const knot_node_t *node, * \retval NS_ERR_SERVFAIL if a runtime collision occured. The server should * respond with SERVFAIL in such case. */ -static int ns_put_covering_nsec3(const knot_zone_contents_t *zone, +static int ns_put_covering_nsec3(const zone_contents_t *zone, const knot_dname_t *name, struct query_data *qdata, knot_pkt_t *resp) { const knot_node_t *prev, *node; /*! \todo Check version. */ - int match = knot_zone_contents_find_nsec3_for_name(zone, name, + int match = zone_contents_find_nsec3_for_name(zone, name, &node, &prev); //assert(match >= 0); if (match < 0) { @@ -142,7 +142,7 @@ dbg_ns_exec_verb( * \retval NS_ERR_SERVFAIL */ static int ns_put_nsec3_closest_encloser_proof( - const knot_zone_contents_t *zone, + const zone_contents_t *zone, const knot_node_t **closest_encloser, const knot_dname_t *qname, struct query_data *qdata, @@ -155,14 +155,14 @@ static int ns_put_nsec3_closest_encloser_proof( assert(resp != NULL); // this function should be called only if NSEC3 is enabled in the zone - assert(knot_zone_contents_nsec3params(zone) != NULL); + assert(zone_contents_nsec3params(zone) != NULL); dbg_ns_verb("Adding closest encloser proof\n"); - if (knot_zone_contents_nsec3params(zone) == NULL) { + if (zone_contents_nsec3params(zone) == NULL) { dbg_ns_exec_verb( char *name = knot_dname_to_str(knot_node_owner( - knot_zone_contents_apex(zone))); + zone_contents_apex(zone))); dbg_ns_verb("No NSEC3PARAM found in zone %s.\n", name); free(name); ); @@ -282,7 +282,7 @@ dbg_ns_exec_verb( * \param qdata Query data. * \param resp Response to put the NSEC3s into. */ -static int ns_put_nsec_wildcard(const knot_zone_contents_t *zone, +static int ns_put_nsec_wildcard(const zone_contents_t *zone, const knot_dname_t *qname, const knot_node_t *previous, struct query_data *qdata, @@ -290,12 +290,12 @@ static int ns_put_nsec_wildcard(const knot_zone_contents_t *zone, { // check if we have previous; if not, find one using the tree if (previous == NULL) { - previous = knot_zone_contents_find_previous(zone, qname); + previous = zone_contents_find_previous(zone, qname); assert(previous != NULL); /*! * \todo isn't this handled in adjusting? - * knot_zone_contents_adjust_node_in_tree_ptr() + * zone_contents_adjust_node_in_tree_ptr() */ while (!knot_node_is_auth(previous)) { previous = knot_node_previous(previous); @@ -331,7 +331,7 @@ static int ns_put_nsec_wildcard(const knot_zone_contents_t *zone, * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ -static int ns_put_nsec3_no_wildcard_child(const knot_zone_contents_t *zone, +static int ns_put_nsec3_no_wildcard_child(const zone_contents_t *zone, const knot_node_t *node, struct query_data *qdata, knot_pkt_t *resp) @@ -372,7 +372,7 @@ static int ns_put_nsec3_no_wildcard_child(const knot_zone_contents_t *zone, * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ -static int ns_put_nsec3_wildcard(const knot_zone_contents_t *zone, +static int ns_put_nsec3_wildcard(const zone_contents_t *zone, const knot_node_t *closest_encloser, const knot_dname_t *qname, struct query_data *qdata, @@ -431,7 +431,7 @@ dbg_ns_exec_verb( static int ns_put_nsec_nsec3_wildcard_answer(const knot_node_t *node, const knot_node_t *closest_encloser, const knot_node_t *previous, - const knot_zone_contents_t *zone, + const zone_contents_t *zone, const knot_dname_t *qname, struct query_data *qdata, knot_pkt_t *resp) @@ -473,7 +473,7 @@ static int ns_put_nsec_nsec3_wildcard_answer(const knot_node_t *node, * \retval NS_ERR_SERVFAIL */ static int ns_put_nsec_nxdomain(const knot_dname_t *qname, - const knot_zone_contents_t *zone, + const zone_contents_t *zone, const knot_node_t *previous, const knot_node_t *closest_encloser, struct query_data *qdata, @@ -485,12 +485,12 @@ static int ns_put_nsec_nxdomain(const knot_dname_t *qname, // check if we have previous; if not, find one using the tree if (previous == NULL) { /*! \todo Check version. */ - previous = knot_zone_contents_find_previous(zone, qname); + previous = zone_contents_find_previous(zone, qname); assert(previous != NULL); /*! * \todo isn't this handled in adjusting? - * knot_zone_contents_adjust_node_in_tree_ptr() + * zone_contents_adjust_node_in_tree_ptr() */ while (!knot_node_is_auth(previous)) { previous = knot_node_previous(previous); @@ -541,7 +541,7 @@ dbg_ns_exec_verb( dbg_ns_verb("Previous node: %s\n", name); free(name); ); - assert(prev_new != knot_zone_contents_apex(zone)); + assert(prev_new != zone_contents_apex(zone)); prev_new = knot_node_previous(prev_new); } assert(knot_dname_cmp(knot_node_owner(prev_new), @@ -591,7 +591,7 @@ dbg_ns_exec_verb( * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ -static int ns_put_nsec3_nxdomain(const knot_zone_contents_t *zone, +static int ns_put_nsec3_nxdomain(const zone_contents_t *zone, const knot_node_t *closest_encloser, const knot_dname_t *qname, struct query_data *qdata, @@ -631,7 +631,7 @@ static int ns_put_nsec3_nxdomain(const knot_zone_contents_t *zone, * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ -static int ns_put_nsec_nsec3_nxdomain(const knot_zone_contents_t *zone, +static int ns_put_nsec_nsec3_nxdomain(const zone_contents_t *zone, const knot_node_t *previous, const knot_node_t *closest_encloser, const knot_dname_t *qname, @@ -667,7 +667,7 @@ static int ns_put_nsec_nsec3_nxdomain(const knot_zone_contents_t *zone, static int ns_put_nsec_nsec3_nodata(const knot_node_t *node, const knot_node_t *closest_encloser, const knot_node_t *previous, - const knot_zone_contents_t *zone, + const zone_contents_t *zone, const knot_dname_t *qname, struct query_data *qdata, knot_pkt_t *resp) diff --git a/src/knot/nameserver/update.c b/src/knot/nameserver/update.c index 8d67f3c736..5055da9769 100644 --- a/src/knot/nameserver/update.c +++ b/src/knot/nameserver/update.c @@ -89,7 +89,7 @@ static int update_forward(knot_pkt_t *pkt, struct query_data *qdata) static int update_prereq_check(struct query_data *qdata) { knot_pkt_t *query = qdata->query; - const knot_zone_contents_t *contents = qdata->zone->contents; + const zone_contents_t *contents = qdata->zone->contents; /* * 2) DDNS Prerequisities Section processing (RFC2136, Section 3.2). @@ -194,8 +194,8 @@ int update_answer(knot_pkt_t *pkt, struct query_data *qdata) * order to get rid of duplicate code. */ int knot_ns_process_update(const knot_pkt_t *query, - knot_zone_contents_t *old_contents, - knot_zone_contents_t **new_contents, + zone_contents_t *old_contents, + zone_contents_t **new_contents, knot_changesets_t *chgs, knot_rcode_t *rcode, uint32_t new_serial) { @@ -208,7 +208,7 @@ int knot_ns_process_update(const knot_pkt_t *query, // 1) Create zone shallow copy. dbg_ns_verb("Creating shallow copy of the zone...\n"); - knot_zone_contents_t *contents_copy = NULL; + zone_contents_t *contents_copy = NULL; int ret = xfrin_prepare_zone_copy(old_contents, &contents_copy); if (ret != KNOT_EOK) { dbg_ns("Failed to prepare zone copy: %s\n", @@ -320,8 +320,8 @@ static int zones_process_update_auth(zone_t *zone, knot_pkt_t *query, uint32_t new_serial = zones_next_serial(zone); - knot_zone_contents_t *new_contents = NULL; - knot_zone_contents_t *old_contents = zone->contents; + zone_contents_t *new_contents = NULL; + zone_contents_t *old_contents = zone->contents; ret = knot_ns_process_update(query, old_contents, &new_contents, chgsets, rcode, new_serial); if (ret != KNOT_EOK) { @@ -433,7 +433,7 @@ static int zones_process_update_auth(zone_t *zone, knot_pkt_t *query, } } else { // Set NSEC3 nodes if no new signatures were created (or auto DNSSEC is off) - ret = knot_zone_contents_adjust_nsec3_pointers(new_contents); + ret = zone_contents_adjust_nsec3_pointers(new_contents); if (ret != KNOT_EOK) { zones_store_changesets_rollback(transaction); zones_free_merged_changesets(chgsets, sec_chs); diff --git a/src/knot/server/notify.c b/src/knot/server/notify.c index 825daf3811..955e5303c5 100644 --- a/src/knot/server/notify.c +++ b/src/knot/server/notify.c @@ -44,7 +44,7 @@ int notify_create_request(const zone_t *zone, knot_pkt_t *pkt) { - knot_zone_contents_t *contents = zone->contents; + zone_contents_t *contents = zone->contents; if (contents == NULL) { return KNOT_EINVAL; /* Not valid for stub zones. */ } diff --git a/src/knot/server/xfr-handler.c b/src/knot/server/xfr-handler.c index 23aa90b53c..b55773feb6 100644 --- a/src/knot/server/xfr-handler.c +++ b/src/knot/server/xfr-handler.c @@ -272,10 +272,10 @@ static void xfr_task_cleanup(knot_ns_xfr_t *rq) dbg_xfr_verb("Cleaning up after XFR-in.\n"); if (rq->type == XFR_TYPE_AIN) { if (rq->flags & XFR_FLAG_AXFR_FINISHED) { - knot_zone_contents_deep_free(&rq->new_contents); + zone_contents_deep_free(&rq->new_contents); } else if (rq->data) { - knot_zone_contents_t *zone = rq->data; - knot_zone_contents_deep_free(&zone); + zone_contents_t *zone = rq->data; + zone_contents_deep_free(&zone); rq->data = NULL; } } else if (rq->type == XFR_TYPE_IIN) { @@ -579,7 +579,7 @@ int knot_ns_switch_zone(knot_ns_xfr_t *xfr) return KNOT_EINVAL; } - knot_zone_contents_t *zone = (knot_zone_contents_t *)xfr->new_contents; + zone_contents_t *zone = (zone_contents_t *)xfr->new_contents; dbg_xfr("Replacing zone by new one: %p\n", zone); if (zone == NULL) { @@ -592,7 +592,7 @@ int knot_ns_switch_zone(knot_ns_xfr_t *xfr) zone_t *z = xfr->zone; if (z == NULL) { char *name = knot_dname_to_str(knot_node_owner( - knot_zone_contents_apex(zone))); + zone_contents_apex(zone))); dbg_xfr("Failed to replace zone %s, old zone " "not found\n", name); free(name); diff --git a/src/knot/server/xfr-handler.h b/src/knot/server/xfr-handler.h index e79241535c..b991dfd0c2 100644 --- a/src/knot/server/xfr-handler.h +++ b/src/knot/server/xfr-handler.h @@ -120,7 +120,7 @@ typedef struct knot_ns_xfr { void *data; zone_t *zone; char* zname; - knot_zone_contents_t *new_contents; + zone_contents_t *new_contents; char *msg; /*! \note [TSIG] TSIG fields */ diff --git a/src/knot/server/zones.c b/src/knot/server/zones.c index 4234daa587..b9c6ff1792 100644 --- a/src/knot/server/zones.c +++ b/src/knot/server/zones.c @@ -39,7 +39,7 @@ #include "knot/updates/changesets.h" #include "knot/updates/ddns.h" #include "knot/updates/xfr-in.h" -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "knot/zone/zone-diff.h" #include "knot/zone/zone.h" #include "knot/zone/zonedb.h" @@ -80,7 +80,7 @@ static uint32_t zones_soa_timer(zone_t *zone, uint32_t (*rr_func)(const knot_rrs rcu_read_lock(); - knot_zone_contents_t * zc = zone->contents; + zone_contents_t * zc = zone->contents; if (!zc) { rcu_read_unlock(); return 0; @@ -831,8 +831,8 @@ uint32_t zones_next_serial(zone_t *zone) return new_serial; } -static bool apex_rr_changed(const knot_zone_contents_t *old_contents, - const knot_zone_contents_t *new_contents, +static bool apex_rr_changed(const zone_contents_t *old_contents, + const zone_contents_t *new_contents, uint16_t type) { const knot_rrset_t *old_rr = knot_node_rrset(old_contents->apex, type); @@ -845,14 +845,14 @@ static bool apex_rr_changed(const knot_zone_contents_t *old_contents, return !knot_rrset_equal(old_rr, new_rr, KNOT_RRSET_COMPARE_WHOLE); } -bool zones_dnskey_changed(const knot_zone_contents_t *old_contents, - const knot_zone_contents_t *new_contents) +bool zones_dnskey_changed(const zone_contents_t *old_contents, + const zone_contents_t *new_contents) { return apex_rr_changed(old_contents, new_contents, KNOT_RRTYPE_DNSKEY); } -bool zones_nsec3param_changed(const knot_zone_contents_t *old_contents, - const knot_zone_contents_t *new_contents) +bool zones_nsec3param_changed(const zone_contents_t *old_contents, + const zone_contents_t *new_contents) { return apex_rr_changed(old_contents, new_contents, KNOT_RRTYPE_NSEC3PARAM); } @@ -886,7 +886,7 @@ static int zones_open_free_filename(const char *old_name, char **new_name) /*----------------------------------------------------------------------------*/ -static int save_transferred_zone(knot_zone_contents_t *zone, const struct sockaddr_storage *from, const char *fname) +static int save_transferred_zone(zone_contents_t *zone, const struct sockaddr_storage *from, const char *fname) { assert(zone != NULL && fname != NULL); @@ -954,7 +954,7 @@ int zones_zonefile_sync(zone_t *zone, journal_t *journal) /* Lock RCU for zone contents. */ rcu_read_lock(); - knot_zone_contents_t *contents = zone->contents; + zone_contents_t *contents = zone->contents; if (!contents) { rcu_read_unlock(); pthread_mutex_unlock(&zone->lock); @@ -1157,14 +1157,14 @@ int zones_save_zone(const knot_ns_xfr_t *xfr) rcu_read_lock(); - knot_zone_contents_t *new_zone = xfr->new_contents; + zone_contents_t *new_zone = xfr->new_contents; const char *zonefile = xfr->zone->conf->file; /* Check if the new zone apex dname matches zone name. */ knot_dname_t *cur_name = knot_dname_from_str(xfr->zone->conf->name); const knot_dname_t *new_name = NULL; - new_name = knot_node_owner(knot_zone_contents_apex(new_zone)); + new_name = knot_node_owner(zone_contents_apex(new_zone)); int r = knot_dname_cmp(cur_name, new_name); knot_dname_free(&cur_name); if (r != 0) { @@ -1420,7 +1420,7 @@ int zones_create_changeset(const zone_t *old_zone, return KNOT_EINVAL; } - int ret = knot_zone_contents_create_diff(old_zone->contents, + int ret = zone_contents_create_diff(old_zone->contents, new_zone->contents, changeset); if (ret != KNOT_EOK) { @@ -1449,7 +1449,7 @@ int zones_create_changeset(const zone_t *old_zone, int zones_store_and_apply_chgsets(knot_changesets_t *chs, zone_t *zone, - knot_zone_contents_t **new_contents, + zone_contents_t **new_contents, const char *msgpref, int type) { int ret = KNOT_EOK; @@ -1654,7 +1654,7 @@ int zones_dnssec_sign(zone_t *zone, bool force, uint32_t *refresh_at) } if (!zones_changesets_empty(chs)) { - knot_zone_contents_t *new_c = NULL; + zone_contents_t *new_c = NULL; ret = zones_store_and_apply_chgsets(chs, zone, &new_c, "DNSSEC", XFR_TYPE_UPDATE); chs = NULL; // freed by zones_store_and_apply_chgsets() @@ -2105,7 +2105,7 @@ static int store_chgsets_after_load(zone_t *old_zone, zone_t *zone, assert(transaction); - knot_zone_contents_t *new_contents = NULL; + zone_contents_t *new_contents = NULL; if (apply_chgset) { /* Apply DNSSEC changeset to the zone as it was not * applied yet. In this case, no diff should have been diff --git a/src/knot/server/zones.h b/src/knot/server/zones.h index 2ff48ddde6..e191b5e66b 100644 --- a/src/knot/server/zones.h +++ b/src/knot/server/zones.h @@ -167,7 +167,7 @@ int zones_create_changeset(const zone_t *old_zone, int zones_store_and_apply_chgsets(knot_changesets_t *chs, zone_t *zone, - knot_zone_contents_t **new_contents, + zone_contents_t **new_contents, const char *msgpref, int type); /*! @@ -274,10 +274,10 @@ int zones_dnssec_ev(event_t *event); /*! \note Exported API for UPDATE processing, but this should really be done * in a better way as it's very similar code to ixfr-from-diff signing code. */ -bool zones_dnskey_changed(const knot_zone_contents_t *old_contents, - const knot_zone_contents_t *new_contents); -bool zones_nsec3param_changed(const knot_zone_contents_t *old_contents, - const knot_zone_contents_t *new_contents); +bool zones_dnskey_changed(const zone_contents_t *old_contents, + const zone_contents_t *new_contents); +bool zones_nsec3param_changed(const zone_contents_t *old_contents, + const zone_contents_t *new_contents); int zones_merge_and_store_changesets(zone_t *zone, knot_changesets_t *diff_chs, knot_changesets_t *sec_chs, diff --git a/src/knot/updates/ddns.c b/src/knot/updates/ddns.c index 787a85a6e3..aff6fb6f8b 100644 --- a/src/knot/updates/ddns.c +++ b/src/knot/updates/ddns.c @@ -201,7 +201,7 @@ static int knot_ddns_add_prereq(knot_ddns_prereq_t *prereqs, /*----------------------------------------------------------------------------*/ -static int knot_ddns_check_exist(const knot_zone_contents_t *zone, +static int knot_ddns_check_exist(const zone_contents_t *zone, const knot_rrset_t *rrset, knot_rcode_t *rcode) { assert(zone != NULL); @@ -211,13 +211,13 @@ static int knot_ddns_check_exist(const knot_zone_contents_t *zone, assert(knot_rrset_class(rrset) == KNOT_CLASS_ANY); if (!knot_dname_is_sub(knot_rrset_owner(rrset), - knot_node_owner(knot_zone_contents_apex(zone)))) { + knot_node_owner(zone_contents_apex(zone)))) { *rcode = KNOT_RCODE_NOTZONE; return KNOT_EOUTOFZONE; } const knot_node_t *node; - node = knot_zone_contents_find_node(zone, knot_rrset_owner(rrset)); + node = zone_contents_find_node(zone, knot_rrset_owner(rrset)); if (node == NULL) { *rcode = KNOT_RCODE_NXRRSET; return KNOT_ENONODE; @@ -231,7 +231,7 @@ static int knot_ddns_check_exist(const knot_zone_contents_t *zone, /*----------------------------------------------------------------------------*/ -static int knot_ddns_check_exist_full(const knot_zone_contents_t *zone, +static int knot_ddns_check_exist_full(const zone_contents_t *zone, const knot_rrset_t *rrset, knot_rcode_t *rcode) { @@ -241,7 +241,7 @@ static int knot_ddns_check_exist_full(const knot_zone_contents_t *zone, assert(knot_rrset_type(rrset) != KNOT_RRTYPE_ANY); if (!knot_dname_is_sub(knot_rrset_owner(rrset), - knot_node_owner(knot_zone_contents_apex(zone)))) { + knot_node_owner(zone_contents_apex(zone)))) { *rcode = KNOT_RCODE_NOTZONE; return KNOT_EOUTOFZONE; } @@ -249,7 +249,7 @@ static int knot_ddns_check_exist_full(const knot_zone_contents_t *zone, const knot_node_t *node; const knot_rrset_t *found; - node = knot_zone_contents_find_node(zone, knot_rrset_owner(rrset)); + node = zone_contents_find_node(zone, knot_rrset_owner(rrset)); if (node == NULL) { *rcode = KNOT_RCODE_NXRRSET; return KNOT_EPREREQ; @@ -273,7 +273,7 @@ static int knot_ddns_check_exist_full(const knot_zone_contents_t *zone, /*----------------------------------------------------------------------------*/ -static int knot_ddns_check_not_exist(const knot_zone_contents_t *zone, +static int knot_ddns_check_not_exist(const zone_contents_t *zone, const knot_rrset_t *rrset, knot_rcode_t *rcode) { @@ -284,14 +284,14 @@ static int knot_ddns_check_not_exist(const knot_zone_contents_t *zone, assert(knot_rrset_class(rrset) == KNOT_CLASS_NONE); if (!knot_dname_is_sub(knot_rrset_owner(rrset), - knot_node_owner(knot_zone_contents_apex(zone)))) { + knot_node_owner(zone_contents_apex(zone)))) { *rcode = KNOT_RCODE_NOTZONE; return KNOT_EOUTOFZONE; } const knot_node_t *node; - node = knot_zone_contents_find_node(zone, knot_rrset_owner(rrset)); + node = zone_contents_find_node(zone, knot_rrset_owner(rrset)); if (node == NULL) { return KNOT_EOK; } else if (knot_node_rrset(node, knot_rrset_type(rrset)) == NULL) { @@ -306,7 +306,7 @@ static int knot_ddns_check_not_exist(const knot_zone_contents_t *zone, /*----------------------------------------------------------------------------*/ -static int knot_ddns_check_in_use(const knot_zone_contents_t *zone, +static int knot_ddns_check_in_use(const zone_contents_t *zone, const knot_dname_t *dname, knot_rcode_t *rcode) { @@ -315,14 +315,14 @@ static int knot_ddns_check_in_use(const knot_zone_contents_t *zone, assert(rcode != NULL); if (!knot_dname_is_sub(dname, - knot_node_owner(knot_zone_contents_apex(zone)))) { + knot_node_owner(zone_contents_apex(zone)))) { *rcode = KNOT_RCODE_NOTZONE; return KNOT_EOUTOFZONE; } const knot_node_t *node; - node = knot_zone_contents_find_node(zone, dname); + node = zone_contents_find_node(zone, dname); if (node == NULL) { *rcode = KNOT_RCODE_NXDOMAIN; return KNOT_EPREREQ; @@ -336,7 +336,7 @@ static int knot_ddns_check_in_use(const knot_zone_contents_t *zone, /*----------------------------------------------------------------------------*/ -static int knot_ddns_check_not_in_use(const knot_zone_contents_t *zone, +static int knot_ddns_check_not_in_use(const zone_contents_t *zone, const knot_dname_t *dname, knot_rcode_t *rcode) { @@ -345,14 +345,14 @@ static int knot_ddns_check_not_in_use(const knot_zone_contents_t *zone, assert(rcode != NULL); if (!knot_dname_is_sub(dname, - knot_node_owner(knot_zone_contents_apex(zone)))) { + knot_node_owner(zone_contents_apex(zone)))) { *rcode = KNOT_RCODE_NOTZONE; return KNOT_EOUTOFZONE; } const knot_node_t *node; - node = knot_zone_contents_find_node(zone, dname); + node = zone_contents_find_node(zone, dname); if (node == NULL) { return KNOT_EOK; } else if (knot_node_rrset_count(node) == 0) { @@ -367,7 +367,7 @@ static int knot_ddns_check_not_in_use(const knot_zone_contents_t *zone, /* API functions */ /*----------------------------------------------------------------------------*/ -int knot_ddns_check_zone(const knot_zone_contents_t *zone, +int knot_ddns_check_zone(const zone_contents_t *zone, const knot_pkt_t *query, knot_rcode_t *rcode) { if (zone == NULL || query == NULL || rcode == NULL) { @@ -383,7 +383,7 @@ int knot_ddns_check_zone(const knot_zone_contents_t *zone, } // check zone CLASS - if (knot_zone_contents_class(zone) != + if (zone_contents_class(zone) != knot_pkt_qclass(query)) { *rcode = KNOT_RCODE_NOTAUTH; return KNOT_ENOZONE; @@ -432,7 +432,7 @@ int knot_ddns_process_prereqs(const knot_pkt_t *query, /*----------------------------------------------------------------------------*/ -int knot_ddns_check_prereqs(const knot_zone_contents_t *zone, +int knot_ddns_check_prereqs(const zone_contents_t *zone, knot_ddns_prereq_t **prereqs, knot_rcode_t *rcode) { int i, ret; @@ -675,7 +675,7 @@ static void knot_ddns_check_add_rr(knot_changeset_t *changeset, /*----------------------------------------------------------------------------*/ -static knot_node_t *knot_ddns_get_node(knot_zone_contents_t *zone, +static knot_node_t *knot_ddns_get_node(zone_contents_t *zone, const knot_rrset_t *rr) { assert(zone != NULL); @@ -686,9 +686,9 @@ static knot_node_t *knot_ddns_get_node(knot_zone_contents_t *zone, dbg_ddns_detail("Searching for node...\n"); if (knot_rrset_is_nsec3rel(rr)) { - node = knot_zone_contents_get_nsec3_node(zone, owner); + node = zone_contents_get_nsec3_node(zone, owner); } else { - node = knot_zone_contents_get_node(zone, owner); + node = zone_contents_get_node(zone, owner); } return node; @@ -1049,7 +1049,7 @@ static int knot_ddns_add_rr_to_chgset(const knot_rrset_t *rr, static int knot_ddns_process_add(const knot_rrset_t *rr, knot_node_t *node, - knot_zone_contents_t *zone, + zone_contents_t *zone, knot_changeset_t *changeset, knot_changes_t *changes, knot_rrset_t **rr_copy) @@ -1065,7 +1065,7 @@ static int knot_ddns_process_add(const knot_rrset_t *rr, if (node == NULL) { // create new node, connect it to the zone nodes dbg_ddns_detail("Node not found. Creating new.\n"); - int ret = knot_zone_contents_create_node(zone, rr, &node); + int ret = zone_contents_create_node(zone, rr, &node); if (ret != KNOT_EOK) { dbg_xfrin("Failed to create new node in zone.\n"); return ret; @@ -1162,7 +1162,7 @@ static int knot_ddns_process_add(const knot_rrset_t *rr, */ static int knot_ddns_process_rem_rr(const knot_rrset_t *rr, knot_node_t *node, - knot_zone_contents_t *zone, + zone_contents_t *zone, knot_changeset_t *changeset, knot_changes_t *changes, uint16_t qclass) { @@ -1596,7 +1596,7 @@ static int knot_ddns_process_rem_all(knot_node_t *node, /*----------------------------------------------------------------------------*/ static int knot_ddns_process_rr(const knot_rrset_t *rr, - knot_zone_contents_t *zone, + zone_contents_t *zone, knot_changeset_t *changeset, knot_changes_t *changes, uint16_t qclass, knot_rrset_t **rr_copy) @@ -1612,7 +1612,7 @@ static int knot_ddns_process_rr(const knot_rrset_t *rr, /* 2) Decide what to do. */ - if (knot_rrset_class(rr) == knot_zone_contents_class(zone)) { + if (knot_rrset_class(rr) == zone_contents_class(zone)) { return knot_ddns_process_add(rr, node, zone, changeset, changes, rr_copy); } else if (node == NULL) { @@ -1647,7 +1647,7 @@ static int knot_ddns_process_rr(const knot_rrset_t *rr, * If anything fails, rollback must be done. The xfrin_rollback_update() may * be good for this. */ -int knot_ddns_process_update(knot_zone_contents_t *zone, +int knot_ddns_process_update(zone_contents_t *zone, const knot_pkt_t *query, knot_changeset_t *changeset, knot_changes_t *changes, @@ -1661,7 +1661,7 @@ int knot_ddns_process_update(knot_zone_contents_t *zone, int ret = KNOT_EOK; /* Copy base SOA RR. */ - const knot_rrset_t *soa = knot_node_rrset(knot_zone_contents_apex(zone), + const knot_rrset_t *soa = knot_node_rrset(zone_contents_apex(zone), KNOT_RRTYPE_SOA); knot_rrset_t *soa_begin = NULL; knot_rrset_t *soa_end = NULL; @@ -1780,7 +1780,7 @@ int knot_ddns_process_update(knot_zone_contents_t *zone, /* And replace it in the zone. */ ret = xfrin_replace_rrset_in_node( - knot_zone_contents_get_apex(zone), + zone_contents_get_apex(zone), soa_end, changes, zone); if (ret != KNOT_EOK) { dbg_ddns("Failed to copy replace SOA in zone: %s\n", diff --git a/src/knot/updates/ddns.h b/src/knot/updates/ddns.h index da3645006f..0fdb67527c 100644 --- a/src/knot/updates/ddns.h +++ b/src/knot/updates/ddns.h @@ -57,16 +57,16 @@ typedef struct knot_ddns_prereq_t { size_t not_in_use_allocd; } knot_ddns_prereq_t; -int knot_ddns_check_zone(const knot_zone_contents_t *zone, +int knot_ddns_check_zone(const zone_contents_t *zone, const knot_pkt_t *query, knot_rcode_t *rcode); int knot_ddns_process_prereqs(const knot_pkt_t *query, knot_ddns_prereq_t **prereqs, knot_rcode_t *rcode); -int knot_ddns_check_prereqs(const knot_zone_contents_t *zone, +int knot_ddns_check_prereqs(const zone_contents_t *zone, knot_ddns_prereq_t **prereqs, knot_rcode_t *rcode); -int knot_ddns_process_update(knot_zone_contents_t *zone, +int knot_ddns_process_update(zone_contents_t *zone, const knot_pkt_t *query, knot_changeset_t *changeset, knot_changes_t *changes, diff --git a/src/knot/updates/xfr-in.c b/src/knot/updates/xfr-in.c index 46a089ed21..8a64d8350d 100644 --- a/src/knot/updates/xfr-in.c +++ b/src/knot/updates/xfr-in.c @@ -27,7 +27,7 @@ #include "libknot/packet/pkt.h" #include "libknot/dname.h" #include "knot/zone/zone.h" -#include "knot/zone/zone-create.h" +#include "knot/zone/zonefile.h" #include "knot/dnssec/zone-nsec.h" #include "knot/dnssec/zone-sign.h" #include "libknot/dnssec/random.h" @@ -58,18 +58,18 @@ static int knot_ns_tsig_required(int packet_nr) /* API functions */ /*----------------------------------------------------------------------------*/ -int xfrin_transfer_needed(const knot_zone_contents_t *zone, +int xfrin_transfer_needed(const zone_contents_t *zone, knot_pkt_t *soa_response) { /* * Retrieve the local Serial */ const knot_rrset_t *soa_rrset = - knot_node_rrset(knot_zone_contents_apex(zone), + knot_node_rrset(zone_contents_apex(zone), KNOT_RRTYPE_SOA); if (soa_rrset == NULL) { char *name = knot_dname_to_str(knot_node_owner( - knot_zone_contents_apex(zone))); + zone_contents_apex(zone))); dbg_xfrin("SOA RRSet missing in the zone %s!\n", name); free(name); return KNOT_ERROR; @@ -279,7 +279,7 @@ static int xfrin_take_rr(const knot_pktsection_t *answer, knot_rrset_t **rr, uin /*----------------------------------------------------------------------------*/ -int xfrin_process_axfr_packet(knot_ns_xfr_t *xfr, knot_zone_contents_t **zone) +int xfrin_process_axfr_packet(knot_ns_xfr_t *xfr, zone_contents_t **zone) { if (xfr->wire == NULL) { return KNOT_EINVAL; @@ -301,7 +301,7 @@ int xfrin_process_axfr_packet(knot_ns_xfr_t *xfr, knot_zone_contents_t **zone) if (rr->type != KNOT_RRTYPE_SOA) { return KNOT_EMALF; } - *zone = knot_zone_contents_new(rr->owner); + *zone = zone_contents_new(rr->owner); if (*zone == NULL) { knot_pkt_free(&packet); return KNOT_ENOMEM; @@ -656,7 +656,7 @@ cleanup: /* Applying changesets to zone */ /*----------------------------------------------------------------------------*/ -void xfrin_zone_contents_free(knot_zone_contents_t **contents) +void xfrin_zone_contents_free(zone_contents_t **contents) { /*! \todo This should be all in some API!! */ @@ -844,7 +844,7 @@ dbg_xfrin_exec_detail( /*----------------------------------------------------------------------------*/ -static knot_node_t *xfrin_add_new_node(knot_zone_contents_t *contents, +static knot_node_t *xfrin_add_new_node(zone_contents_t *contents, knot_rrset_t *rrset, int is_nsec3) { knot_node_t *node = knot_node_new(knot_rrset_get_owner(rrset), @@ -859,9 +859,9 @@ static knot_node_t *xfrin_add_new_node(knot_zone_contents_t *contents, // insert the node into zone structures and create parents if // necessary if (is_nsec3) { - ret = knot_zone_contents_add_nsec3_node(contents, node, 1, 0); + ret = zone_contents_add_nsec3_node(contents, node, 1, 0); } else { - ret = knot_zone_contents_add_node(contents, node, 1, 0); + ret = zone_contents_add_node(contents, node, 1, 0); } if (ret != KNOT_EOK) { dbg_xfrin("Failed to add new node to zone contents.\n"); @@ -877,7 +877,7 @@ static knot_node_t *xfrin_add_new_node(knot_zone_contents_t *contents, int xfrin_replace_rrset_in_node(knot_node_t *node, knot_rrset_t *rrset_new, knot_changes_t *changes, - knot_zone_contents_t *contents) + zone_contents_t *contents) { if (node == NULL || rrset_new == NULL || changes == NULL || contents == NULL) { @@ -900,7 +900,7 @@ int xfrin_replace_rrset_in_node(knot_node_t *node, // insert the new RRSet to the node dbg_xfrin_verb("Adding new RRSet.\n"); - ret = knot_zone_contents_add_rrset(contents, rrset_new, &node, + ret = zone_contents_add_rrset(contents, rrset_new, &node, KNOT_RRSET_DUPL_SKIP); if (ret < 0) { @@ -923,7 +923,7 @@ static int xfrin_apply_add_normal(knot_changes_t *changes, knot_rrset_t *add, knot_node_t *node, knot_rrset_t **rrset, - knot_zone_contents_t *contents) + zone_contents_t *contents) { assert(changes != NULL); assert(add != NULL); @@ -973,7 +973,7 @@ dbg_xfrin_exec_detail( * doesn't matter whether there are some extra dnames to * be added to the table or not. */ - ret = knot_zone_contents_add_rrset(contents, add, &node, + ret = zone_contents_add_rrset(contents, add, &node, KNOT_RRSET_DUPL_SKIP); if (ret < 0) { @@ -1061,7 +1061,7 @@ static int xfrin_switch_nodes_in_node(knot_node_t **node, void *data) /*----------------------------------------------------------------------------*/ -static int xfrin_switch_nodes(knot_zone_contents_t *contents_copy) +static int xfrin_switch_nodes(zone_contents_t *contents_copy) { assert(contents_copy != NULL); @@ -1079,7 +1079,7 @@ static int xfrin_switch_nodes(knot_zone_contents_t *contents_copy) /*----------------------------------------------------------------------------*/ -static void xfrin_zone_contents_free2(knot_zone_contents_t **contents) +static void xfrin_zone_contents_free2(zone_contents_t **contents) { /*! \todo This should be all in some API!! */ @@ -1110,8 +1110,8 @@ static int xfrin_cleanup_old_nodes(knot_node_t **node, void *data) /*----------------------------------------------------------------------------*/ -static void xfrin_cleanup_failed_update(knot_zone_contents_t *old_contents, - knot_zone_contents_t **new_contents) +static void xfrin_cleanup_failed_update(zone_contents_t *old_contents, + zone_contents_t **new_contents) { if (old_contents == NULL && new_contents == NULL) { return; @@ -1134,8 +1134,8 @@ static void xfrin_cleanup_failed_update(knot_zone_contents_t *old_contents, /*----------------------------------------------------------------------------*/ -void xfrin_rollback_update(knot_zone_contents_t *old_contents, - knot_zone_contents_t **new_contents, +void xfrin_rollback_update(zone_contents_t *old_contents, + zone_contents_t **new_contents, knot_changes_t *changes) { if (changes == NULL) { @@ -1154,7 +1154,7 @@ void xfrin_rollback_update(knot_zone_contents_t *old_contents, /*----------------------------------------------------------------------------*/ -static int xfrin_apply_remove(knot_zone_contents_t *contents, +static int xfrin_apply_remove(zone_contents_t *contents, knot_changeset_t *chset, knot_changes_t *changes) { @@ -1199,11 +1199,11 @@ dbg_xfrin_exec_verb( if (!last_node || knot_rrset_owner(rr) != knot_node_owner(last_node)) { if (is_nsec3) { - last_node = knot_zone_contents_get_nsec3_node( + last_node = zone_contents_get_nsec3_node( contents, knot_rrset_owner(rr)); } else { - last_node = knot_zone_contents_get_node(contents, + last_node = zone_contents_get_node(contents, knot_rrset_owner(rr)); } if (last_node == NULL) { @@ -1236,7 +1236,7 @@ dbg_xfrin_exec_verb( /*----------------------------------------------------------------------------*/ -static int xfrin_apply_add(knot_zone_contents_t *contents, +static int xfrin_apply_add(zone_contents_t *contents, knot_changeset_t *chset, knot_changes_t *changes) { @@ -1274,11 +1274,11 @@ dbg_xfrin_exec_verb( != knot_node_owner(last_node)) { dbg_xfrin_detail("Searching for node...\n"); if (is_nsec3) { - last_node = knot_zone_contents_get_nsec3_node( + last_node = zone_contents_get_nsec3_node( contents, knot_rrset_owner(rr)); } else { - last_node = knot_zone_contents_get_node(contents, + last_node = zone_contents_get_node(contents, knot_rrset_owner(rr)); } if (last_node == NULL) { @@ -1348,12 +1348,12 @@ dbg_xfrin_exec_verb( /*----------------------------------------------------------------------------*/ -static int xfrin_apply_replace_soa(knot_zone_contents_t *contents, +static int xfrin_apply_replace_soa(zone_contents_t *contents, knot_changes_t *changes, knot_changeset_t *chset) { dbg_xfrin("Replacing SOA record.\n"); - knot_node_t *node = knot_zone_contents_get_apex(contents); + knot_node_t *node = zone_contents_get_apex(contents); assert(node != NULL); assert(node != NULL); @@ -1371,7 +1371,7 @@ static int xfrin_apply_replace_soa(knot_zone_contents_t *contents, /*----------------------------------------------------------------------------*/ -static int xfrin_apply_changeset(knot_zone_contents_t *contents, +static int xfrin_apply_changeset(zone_contents_t *contents, knot_changes_t *changes, knot_changeset_t *chset) { @@ -1458,7 +1458,7 @@ static int xfrin_mark_empty(knot_node_t **node_p, void *data) /*----------------------------------------------------------------------------*/ -static int xfrin_remove_empty_nodes(knot_zone_contents_t *z) +static int xfrin_remove_empty_nodes(zone_contents_t *z) { dbg_xfrin("Removing empty nodes from zone.\n"); @@ -1475,7 +1475,7 @@ static int xfrin_remove_empty_nodes(knot_zone_contents_t *z) node_t *nxt = NULL; WALK_LIST_DELSAFE(n, nxt, l) { knot_node_ln_t *list_node = (knot_node_ln_t *)n; - ret = knot_zone_contents_remove_node(z, list_node->node->owner); + ret = zone_contents_remove_node(z, list_node->node->owner); if (ret != KNOT_EOK) { return ret; } @@ -1493,7 +1493,7 @@ static int xfrin_remove_empty_nodes(knot_zone_contents_t *z) WALK_LIST_DELSAFE(n, nxt, l) { knot_node_ln_t *list_node = (knot_node_ln_t *)n; - ret = knot_zone_contents_remove_nsec3_node(z, list_node->node->owner); + ret = zone_contents_remove_nsec3_node(z, list_node->node->owner); if (ret != KNOT_EOK) { return ret; } @@ -1506,7 +1506,7 @@ static int xfrin_remove_empty_nodes(knot_zone_contents_t *z) /*----------------------------------------------------------------------------*/ -static int adjust_nsec3_changes(knot_zone_contents_t *contents, +static int adjust_nsec3_changes(zone_contents_t *contents, hattrie_t *changes) { if (contents->nsec3_nodes == NULL) { @@ -1523,10 +1523,10 @@ static int adjust_nsec3_changes(knot_zone_contents_t *contents, const knot_dname_t *hash = val->hashed_dname; if (hash) { knot_node_t *nsec3_node = - knot_zone_contents_get_nsec3_node(contents, hash); + zone_contents_get_nsec3_node(contents, hash); if (nsec3_node) { knot_node_t *normal_node = - knot_zone_contents_get_node(contents, + zone_contents_get_node(contents, dname); if (normal_node) { normal_node->nsec3_node = nsec3_node; @@ -1542,8 +1542,8 @@ static int adjust_nsec3_changes(knot_zone_contents_t *contents, /*----------------------------------------------------------------------------*/ -int xfrin_prepare_zone_copy(knot_zone_contents_t *old_contents, - knot_zone_contents_t **new_contents) +int xfrin_prepare_zone_copy(zone_contents_t *old_contents, + zone_contents_t **new_contents) { if (old_contents == NULL || new_contents == NULL) { return KNOT_EINVAL; @@ -1554,7 +1554,7 @@ int xfrin_prepare_zone_copy(knot_zone_contents_t *old_contents, /* * Ensure that the zone generation is set to 0. */ - if (!knot_zone_contents_gen_is_old(old_contents)) { + if (!zone_contents_gen_is_old(old_contents)) { // this would mean that a previous update was not completed // abort dbg_zone("Trying to apply changesets to zone that is " @@ -1570,17 +1570,17 @@ int xfrin_prepare_zone_copy(knot_zone_contents_t *old_contents, * NSEC3 tree, hash table, domain name table), and copy all nodes. * The data in the nodes (RRSets) remain the same though. */ - knot_zone_contents_t *contents_copy = NULL; + zone_contents_t *contents_copy = NULL; dbg_xfrin("Copying zone contents.\n"); - int ret = knot_zone_contents_shallow_copy(old_contents, &contents_copy); + int ret = zone_contents_shallow_copy(old_contents, &contents_copy); if (ret != KNOT_EOK) { dbg_xfrin("Failed to create shallow copy of zone: %s\n", knot_strerror(ret)); return ret; } - assert(knot_zone_contents_apex(contents_copy) != NULL); + assert(zone_contents_apex(contents_copy) != NULL); /* * Fix references to new nodes. Some references in new nodes may point @@ -1590,10 +1590,10 @@ int xfrin_prepare_zone_copy(knot_zone_contents_t *old_contents, ret = xfrin_switch_nodes(contents_copy); if (ret != KNOT_EOK) { dbg_xfrin("Failed to switch pointers in nodes.\n"); - knot_zone_contents_free(&contents_copy); + zone_contents_free(&contents_copy); return ret; } - assert(knot_zone_contents_apex(contents_copy) != NULL); + assert(zone_contents_apex(contents_copy) != NULL); *new_contents = contents_copy; @@ -1602,7 +1602,7 @@ int xfrin_prepare_zone_copy(knot_zone_contents_t *old_contents, /*----------------------------------------------------------------------------*/ -int xfrin_finalize_updated_zone(knot_zone_contents_t *contents_copy, +int xfrin_finalize_updated_zone(zone_contents_t *contents_copy, bool set_nsec3_names, const hattrie_t *sorted_changes) { @@ -1633,15 +1633,15 @@ int xfrin_finalize_updated_zone(knot_zone_contents_t *contents_copy, dbg_xfrin("Adjusting zone contents.\n"); if (set_nsec3_names) { if (sorted_changes) { - ret = knot_zone_contents_adjust_pointers(contents_copy); + ret = zone_contents_adjust_pointers(contents_copy); ret = adjust_nsec3_changes(contents_copy, (void *)sorted_changes); } else { - ret = knot_zone_contents_adjust_full(contents_copy, + ret = zone_contents_adjust_full(contents_copy, NULL, NULL); } } else { - ret = knot_zone_contents_adjust_pointers(contents_copy); + ret = zone_contents_adjust_pointers(contents_copy); } if (ret != KNOT_EOK) { dbg_xfrin("Failed to finalize zone contents: %s\n", @@ -1649,14 +1649,14 @@ int xfrin_finalize_updated_zone(knot_zone_contents_t *contents_copy, return ret; } - assert(knot_zone_contents_apex(contents_copy) != NULL); + assert(zone_contents_apex(contents_copy) != NULL); return KNOT_EOK; } /*----------------------------------------------------------------------------*/ -int xfrin_apply_changesets_directly(knot_zone_contents_t *contents, +int xfrin_apply_changesets_directly(zone_contents_t *contents, knot_changes_t *changes, knot_changesets_t *chsets) { @@ -1678,8 +1678,8 @@ int xfrin_apply_changesets_directly(knot_zone_contents_t *contents, /*----------------------------------------------------------------------------*/ /* Post-DDNS application, no need to shallow copy. */ -int xfrin_apply_changesets_dnssec_ddns(knot_zone_contents_t *z_old, - knot_zone_contents_t *z_new, +int xfrin_apply_changesets_dnssec_ddns(zone_contents_t *z_old, + zone_contents_t *z_new, knot_changesets_t *sec_chsets, knot_changesets_t *chsets, const hattrie_t *sorted_changes) @@ -1690,7 +1690,7 @@ int xfrin_apply_changesets_dnssec_ddns(knot_zone_contents_t *z_old, } /* Set generation to old. Zone should be long locked at this point. */ - knot_zone_contents_set_gen_old(z_new); + zone_contents_set_gen_old(z_new); /* Apply changes. */ int ret = xfrin_apply_changesets_directly(z_new, chsets->changes, @@ -1718,14 +1718,14 @@ int xfrin_apply_changesets_dnssec_ddns(knot_zone_contents_t *z_old, int xfrin_apply_changesets(zone_t *zone, knot_changesets_t *chsets, - knot_zone_contents_t **new_contents) + zone_contents_t **new_contents) { if (zone == NULL || chsets == NULL || EMPTY_LIST(chsets->sets) || new_contents == NULL) { return KNOT_EINVAL; } - knot_zone_contents_t *old_contents = zone->contents; + zone_contents_t *old_contents = zone->contents; if (!old_contents) { dbg_xfrin("Cannot apply changesets to empty zone.\n"); return KNOT_EINVAL; @@ -1734,7 +1734,7 @@ int xfrin_apply_changesets(zone_t *zone, dbg_xfrin("Applying changesets to zone...\n"); dbg_xfrin_verb("Creating shallow copy of the zone...\n"); - knot_zone_contents_t *contents_copy = NULL; + zone_contents_t *contents_copy = NULL; int ret = xfrin_prepare_zone_copy(old_contents, &contents_copy); if (ret != KNOT_EOK) { dbg_xfrin("Failed to prepare zone copy: %s\n", @@ -1759,7 +1759,7 @@ int xfrin_apply_changesets(zone_t *zone, return ret; } } - assert(knot_zone_contents_apex(contents_copy) != NULL); + assert(zone_contents_apex(contents_copy) != NULL); /*! * \todo Test failure of IXFR. @@ -1782,7 +1782,7 @@ int xfrin_apply_changesets(zone_t *zone, /*----------------------------------------------------------------------------*/ int xfrin_switch_zone(zone_t *zone, - knot_zone_contents_t *new_contents, + zone_contents_t *new_contents, int transfer_type) { if (zone == NULL || new_contents == NULL) { @@ -1794,7 +1794,7 @@ int xfrin_switch_zone(zone_t *zone, zone->contents, (zone->contents) ? zone->contents->apex : NULL, new_contents->apex); - knot_zone_contents_t *old = + zone_contents_t *old = zone_switch_contents(zone, new_contents); dbg_xfrin_verb("Old contents: %p, apex: %p, new apex: %p\n", @@ -1802,7 +1802,7 @@ int xfrin_switch_zone(zone_t *zone, // set generation to old, so that the flags may be used in next transfer // and we do not search for new nodes anymore - knot_zone_contents_set_gen_old(new_contents); + zone_contents_set_gen_old(new_contents); // wait for readers to finish dbg_xfrin_verb("Waiting for readers to finish...\n"); @@ -1812,7 +1812,7 @@ int xfrin_switch_zone(zone_t *zone, dbg_xfrin_verb("Freeing old zone: %p\n", old); if (transfer_type == XFR_TYPE_AIN) { - knot_zone_contents_deep_free(&old); + zone_contents_deep_free(&old); } else { assert(old != NULL); xfrin_zone_contents_free(&old); diff --git a/src/knot/updates/xfr-in.h b/src/knot/updates/xfr-in.h index df11deefbf..122e6e2ffa 100644 --- a/src/knot/updates/xfr-in.h +++ b/src/knot/updates/xfr-in.h @@ -57,7 +57,7 @@ typedef enum xfrin_transfer_result { * \retval 1 if the transfer is needed. * \retval 0 if the transfer is not needed. */ -int xfrin_transfer_needed(const knot_zone_contents_t *zone, +int xfrin_transfer_needed(const zone_contents_t *zone, knot_pkt_t *soa_response); /*! @@ -114,7 +114,7 @@ int xfrin_create_ixfr_query(const zone_t *zone, knot_pkt_t *pkt); * * \todo Refactor!!! */ -int xfrin_process_axfr_packet(knot_ns_xfr_t *xfr, knot_zone_contents_t **zone); +int xfrin_process_axfr_packet(knot_ns_xfr_t *xfr, zone_contents_t **zone); /*! * \brief Destroys the whole changesets structure. @@ -150,7 +150,7 @@ int xfrin_process_ixfr_packet(knot_ns_xfr_t *xfr); */ int xfrin_apply_changesets(zone_t *zone, knot_changesets_t *chsets, - knot_zone_contents_t **new_contents); + zone_contents_t **new_contents); /*! * \brief Applies DNSSEC changesets after DDNS. @@ -166,8 +166,8 @@ int xfrin_apply_changesets(zone_t *zone, * by the UPDATE-processing function. It uses new and old zones from this * operation. */ -int xfrin_apply_changesets_dnssec_ddns(knot_zone_contents_t *z_old, - knot_zone_contents_t *z_new, +int xfrin_apply_changesets_dnssec_ddns(zone_contents_t *z_old, + zone_contents_t *z_new, knot_changesets_t *sec_chsets, knot_changesets_t *chsets, const hattrie_t *sorted_changes); @@ -185,12 +185,12 @@ int xfrin_apply_changesets_dnssec_ddns(knot_zone_contents_t *z_old, * \retval KNOT_EINVAL if given one of the arguments is NULL. * \return Other error code if the application went wrong. */ -int xfrin_apply_changesets_directly(knot_zone_contents_t *contents, +int xfrin_apply_changesets_directly(zone_contents_t *contents, knot_changes_t *changes, knot_changesets_t *chsets); -int xfrin_prepare_zone_copy(knot_zone_contents_t *old_contents, - knot_zone_contents_t **new_contents); +int xfrin_prepare_zone_copy(zone_contents_t *old_contents, + zone_contents_t **new_contents); /*! * \brief Sets pointers and NSEC3 nodes after signing/DDNS. @@ -200,18 +200,18 @@ int xfrin_prepare_zone_copy(knot_zone_contents_t *old_contents, * node mapping, no hashes are calculated. * \return KNOT_E* */ -int xfrin_finalize_updated_zone(knot_zone_contents_t *contents_copy, +int xfrin_finalize_updated_zone(zone_contents_t *contents_copy, bool set_nsec3_names, const hattrie_t *sorted_changes); int xfrin_switch_zone(zone_t *zone, - knot_zone_contents_t *new_contents, + zone_contents_t *new_contents, int transfer_type); void xfrin_cleanup_successful_update(knot_changes_t *changes); -void xfrin_rollback_update(knot_zone_contents_t *old_contents, - knot_zone_contents_t **new_contents, +void xfrin_rollback_update(zone_contents_t *old_contents, + zone_contents_t **new_contents, knot_changes_t *changes); int xfrin_copy_rrset(knot_node_t *node, uint16_t type, @@ -224,9 +224,9 @@ int xfrin_copy_old_rrset(knot_rrset_t *old, knot_rrset_t **copy, int xfrin_replace_rrset_in_node(knot_node_t *node, knot_rrset_t *rrset_new, knot_changes_t *changes, - knot_zone_contents_t *contents); + zone_contents_t *contents); -void xfrin_zone_contents_free(knot_zone_contents_t **contents); +void xfrin_zone_contents_free(zone_contents_t **contents); #endif /* _KNOTXFR_IN_H_ */ diff --git a/src/knot/zone/zone-contents.c b/src/knot/zone/contents.c similarity index 83% rename from src/knot/zone/zone-contents.c rename to src/knot/zone/contents.c index ff1ed14ee3..788a807314 100644 --- a/src/knot/zone/zone-contents.c +++ b/src/knot/zone/contents.c @@ -17,7 +17,7 @@ #include <config.h> #include <assert.h> -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "common/debug.h" #include "libknot/rrset.h" #include "common/base32hex.h" @@ -35,13 +35,13 @@ /*----------------------------------------------------------------------------*/ typedef struct { - knot_zone_contents_apply_cb_t func; + zone_contents_apply_cb_t func; void *data; } knot_zone_tree_func_t; typedef struct { knot_node_t *first_node; - knot_zone_contents_t *zone; + zone_contents_t *zone; knot_node_t *previous_node; } knot_zone_adjust_arg_t; @@ -79,8 +79,8 @@ static int tree_apply_cb(knot_node_t **node, void *data) * \retval KNOT_EINVAL if either of the arguments is NULL. * \retval KNOT_EOUTOFZONE if the node does not belong to the zone. */ -static int knot_zone_contents_check_node( - const knot_zone_contents_t *contents, const knot_node_t *node) +static int zone_contents_check_node( + const zone_contents_t *contents, const knot_node_t *node) { if (contents == NULL || node == NULL) { return KNOT_EINVAL; @@ -114,7 +114,7 @@ dbg_zone_exec( * \param node Node to destroy RRSets from. * \param data Unused parameter. */ -static int knot_zone_contents_destroy_node_rrsets_from_tree( +static int zone_contents_destroy_node_rrsets_from_tree( knot_node_t **tnode, void *data) { UNUSED(data); @@ -129,7 +129,7 @@ static int knot_zone_contents_destroy_node_rrsets_from_tree( /*----------------------------------------------------------------------------*/ -static int knot_zone_contents_nsec3_name(const knot_zone_contents_t *zone, +static int zone_contents_nsec3_name(const zone_contents_t *zone, const knot_dname_t *name, knot_dname_t **nsec3_name) { @@ -137,7 +137,7 @@ static int knot_zone_contents_nsec3_name(const knot_zone_contents_t *zone, *nsec3_name = NULL; const knot_nsec3_params_t *nsec3_params = - knot_zone_contents_nsec3params(zone); + zone_contents_nsec3params(zone); if (nsec3_params == NULL) { return KNOT_ENSEC3PAR; @@ -153,7 +153,7 @@ static int knot_zone_contents_nsec3_name(const knot_zone_contents_t *zone, } /*! \brief Link pointers to additional nodes for this RRSet. */ -static int discover_additionals(knot_rrset_t *rr, knot_zone_contents_t *zone) +static int discover_additionals(knot_rrset_t *rr, zone_contents_t *zone) { const knot_node_t *node = NULL, *encloser = NULL, *prev = NULL; const knot_dname_t *dname = NULL; @@ -174,7 +174,7 @@ static int discover_additionals(knot_rrset_t *rr, knot_zone_contents_t *zone) /* Try to find node for the dname in the RDATA. */ dname = knot_rdata_name(rr, i); - knot_zone_contents_find_dname(zone, dname, &node, &encloser, &prev); + zone_contents_find_dname(zone, dname, &node, &encloser, &prev); if (node == NULL && encloser && encloser->wildcard_child) { node = encloser->wildcard_child; } @@ -243,7 +243,7 @@ static int adjust_nsec3_pointers(knot_node_t **tnode, void *data) // Connect to NSEC3 node (only if NSEC3 tree is not empty) knot_node_t *nsec3 = NULL; knot_dname_t *nsec3_name = NULL; - int ret = knot_zone_contents_nsec3_name(args->zone, + int ret = zone_contents_nsec3_name(args->zone, knot_node_owner(node), &nsec3_name); if (ret == KNOT_EOK) { @@ -271,7 +271,7 @@ static int adjust_nsec3_pointers(knot_node_t **tnode, void *data) * \param tnode Zone node to adjust. * \param data Adjusting parameters (knot_zone_adjust_arg_t *). */ -static int knot_zone_contents_adjust_normal_node(knot_node_t **tnode, +static int zone_contents_adjust_normal_node(knot_node_t **tnode, void *data) { assert(data != NULL); @@ -298,7 +298,7 @@ static int knot_zone_contents_adjust_normal_node(knot_node_t **tnode, * \param tnode Zone node to adjust. * \param data Adjusting parameters (knot_zone_adjust_arg_t *). */ -static int knot_zone_contents_adjust_nsec3_node(knot_node_t **tnode, +static int zone_contents_adjust_nsec3_node(knot_node_t **tnode, void *data) { assert(data != NULL); @@ -362,7 +362,7 @@ static int adjust_additional(knot_node_t **tnode, void *data) * \retval 0 if the domain name was not found. \a node may hold any (or none) * node. \a previous is set properly. */ -static int knot_zone_contents_find_in_tree(knot_zone_tree_t *tree, +static int zone_contents_find_in_tree(knot_zone_tree_t *tree, const knot_dname_t *name, knot_node_t **node, knot_node_t **previous) @@ -415,19 +415,19 @@ static int knot_zc_nsec3_parameters_match(const knot_rrset_t *rrset, /* API functions */ /*----------------------------------------------------------------------------*/ -knot_zone_contents_t *knot_zone_contents_new(const knot_dname_t *apex_name) +zone_contents_t *zone_contents_new(const knot_dname_t *apex_name) { dbg_zone("%s(%p)\n", __func__, apex_name); if (apex_name == NULL) { return NULL; } - knot_zone_contents_t *contents = malloc(sizeof(knot_zone_contents_t)); + zone_contents_t *contents = malloc(sizeof(zone_contents_t)); if (contents == NULL) { return NULL; } - memset(contents, 0, sizeof(knot_zone_contents_t)); + memset(contents, 0, sizeof(zone_contents_t)); contents->node_count = 1; contents->apex = knot_node_new(apex_name, NULL, 0); if (contents->apex == NULL) { @@ -460,7 +460,7 @@ cleanup: /*----------------------------------------------------------------------------*/ -int knot_zone_contents_gen_is_old(const knot_zone_contents_t *contents) +int zone_contents_gen_is_old(const zone_contents_t *contents) { return ((contents->flags & KNOT_ZONE_FLAGS_GEN_MASK) == KNOT_ZONE_FLAGS_GEN_OLD); @@ -468,7 +468,7 @@ int knot_zone_contents_gen_is_old(const knot_zone_contents_t *contents) /*----------------------------------------------------------------------------*/ -int knot_zone_contents_gen_is_new(const knot_zone_contents_t *contents) +int zone_contents_gen_is_new(const zone_contents_t *contents) { return ((contents->flags & KNOT_ZONE_FLAGS_GEN_MASK) == KNOT_ZONE_FLAGS_GEN_NEW); @@ -476,7 +476,7 @@ int knot_zone_contents_gen_is_new(const knot_zone_contents_t *contents) /*----------------------------------------------------------------------------*/ -void knot_zone_contents_set_gen_old(knot_zone_contents_t *contents) +void zone_contents_set_gen_old(zone_contents_t *contents) { contents->flags &= ~KNOT_ZONE_FLAGS_GEN_MASK; contents->flags |= KNOT_ZONE_FLAGS_GEN_OLD; @@ -484,7 +484,7 @@ void knot_zone_contents_set_gen_old(knot_zone_contents_t *contents) /*----------------------------------------------------------------------------*/ -void knot_zone_contents_set_gen_new(knot_zone_contents_t *contents) +void zone_contents_set_gen_new(zone_contents_t *contents) { contents->flags &= ~KNOT_ZONE_FLAGS_GEN_MASK; contents->flags |= KNOT_ZONE_FLAGS_GEN_NEW; @@ -492,7 +492,7 @@ void knot_zone_contents_set_gen_new(knot_zone_contents_t *contents) /*----------------------------------------------------------------------------*/ -uint16_t knot_zone_contents_class(const knot_zone_contents_t *contents) +uint16_t zone_contents_class(const zone_contents_t *contents) { if (contents == NULL || contents->apex == NULL || knot_node_rrset(contents->apex, KNOT_RRTYPE_SOA) == NULL) { @@ -505,7 +505,7 @@ uint16_t knot_zone_contents_class(const knot_zone_contents_t *contents) /*----------------------------------------------------------------------------*/ -int knot_zone_contents_add_node(knot_zone_contents_t *zone, +int zone_contents_add_node(zone_contents_t *zone, knot_node_t *node, int create_parents, uint8_t flags) { @@ -520,7 +520,7 @@ dbg_zone_exec_detail( ); int ret = 0; - if ((ret = knot_zone_contents_check_node(zone, node)) != 0) { + if ((ret = zone_contents_check_node(zone, node)) != 0) { dbg_zone("Node check failed.\n"); return ret; } @@ -556,7 +556,7 @@ dbg_zone_exec_detail( } } else { while (parent != NULL && - !(next_node = knot_zone_contents_get_node(zone, parent))) { + !(next_node = zone_contents_get_node(zone, parent))) { /* Create a new node. */ dbg_zone_detail("Creating new node.\n"); @@ -567,7 +567,7 @@ dbg_zone_exec_detail( /* Insert node to a tree. */ dbg_zone_detail("Inserting new node to zone tree.\n"); - assert(knot_zone_contents_find_node(zone, parent) == NULL); + assert(zone_contents_find_node(zone, parent) == NULL); ret = knot_zone_tree_insert(zone->nodes, next_node); if (ret != KNOT_EOK) { knot_node_free(&next_node); @@ -600,7 +600,7 @@ dbg_zone_exec_detail( /*----------------------------------------------------------------------------*/ -int knot_zone_contents_create_node(knot_zone_contents_t *contents, +int zone_contents_create_node(zone_contents_t *contents, const knot_rrset_t *rr, knot_node_t **node) { @@ -616,9 +616,9 @@ int knot_zone_contents_create_node(knot_zone_contents_t *contents, /* Add to the proper tree. */ int ret = KNOT_EOK; if (knot_rrset_is_nsec3rel(rr)) { - ret = knot_zone_contents_add_nsec3_node(contents, *node, 1, 0); + ret = zone_contents_add_nsec3_node(contents, *node, 1, 0); } else { - ret = knot_zone_contents_add_node(contents, *node, 1, 0); + ret = zone_contents_add_node(contents, *node, 1, 0); } if (ret != KNOT_EOK) { @@ -632,7 +632,7 @@ int knot_zone_contents_create_node(knot_zone_contents_t *contents, /*----------------------------------------------------------------------------*/ -static int insert_rr(knot_zone_contents_t *z, knot_rrset_t *rr, knot_node_t **n, +static int insert_rr(zone_contents_t *z, knot_rrset_t *rr, knot_node_t **n, knot_rrset_t **rrset, bool nsec3) { if (z == NULL || rr == NULL || n == NULL || rrset == NULL) { @@ -647,16 +647,16 @@ static int insert_rr(knot_zone_contents_t *z, knot_rrset_t *rr, knot_node_t **n, int ret = KNOT_EOK; if (*n == NULL) { - *n = nsec3 ? knot_zone_contents_get_nsec3_node(z, rr->owner) : - knot_zone_contents_get_node(z, rr->owner); + *n = nsec3 ? zone_contents_get_nsec3_node(z, rr->owner) : + zone_contents_get_node(z, rr->owner); if (*n == NULL) { // Create new, insert *n = knot_node_new(rr->owner, NULL, 0); if (*n == NULL) { return KNOT_ENOMEM; } - ret = nsec3 ? knot_zone_contents_add_nsec3_node(z, *n, true, 0) : - knot_zone_contents_add_node(z, *n, true, 0); + ret = nsec3 ? zone_contents_add_nsec3_node(z, *n, true, 0) : + zone_contents_add_node(z, *n, true, 0); if (ret != KNOT_EOK) { knot_node_free(n); } @@ -671,14 +671,14 @@ static bool to_nsec3_tree(const knot_rrset_t *rr) return knot_rrset_is_nsec3rel(rr); } -int knot_zone_contents_add_rr(knot_zone_contents_t *z, +int zone_contents_add_rr(zone_contents_t *z, knot_rrset_t *rr, knot_node_t **n, knot_rrset_t **rrset) { return insert_rr(z, rr, n, rrset, to_nsec3_tree(rr)); } -int knot_zone_contents_add_rrset(knot_zone_contents_t *zone, +int zone_contents_add_rrset(zone_contents_t *zone, knot_rrset_t *rrset, knot_node_t **node, knot_rrset_dupl_handling_t dupl) { @@ -701,7 +701,7 @@ dbg_zone_exec_detail( } if ((*node) == NULL - && (*node = knot_zone_contents_get_node(zone, + && (*node = zone_contents_get_node(zone, rrset->owner)) == NULL) { return KNOT_ENONODE; } @@ -731,7 +731,7 @@ dbg_zone_exec_detail( /*----------------------------------------------------------------------------*/ -int knot_zone_contents_add_nsec3_node(knot_zone_contents_t *zone, +int zone_contents_add_nsec3_node(zone_contents_t *zone, knot_node_t *node, int create_parents, uint8_t flags) { @@ -743,7 +743,7 @@ int knot_zone_contents_add_nsec3_node(knot_zone_contents_t *zone, } int ret = 0; - if ((ret = knot_zone_contents_check_node(zone, node)) != 0) { + if ((ret = zone_contents_check_node(zone, node)) != 0) { dbg_zone("Failed node check: %s\n", knot_strerror(ret)); return ret; } @@ -767,7 +767,7 @@ int knot_zone_contents_add_nsec3_node(knot_zone_contents_t *zone, /*----------------------------------------------------------------------------*/ -int knot_zone_contents_remove_node(knot_zone_contents_t *contents, +int zone_contents_remove_node(zone_contents_t *contents, const knot_dname_t *owner) { if (contents == NULL || owner == NULL) { @@ -791,7 +791,7 @@ dbg_zone_exec_verb( /*----------------------------------------------------------------------------*/ -int knot_zone_contents_remove_nsec3_node(knot_zone_contents_t *contents, +int zone_contents_remove_nsec3_node(zone_contents_t *contents, const knot_dname_t *owner) { if (contents == NULL || owner == NULL) { @@ -812,7 +812,7 @@ int knot_zone_contents_remove_nsec3_node(knot_zone_contents_t *contents, /*----------------------------------------------------------------------------*/ -knot_node_t *knot_zone_contents_get_node(const knot_zone_contents_t *zone, +knot_node_t *zone_contents_get_node(const zone_contents_t *zone, const knot_dname_t *name) { if (zone == NULL || name == NULL) { @@ -831,8 +831,8 @@ knot_node_t *knot_zone_contents_get_node(const knot_zone_contents_t *zone, /*----------------------------------------------------------------------------*/ -knot_node_t *knot_zone_contents_get_nsec3_node( - const knot_zone_contents_t *zone, const knot_dname_t *name) +knot_node_t *zone_contents_get_nsec3_node( + const zone_contents_t *zone, const knot_dname_t *name) { if (zone == NULL || name == NULL) { return NULL; @@ -852,15 +852,15 @@ knot_node_t *knot_zone_contents_get_nsec3_node( /*----------------------------------------------------------------------------*/ -const knot_node_t *knot_zone_contents_find_node( - const knot_zone_contents_t *zone,const knot_dname_t *name) +const knot_node_t *zone_contents_find_node( + const zone_contents_t *zone,const knot_dname_t *name) { - return knot_zone_contents_get_node(zone, name); + return zone_contents_get_node(zone, name); } /*----------------------------------------------------------------------------*/ -int knot_zone_contents_find_dname(const knot_zone_contents_t *zone, +int zone_contents_find_dname(const zone_contents_t *zone, const knot_dname_t *name, const knot_node_t **node, const knot_node_t **closest_encloser, @@ -883,7 +883,7 @@ dbg_zone_exec_verb( knot_node_t *found = NULL, *prev = NULL; - int exact_match = knot_zone_contents_find_in_tree(zone->nodes, name, + int exact_match = zone_contents_find_in_tree(zone->nodes, name, &found, &prev); assert(exact_match >= 0); *node = found; @@ -952,8 +952,8 @@ dbg_zone_exec( /*----------------------------------------------------------------------------*/ -knot_node_t *knot_zone_contents_get_previous( - const knot_zone_contents_t *zone, const knot_dname_t *name) +knot_node_t *zone_contents_get_previous( + const zone_contents_t *zone, const knot_dname_t *name) { if (zone == NULL || name == NULL) { return NULL; @@ -961,7 +961,7 @@ knot_node_t *knot_zone_contents_get_previous( knot_node_t *found = NULL, *prev = NULL; - int exact_match = knot_zone_contents_find_in_tree(zone->nodes, name, + int exact_match = zone_contents_find_in_tree(zone->nodes, name, &found, &prev); assert(exact_match >= 0); assert(prev != NULL); @@ -971,16 +971,16 @@ knot_node_t *knot_zone_contents_get_previous( /*----------------------------------------------------------------------------*/ -const knot_node_t *knot_zone_contents_find_previous( - const knot_zone_contents_t *zone, const knot_dname_t *name) +const knot_node_t *zone_contents_find_previous( + const zone_contents_t *zone, const knot_dname_t *name) { - return knot_zone_contents_get_previous(zone, name); + return zone_contents_get_previous(zone, name); } /*----------------------------------------------------------------------------*/ -knot_node_t *knot_zone_contents_get_previous_nsec3( - const knot_zone_contents_t *zone, const knot_dname_t *name) +knot_node_t *zone_contents_get_previous_nsec3( + const zone_contents_t *zone, const knot_dname_t *name) { if (zone == NULL || name == NULL) { return NULL; @@ -988,7 +988,7 @@ knot_node_t *knot_zone_contents_get_previous_nsec3( knot_node_t *found = NULL, *prev = NULL; - int exact_match = knot_zone_contents_find_in_tree(zone->nsec3_nodes, + int exact_match = zone_contents_find_in_tree(zone->nsec3_nodes, name, &found, &prev); assert(exact_match >= 0); assert(prev != NULL); @@ -998,23 +998,23 @@ knot_node_t *knot_zone_contents_get_previous_nsec3( /*----------------------------------------------------------------------------*/ -const knot_node_t *knot_zone_contents_find_previous_nsec3( - const knot_zone_contents_t *zone, const knot_dname_t *name) +const knot_node_t *zone_contents_find_previous_nsec3( + const zone_contents_t *zone, const knot_dname_t *name) { - return knot_zone_contents_get_previous_nsec3(zone, name); + return zone_contents_get_previous_nsec3(zone, name); } /*----------------------------------------------------------------------------*/ -const knot_node_t *knot_zone_contents_find_nsec3_node( - const knot_zone_contents_t *zone, const knot_dname_t *name) +const knot_node_t *zone_contents_find_nsec3_node( + const zone_contents_t *zone, const knot_dname_t *name) { - return knot_zone_contents_get_nsec3_node(zone, name); + return zone_contents_get_nsec3_node(zone, name); } /*----------------------------------------------------------------------------*/ -int knot_zone_contents_find_nsec3_for_name(const knot_zone_contents_t *zone, +int zone_contents_find_nsec3_for_name(const zone_contents_t *zone, const knot_dname_t *name, const knot_node_t **nsec3_node, const knot_node_t **nsec3_previous) @@ -1025,7 +1025,7 @@ int knot_zone_contents_find_nsec3_for_name(const knot_zone_contents_t *zone, } knot_dname_t *nsec3_name = NULL; - int ret = knot_zone_contents_nsec3_name(zone, name, &nsec3_name); + int ret = zone_contents_nsec3_name(zone, name, &nsec3_name); if (ret != KNOT_EOK) { return ret; @@ -1149,8 +1149,8 @@ dbg_zone_exec_detail( /*----------------------------------------------------------------------------*/ -const knot_node_t *knot_zone_contents_apex( - const knot_zone_contents_t *zone) +const knot_node_t *zone_contents_apex( + const zone_contents_t *zone) { if (zone == NULL) { return NULL; @@ -1161,7 +1161,7 @@ const knot_node_t *knot_zone_contents_apex( /*----------------------------------------------------------------------------*/ -knot_node_t *knot_zone_contents_get_apex(const knot_zone_contents_t *zone) +knot_node_t *zone_contents_get_apex(const zone_contents_t *zone) { if (zone == NULL) { return NULL; @@ -1172,7 +1172,7 @@ knot_node_t *knot_zone_contents_get_apex(const knot_zone_contents_t *zone) /*----------------------------------------------------------------------------*/ -static int knot_zone_contents_adjust_nodes(knot_zone_tree_t *nodes, +static int zone_contents_adjust_nodes(knot_zone_tree_t *nodes, knot_zone_adjust_arg_t *adjust_arg, knot_zone_tree_apply_cb_t callback) { @@ -1194,7 +1194,7 @@ static int knot_zone_contents_adjust_nodes(knot_zone_tree_t *nodes, /*----------------------------------------------------------------------------*/ -static int knot_zone_contents_adjust_nsec3_tree(knot_zone_contents_t *contents) +static int zone_contents_adjust_nsec3_tree(zone_contents_t *contents) { if (contents->nsec3_nodes == NULL) { return KNOT_EOK; @@ -1203,16 +1203,16 @@ static int knot_zone_contents_adjust_nsec3_tree(knot_zone_contents_t *contents) knot_zone_adjust_arg_t adjust_arg = { .first_node = NULL, .previous_node = NULL, .zone = contents }; - return knot_zone_contents_adjust_nodes(contents->nsec3_nodes, + return zone_contents_adjust_nodes(contents->nsec3_nodes, &adjust_arg, - knot_zone_contents_adjust_nsec3_node); + zone_contents_adjust_nsec3_node); } /*----------------------------------------------------------------------------*/ -int knot_zone_contents_adjust_pointers(knot_zone_contents_t *contents) +int zone_contents_adjust_pointers(zone_contents_t *contents) { - int ret = knot_zone_contents_load_nsec3param(contents); + int ret = zone_contents_load_nsec3param(contents); if (ret != KNOT_EOK) { log_zone_error("Failed to load NSEC3 params: %s\n", knot_strerror(ret)); @@ -1222,24 +1222,24 @@ int knot_zone_contents_adjust_pointers(knot_zone_contents_t *contents) knot_zone_adjust_arg_t adjust_arg = { .first_node = NULL, .previous_node = NULL, .zone = contents }; - ret = knot_zone_contents_adjust_nodes(contents->nodes, &adjust_arg, + ret = zone_contents_adjust_nodes(contents->nodes, &adjust_arg, adjust_pointers); if (ret != KNOT_EOK) { return ret; } - ret = knot_zone_contents_adjust_nsec3_tree(contents); + ret = zone_contents_adjust_nsec3_tree(contents); if (ret != KNOT_EOK) { return ret; } - return knot_zone_contents_adjust_nodes(contents->nodes, &adjust_arg, + return zone_contents_adjust_nodes(contents->nodes, &adjust_arg, adjust_additional); } /*----------------------------------------------------------------------------*/ -int knot_zone_contents_adjust_nsec3_pointers(knot_zone_contents_t *contents) +int zone_contents_adjust_nsec3_pointers(zone_contents_t *contents) { if (contents->nsec3_nodes == NULL) { return KNOT_EOK; @@ -1248,13 +1248,13 @@ int knot_zone_contents_adjust_nsec3_pointers(knot_zone_contents_t *contents) knot_zone_adjust_arg_t adjust_arg = { .first_node = NULL, .previous_node = NULL, .zone = contents }; - return knot_zone_contents_adjust_nodes(contents->nodes, &adjust_arg, + return zone_contents_adjust_nodes(contents->nodes, &adjust_arg, adjust_nsec3_pointers); } /*----------------------------------------------------------------------------*/ -int knot_zone_contents_adjust_full(knot_zone_contents_t *zone, +int zone_contents_adjust_full(zone_contents_t *zone, knot_node_t **first_nsec3_node, knot_node_t **last_nsec3_node) { @@ -1262,7 +1262,7 @@ int knot_zone_contents_adjust_full(knot_zone_contents_t *zone, return KNOT_EINVAL; } - int result = knot_zone_contents_load_nsec3param(zone); + int result = zone_contents_load_nsec3param(zone); if (result != KNOT_EOK) { log_zone_error("Failed to load NSEC3 params: %s\n", knot_strerror(result)); @@ -1276,8 +1276,8 @@ int knot_zone_contents_adjust_full(knot_zone_contents_t *zone, // adjust NSEC3 nodes - result = knot_zone_contents_adjust_nodes(zone->nsec3_nodes, &adjust_arg, - knot_zone_contents_adjust_nsec3_node); + result = zone_contents_adjust_nodes(zone->nsec3_nodes, &adjust_arg, + zone_contents_adjust_nsec3_node); if (result != KNOT_EOK) { return result; } @@ -1294,8 +1294,8 @@ int knot_zone_contents_adjust_full(knot_zone_contents_t *zone, // adjust normal nodes - result = knot_zone_contents_adjust_nodes(zone->nodes, &adjust_arg, - knot_zone_contents_adjust_normal_node); + result = zone_contents_adjust_nodes(zone->nodes, &adjust_arg, + zone_contents_adjust_normal_node); if (result != KNOT_EOK) { return result; } @@ -1306,13 +1306,13 @@ int knot_zone_contents_adjust_full(knot_zone_contents_t *zone, * \note This MUST be done after node adjusting because it needs to * do full lookup to see through wildcards. */ - return knot_zone_contents_adjust_nodes(zone->nodes, &adjust_arg, + return zone_contents_adjust_nodes(zone->nodes, &adjust_arg, adjust_additional); } /*----------------------------------------------------------------------------*/ -int knot_zone_contents_load_nsec3param(knot_zone_contents_t *zone) +int zone_contents_load_nsec3param(zone_contents_t *zone) { if (zone == NULL || zone->apex == NULL) { return KNOT_EINVAL; @@ -1337,8 +1337,8 @@ int knot_zone_contents_load_nsec3param(knot_zone_contents_t *zone) /*----------------------------------------------------------------------------*/ -const knot_nsec3_params_t *knot_zone_contents_nsec3params( - const knot_zone_contents_t *zone) +const knot_nsec3_params_t *zone_contents_nsec3params( + const zone_contents_t *zone) { if (zone == NULL) { return NULL; @@ -1353,8 +1353,8 @@ const knot_nsec3_params_t *knot_zone_contents_nsec3params( /*----------------------------------------------------------------------------*/ -int knot_zone_contents_tree_apply_inorder(knot_zone_contents_t *zone, - knot_zone_contents_apply_cb_t function, +int zone_contents_tree_apply_inorder(zone_contents_t *zone, + zone_contents_apply_cb_t function, void *data) { if (zone == NULL) { @@ -1370,8 +1370,8 @@ int knot_zone_contents_tree_apply_inorder(knot_zone_contents_t *zone, /*----------------------------------------------------------------------------*/ -int knot_zone_contents_nsec3_apply_inorder(knot_zone_contents_t *zone, - knot_zone_contents_apply_cb_t function, +int zone_contents_nsec3_apply_inorder(zone_contents_t *zone, + zone_contents_apply_cb_t function, void *data) { if (zone == NULL) { @@ -1388,8 +1388,8 @@ int knot_zone_contents_nsec3_apply_inorder(knot_zone_contents_t *zone, /*----------------------------------------------------------------------------*/ -int knot_zone_contents_shallow_copy(const knot_zone_contents_t *from, - knot_zone_contents_t **to) +int zone_contents_shallow_copy(const zone_contents_t *from, + zone_contents_t **to) { if (from == NULL || to == NULL) { return KNOT_EINVAL; @@ -1402,8 +1402,8 @@ int knot_zone_contents_shallow_copy(const knot_zone_contents_t *from, int ret = KNOT_EOK; - knot_zone_contents_t *contents = (knot_zone_contents_t *)calloc( - 1, sizeof(knot_zone_contents_t)); + zone_contents_t *contents = (zone_contents_t *)calloc( + 1, sizeof(zone_contents_t)); if (contents == NULL) { ERR_ALLOC_FAILED; return KNOT_ENOMEM; @@ -1414,7 +1414,7 @@ int knot_zone_contents_shallow_copy(const knot_zone_contents_t *from, contents->node_count = from->node_count; contents->flags = from->flags; // set the 'new' flag - knot_zone_contents_set_gen_new(contents); + zone_contents_set_gen_new(contents); if ((ret = knot_zone_tree_deep_copy(from->nodes, &contents->nodes)) != KNOT_EOK @@ -1425,7 +1425,7 @@ int knot_zone_contents_shallow_copy(const knot_zone_contents_t *from, contents->apex = knot_node_get_new_node(from->apex); - dbg_zone("knot_zone_contents_shallow_copy: finished OK\n"); + dbg_zone("zone_contents_shallow_copy: finished OK\n"); *to = contents; return KNOT_EOK; @@ -1439,7 +1439,7 @@ cleanup: /*----------------------------------------------------------------------------*/ -void knot_zone_contents_free(knot_zone_contents_t **contents) +void zone_contents_free(zone_contents_t **contents) { if (contents == NULL || *contents == NULL) { return; @@ -1459,7 +1459,7 @@ void knot_zone_contents_free(knot_zone_contents_t **contents) /*----------------------------------------------------------------------------*/ -void knot_zone_contents_deep_free(knot_zone_contents_t **contents) +void zone_contents_deep_free(zone_contents_t **contents) { if (contents == NULL || *contents == NULL) { return; @@ -1469,30 +1469,30 @@ void knot_zone_contents_deep_free(knot_zone_contents_t **contents) // Delete NSEC3 tree knot_zone_tree_apply( (*contents)->nsec3_nodes, - knot_zone_contents_destroy_node_rrsets_from_tree, + zone_contents_destroy_node_rrsets_from_tree, (void*)1); // Delete normal tree knot_zone_tree_apply( (*contents)->nodes, - knot_zone_contents_destroy_node_rrsets_from_tree, + zone_contents_destroy_node_rrsets_from_tree, (void*)1); } - knot_zone_contents_free(contents); + zone_contents_free(contents); } /*----------------------------------------------------------------------------*/ -uint32_t knot_zone_serial(const knot_zone_contents_t *zone) +uint32_t knot_zone_serial(const zone_contents_t *zone) { if (!zone) return 0; const knot_rrset_t *soa = NULL; - soa = knot_node_rrset(knot_zone_contents_apex(zone), KNOT_RRTYPE_SOA); + soa = knot_node_rrset(zone_contents_apex(zone), KNOT_RRTYPE_SOA); return knot_rdata_soa_serial(soa); } -bool knot_zone_contents_is_signed(const knot_zone_contents_t *zone) +bool zone_contents_is_signed(const zone_contents_t *zone) { return knot_node_rrtype_is_signed(zone->apex, KNOT_RRTYPE_SOA); } diff --git a/src/knot/zone/zone-contents.h b/src/knot/zone/contents.h similarity index 76% rename from src/knot/zone/zone-contents.h rename to src/knot/zone/contents.h index 8dabc44c37..06cd04df50 100644 --- a/src/knot/zone/zone-contents.h +++ b/src/knot/zone/contents.h @@ -1,13 +1,3 @@ -/*! - * \file zone-contents.h - * - * \author Lubos Slovak <lubos.slovak@nic.cz> - * - * \brief Zone contents structure and API for manipulating it. - * - * \addtogroup libknot - * @{ - */ /* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> This program is free software: you can redistribute it and/or modify @@ -23,9 +13,18 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/*! + * \file contents.h + * + * \author Lubos Slovak <lubos.slovak@nic.cz> + * + * \brief Zone contents structure and API for manipulating it. + * + * \addtogroup libknot + * @{ + */ -#ifndef _KNOT_ZONE_CONTENTS_H_ -#define _KNOT_ZONE_CONTENTS_H_ +#pragma once #include "knot/zone/node.h" #include "libknot/dnssec/nsec3.h" @@ -41,7 +40,7 @@ enum zone_contents_find_dname_result { /*----------------------------------------------------------------------------*/ -typedef struct knot_zone_contents_t { +typedef struct zone_contents_t { knot_node_t *apex; /*!< Apex node of the zone (holding SOA) */ knot_zone_tree_t *nodes; @@ -69,7 +68,7 @@ typedef struct knot_zone_contents_t { * - 0xx - ANY queries enabled */ uint8_t flags; -} knot_zone_contents_t; +} zone_contents_t; /*!< \brief Helper linked list list for CNAME loop checking */ typedef struct cname_chain { @@ -80,19 +79,19 @@ typedef struct cname_chain { /*! * \brief Signature of callback for zone contents apply functions. */ -typedef int (*knot_zone_contents_apply_cb_t)(knot_node_t *node, void *data); +typedef int (*zone_contents_apply_cb_t)(knot_node_t *node, void *data); /*----------------------------------------------------------------------------*/ -knot_zone_contents_t *knot_zone_contents_new(const knot_dname_t *apex_name); +zone_contents_t *zone_contents_new(const knot_dname_t *apex_name); -int knot_zone_contents_gen_is_old(const knot_zone_contents_t *contents); -int knot_zone_contents_gen_is_new(const knot_zone_contents_t *contents); +int zone_contents_gen_is_old(const zone_contents_t *contents); +int zone_contents_gen_is_new(const zone_contents_t *contents); -void knot_zone_contents_set_gen_old(knot_zone_contents_t *contents); -void knot_zone_contents_set_gen_new(knot_zone_contents_t *contents); +void zone_contents_set_gen_old(zone_contents_t *contents); +void zone_contents_set_gen_new(zone_contents_t *contents); -uint16_t knot_zone_contents_class(const knot_zone_contents_t *contents); +uint16_t zone_contents_class(const zone_contents_t *contents); /*! * \brief Adds a node to the given zone. @@ -112,7 +111,7 @@ uint16_t knot_zone_contents_class(const knot_zone_contents_t *contents); * \retval KNOT_EOUTOFZONE * \retval KNOT_EHASH */ -int knot_zone_contents_add_node(knot_zone_contents_t *contents, +int zone_contents_add_node(zone_contents_t *contents, knot_node_t *node, int create_parents, uint8_t flags); @@ -124,11 +123,11 @@ int knot_zone_contents_add_node(knot_zone_contents_t *contents, * \param node Returns created node. * \return */ -int knot_zone_contents_create_node(knot_zone_contents_t *contents, +int zone_contents_create_node(zone_contents_t *contents, const knot_rrset_t *rr, knot_node_t **node); -int knot_zone_contents_add_rr(knot_zone_contents_t *z, +int zone_contents_add_rr(zone_contents_t *z, knot_rrset_t *rr, knot_node_t **n, knot_rrset_t **rrset); @@ -154,7 +153,7 @@ int knot_zone_contents_add_rr(knot_zone_contents_t *z, * \retval KNOT_EINVAL * \retval KNOT_EOUTOFZONE */ -int knot_zone_contents_add_rrset(knot_zone_contents_t *contents, +int zone_contents_add_rrset(zone_contents_t *contents, knot_rrset_t *rrset, knot_node_t **node, knot_rrset_dupl_handling_t dupl); @@ -173,14 +172,14 @@ int knot_zone_contents_add_rrset(knot_zone_contents_t *contents, * \retval KNOT_EINVAL * \retval KNOT_EOUTOFZONE */ -int knot_zone_contents_add_nsec3_node(knot_zone_contents_t *contents, +int zone_contents_add_nsec3_node(zone_contents_t *contents, knot_node_t *node, int create_parents, uint8_t flags); -int knot_zone_contents_remove_node(knot_zone_contents_t *contents, +int zone_contents_remove_node(zone_contents_t *contents, const knot_dname_t *owner); -int knot_zone_contents_remove_nsec3_node(knot_zone_contents_t *contents, +int zone_contents_remove_nsec3_node(zone_contents_t *contents, const knot_dname_t *owner); /*! @@ -191,8 +190,8 @@ int knot_zone_contents_remove_nsec3_node(knot_zone_contents_t *contents, * * \return Corresponding node if found, NULL otherwise. */ -knot_node_t *knot_zone_contents_get_node( - const knot_zone_contents_t *contents, const knot_dname_t *name); +knot_node_t *zone_contents_get_node( + const zone_contents_t *contents, const knot_dname_t *name); /*! * \brief Tries to find a node with the specified name among the NSEC3 nodes @@ -203,13 +202,13 @@ knot_node_t *knot_zone_contents_get_node( * * \return Corresponding node if found, NULL otherwise. */ -knot_node_t *knot_zone_contents_get_nsec3_node( - const knot_zone_contents_t *contents, const knot_dname_t *name); +knot_node_t *zone_contents_get_nsec3_node( + const zone_contents_t *contents, const knot_dname_t *name); /*! * \brief Tries to find a node with the specified name in the zone. * - * \note This function is identical to knot_zone_contents_get_node(), only it returns + * \note This function is identical to zone_contents_get_node(), only it returns * constant reference. * * \param zone Zone where the name should be searched for. @@ -217,8 +216,8 @@ knot_node_t *knot_zone_contents_get_nsec3_node( * * \return Corresponding node if found, NULL otherwise. */ -const knot_node_t *knot_zone_contents_find_node( - const knot_zone_contents_t *contents, const knot_dname_t *name); +const knot_node_t *zone_contents_find_node( + const zone_contents_t *contents, const knot_dname_t *name); /*! * \brief Tries to find domain name in the given zone using AVL tree. @@ -235,7 +234,7 @@ const knot_node_t *knot_zone_contents_find_node( * \retval KNOT_EINVAL * \retval KNOT_EOUTOFZONE */ -int knot_zone_contents_find_dname(const knot_zone_contents_t *contents, +int zone_contents_find_dname(const zone_contents_t *contents, const knot_dname_t *name, const knot_node_t **node, const knot_node_t **closest_encloser, @@ -249,23 +248,23 @@ int knot_zone_contents_find_dname(const knot_zone_contents_t *contents, * * \return Previous node in canonical order, or NULL if some parameter is wrong. */ -const knot_node_t *knot_zone_contents_find_previous( - const knot_zone_contents_t *contents, const knot_dname_t *name); +const knot_node_t *zone_contents_find_previous( + const zone_contents_t *contents, const knot_dname_t *name); -knot_node_t *knot_zone_contents_get_previous( - const knot_zone_contents_t *contents, const knot_dname_t *name); +knot_node_t *zone_contents_get_previous( + const zone_contents_t *contents, const knot_dname_t *name); -const knot_node_t *knot_zone_contents_find_previous_nsec3( - const knot_zone_contents_t *contents, const knot_dname_t *name); +const knot_node_t *zone_contents_find_previous_nsec3( + const zone_contents_t *contents, const knot_dname_t *name); -knot_node_t *knot_zone_contents_get_previous_nsec3( - const knot_zone_contents_t *contents, const knot_dname_t *name); +knot_node_t *zone_contents_get_previous_nsec3( + const zone_contents_t *contents, const knot_dname_t *name); /*! * \brief Tries to find a node with the specified name among the NSEC3 nodes * of the zone. * - * \note This function is identical to knot_zone_contents_get_nsec3_node(), only it + * \note This function is identical to zone_contents_get_nsec3_node(), only it * returns constant reference. * * \param zone Zone where the name should be searched for. @@ -273,8 +272,8 @@ knot_node_t *knot_zone_contents_get_previous_nsec3( * * \return Corresponding node if found, NULL otherwise. */ -const knot_node_t *knot_zone_contents_find_nsec3_node( - const knot_zone_contents_t *contents, const knot_dname_t *name); +const knot_node_t *zone_contents_find_nsec3_node( + const zone_contents_t *contents, const knot_dname_t *name); /*! * \brief Finds NSEC3 node and previous NSEC3 node in canonical order, @@ -297,8 +296,8 @@ const knot_node_t *knot_zone_contents_find_nsec3_node( * \retval KNOT_ECRYPTO * \retval KNOT_ERROR */ -int knot_zone_contents_find_nsec3_for_name( - const knot_zone_contents_t *contents, +int zone_contents_find_nsec3_for_name( + const zone_contents_t *contents, const knot_dname_t *name, const knot_node_t **nsec3_node, const knot_node_t **nsec3_previous); @@ -309,22 +308,22 @@ int knot_zone_contents_find_nsec3_for_name( * * \return Zone apex node. */ -const knot_node_t *knot_zone_contents_apex( - const knot_zone_contents_t *contents); +const knot_node_t *zone_contents_apex( + const zone_contents_t *contents); -knot_node_t *knot_zone_contents_get_apex( - const knot_zone_contents_t *contents); +knot_node_t *zone_contents_get_apex( + const zone_contents_t *contents); /*! * \brief Sets parent and previous pointers and node flags. (cheap operation) * For both normal and NSEC3 tree */ -int knot_zone_contents_adjust_pointers(knot_zone_contents_t *contents); +int zone_contents_adjust_pointers(zone_contents_t *contents); /*! * \brief Sets NSEC3 nodes for normal nodes. (costly operation, calculates hash) */ -int knot_zone_contents_adjust_nsec3_pointers(knot_zone_contents_t *); +int zone_contents_adjust_nsec3_pointers(zone_contents_t *); /*! * \brief Sets parent and previous pointers, sets node flags and NSEC3 links. @@ -336,7 +335,7 @@ int knot_zone_contents_adjust_nsec3_pointers(knot_zone_contents_t *); * Will not be saved if set to NULL. * \param zone Zone to adjust domain names in. */ -int knot_zone_contents_adjust_full(knot_zone_contents_t *contents, +int zone_contents_adjust_full(zone_contents_t *contents, knot_node_t **first_nsec3_node, knot_node_t **last_nsec3_node); @@ -353,23 +352,23 @@ int knot_zone_contents_adjust_full(knot_zone_contents_t *contents, * * \param zone Zone to get the NSEC3PARAM record from. */ -int knot_zone_contents_load_nsec3param(knot_zone_contents_t *contents); +int zone_contents_load_nsec3param(zone_contents_t *contents); /*! * \brief Returns the parsed NSEC3PARAM record of the zone. * * \note You must parse the NSEC3PARAM record prior to calling this function - * (knot_zone_contents_load_nsec3param()). + * (zone_contents_load_nsec3param()). * * \param zone Zone to get the NSEC3PARAM record from. * * \return Parsed NSEC3PARAM from the zone or NULL if the zone does not use * NSEC3 or the record was not parsed before. * - * \see knot_zone_contents_load_nsec3param() + * \see zone_contents_load_nsec3param() */ -const knot_nsec3_params_t *knot_zone_contents_nsec3params( - const knot_zone_contents_t *contents); +const knot_nsec3_params_t *zone_contents_nsec3params( + const zone_contents_t *contents); /*! * \brief Applies the given function to each regular node in the zone. @@ -385,8 +384,8 @@ const knot_nsec3_params_t *knot_zone_contents_nsec3params( * \param function Function to be applied to each node of the zone. * \param data Arbitrary data to be passed to the function. */ -int knot_zone_contents_tree_apply_inorder(knot_zone_contents_t *zone, - knot_zone_contents_apply_cb_t function, +int zone_contents_tree_apply_inorder(zone_contents_t *zone, + zone_contents_apply_cb_t function, void *data); /*! @@ -404,8 +403,8 @@ int knot_zone_contents_tree_apply_inorder(knot_zone_contents_t *zone, * \param function Function to be applied to each node of the zone. * \param data Arbitrary data to be passed to the function. */ -int knot_zone_contents_nsec3_apply_inorder(knot_zone_contents_t *zone, - knot_zone_contents_apply_cb_t function, +int zone_contents_nsec3_apply_inorder(zone_contents_t *zone, + zone_contents_apply_cb_t function, void *data); /*! @@ -424,12 +423,12 @@ int knot_zone_contents_nsec3_apply_inorder(knot_zone_contents_t *zone, * \retval KNOT_EINVAL * \retval KNOT_ENOMEM */ -int knot_zone_contents_shallow_copy(const knot_zone_contents_t *from, - knot_zone_contents_t **to); +int zone_contents_shallow_copy(const zone_contents_t *from, + zone_contents_t **to); -void knot_zone_contents_free(knot_zone_contents_t **contents); +void zone_contents_free(zone_contents_t **contents); -void knot_zone_contents_deep_free(knot_zone_contents_t **contents); +void zone_contents_deep_free(zone_contents_t **contents); /*! * \brief Fetch zone serial. @@ -438,13 +437,11 @@ void knot_zone_contents_deep_free(knot_zone_contents_t **contents); * * \return serial or 0 */ -uint32_t knot_zone_serial(const knot_zone_contents_t *zone); +uint32_t knot_zone_serial(const zone_contents_t *zone); /*! * \brief Return true if zone is signed. */ -bool knot_zone_contents_is_signed(const knot_zone_contents_t *zone); - -#endif +bool zone_contents_is_signed(const zone_contents_t *zone); /*! @} */ diff --git a/src/knot/zone/semantic-check.c b/src/knot/zone/semantic-check.c index a72ca9b5a7..aaae7b9535 100644 --- a/src/knot/zone/semantic-check.c +++ b/src/knot/zone/semantic-check.c @@ -648,7 +648,7 @@ static int rdata_nsec_to_type_array(const knot_rrset_t *rrset, size_t pos, * * \return Appropriate error code if error was found. */ -static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, +static int check_nsec3_node_in_zone(zone_contents_t *zone, knot_node_t *node, err_handler_t *handler) { assert(handler); @@ -668,7 +668,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, const knot_node_t *nsec3_previous; const knot_node_t *nsec3_node; - if (knot_zone_contents_find_nsec3_for_name(zone, + if (zone_contents_find_nsec3_for_name(zone, knot_node_owner(node), &nsec3_node, &nsec3_previous) != 0) { @@ -715,7 +715,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, } const knot_rrset_t *soa_rrset = - knot_node_rrset(knot_zone_contents_apex(zone), + knot_node_rrset(zone_contents_apex(zone), KNOT_RRTYPE_SOA); assert(soa_rrset); uint32_t minimum_ttl = knot_rdata_soa_minimum(soa_rrset); @@ -726,7 +726,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, } /* Result is a dname, it can't be larger */ - const knot_node_t *apex = knot_zone_contents_apex(zone); + const knot_node_t *apex = zone_contents_apex(zone); uint8_t *next_dname_str = NULL; uint8_t next_dname_size = 0; knot_rdata_nsec3_next_hashed(nsec3_rrset, 0, &next_dname_str, @@ -738,7 +738,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, return KNOT_ERROR; } - if (knot_zone_contents_find_nsec3_node(zone, next_dname) == NULL) { + if (zone_contents_find_nsec3_node(zone, next_dname) == NULL) { err_handler_handle_error(handler, node, ZC_ERR_NSEC3_RDATA_CHAIN, NULL); } @@ -843,11 +843,11 @@ static int sem_check_node_mandatory(const knot_node_t *node, return KNOT_EOK; } -static int sem_check_node_optional(const knot_zone_contents_t *zone, +static int sem_check_node_optional(const zone_contents_t *zone, const knot_node_t *node, err_handler_t *handler) { - if (knot_node_is_deleg_point(node) || knot_zone_contents_apex(zone) == + if (knot_node_is_deleg_point(node) || zone_contents_apex(zone) == node) { const knot_rrset_t *ns_rrset = knot_node_rrset(node, KNOT_RRTYPE_NS); @@ -867,10 +867,10 @@ static int sem_check_node_optional(const knot_zone_contents_t *zone, } const knot_node_t *glue_node = - knot_zone_contents_find_node(zone, ns_dname); + zone_contents_find_node(zone, ns_dname); if (knot_dname_is_sub(ns_dname, - knot_node_owner(knot_zone_contents_apex(zone)))) { + knot_node_owner(zone_contents_apex(zone)))) { if (glue_node == NULL) { /* Try wildcard ([1]* + suffix). */ knot_dname_t wildcard[KNOT_DNAME_MAXLEN]; @@ -879,7 +879,7 @@ static int sem_check_node_optional(const knot_zone_contents_t *zone, knot_wire_next_label(ns_dname, NULL), sizeof(wildcard)); const knot_node_t *wildcard_node = - knot_zone_contents_find_node(zone, + zone_contents_find_node(zone, wildcard); if (wildcard_node == NULL) { err_handler_handle_error(handler, node, @@ -925,7 +925,7 @@ static int sem_check_node_optional(const knot_zone_contents_t *zone, * * \return Appropriate error code if error was found. */ -int sem_check_node_plain(const knot_zone_contents_t *zone, +int sem_check_node_plain(const zone_contents_t *zone, const knot_node_t *node, err_handler_t *handler, bool only_mandatory, @@ -971,7 +971,7 @@ int sem_check_rrset(const knot_node_t *node, * * \return Appropriate error code if error was found. */ -static int semantic_checks_dnssec(knot_zone_contents_t *zone, +static int semantic_checks_dnssec(zone_contents_t *zone, knot_node_t *node, knot_node_t **last_node, err_handler_t *handler, @@ -984,7 +984,7 @@ static int semantic_checks_dnssec(knot_zone_contents_t *zone, uint rrset_count = knot_node_rrset_count(node); const knot_rrset_t **rrsets = knot_node_rrsets_no_copy(node); const knot_rrset_t *dnskey_rrset = - knot_node_rrset(knot_zone_contents_apex(zone), + knot_node_rrset(zone_contents_apex(zone), KNOT_RRTYPE_DNSKEY); int ret = 0; @@ -1070,13 +1070,13 @@ static int semantic_checks_dnssec(knot_zone_contents_t *zone, } knot_dname_to_lower(lowercase); - if (knot_zone_contents_find_node(zone, lowercase) == NULL) { + if (zone_contents_find_node(zone, lowercase) == NULL) { err_handler_handle_error(handler, node, ZC_ERR_NSEC_RDATA_CHAIN, NULL); } if (knot_dname_cmp(lowercase, - knot_node_owner(knot_zone_contents_apex(zone))) + knot_node_owner(zone_contents_apex(zone))) == 0) { /* saving the last node */ *last_node = node; @@ -1113,7 +1113,7 @@ static int do_checks_in_tree(knot_node_t *node, void *data) arg_t *args = (arg_t *)data; - knot_zone_contents_t *zone = (knot_zone_contents_t *)args->arg1; + zone_contents_t *zone = (zone_contents_t *)args->arg1; knot_node_t **last_node = (knot_node_t **)args->arg5; @@ -1141,7 +1141,7 @@ static int do_checks_in_tree(knot_node_t *node, void *data) return KNOT_EOK; } -int zone_do_sem_checks(knot_zone_contents_t *zone, int do_checks, +int zone_do_sem_checks(zone_contents_t *zone, int do_checks, err_handler_t *handler, knot_node_t *first_nsec3_node, knot_node_t *last_nsec3_node) { @@ -1158,7 +1158,7 @@ int zone_do_sem_checks(knot_zone_contents_t *zone, int do_checks, int fatal_error = 0; arguments.arg7 = (void *)&fatal_error; - int ret = knot_zone_contents_tree_apply_inorder(zone, + int ret = zone_contents_tree_apply_inorder(zone, do_checks_in_tree, &arguments); if (ret != KNOT_EOK) { @@ -1175,7 +1175,7 @@ int zone_do_sem_checks(knot_zone_contents_t *zone, int do_checks, } void log_cyclic_errors_in_zone(err_handler_t *handler, - knot_zone_contents_t *zone, + zone_contents_t *zone, knot_node_t *last_node, const knot_node_t *first_nsec3_node, const knot_node_t *last_nsec3_node, @@ -1196,7 +1196,7 @@ void log_cyclic_errors_in_zone(err_handler_t *handler, } /* Result is a dname, it can't be larger */ - const knot_node_t *apex = knot_zone_contents_apex(zone); + const knot_node_t *apex = zone_contents_apex(zone); uint8_t *next_dname_str = NULL; uint8_t next_dname_size = 0; knot_rdata_nsec3_next_hashed(nsec3_rrset, 0, &next_dname_str, @@ -1210,8 +1210,8 @@ void log_cyclic_errors_in_zone(err_handler_t *handler, } /* Check it points somewhere first. */ - if (knot_zone_contents_find_nsec3_node(zone, next_dname) == NULL) { - assert(knot_zone_contents_find_node(zone, + if (zone_contents_find_nsec3_node(zone, next_dname) == NULL) { + assert(zone_contents_find_node(zone, next_dname) == NULL); err_handler_handle_error(handler, last_nsec3_node, @@ -1248,7 +1248,7 @@ void log_cyclic_errors_in_zone(err_handler_t *handler, assert(next_dname); const knot_dname_t *apex_dname = - knot_node_owner(knot_zone_contents_apex(zone)); + knot_node_owner(zone_contents_apex(zone)); assert(apex_dname); if (knot_dname_cmp(next_dname, apex_dname) !=0) { diff --git a/src/knot/zone/semantic-check.h b/src/knot/zone/semantic-check.h index 649db7600a..1627a14170 100644 --- a/src/knot/zone/semantic-check.h +++ b/src/knot/zone/semantic-check.h @@ -28,7 +28,7 @@ #define _KNOT_SEMANTIC_CHECK_H_ #include "knot/zone/node.h" -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" enum check_levels { SEM_CHECK_UNSIGNED = 1, @@ -181,7 +181,7 @@ int err_handler_handle_error(err_handler_t *handler, * \param do_checks Level of semantic checks. */ void log_cyclic_errors_in_zone(err_handler_t *handler, - knot_zone_contents_t *zone, + zone_contents_t *zone, knot_node_t *last_node, const knot_node_t *first_nsec3_node, const knot_node_t *last_nsec3_node, @@ -203,7 +203,7 @@ void err_handler_log_all(err_handler_t *handler); * \param handler Semantic error handler. * \param last_node Last checked node, that is a part of NSEC(3) chain. */ -int zone_do_sem_checks(knot_zone_contents_t *zone, int check_level, +int zone_do_sem_checks(zone_contents_t *zone, int check_level, err_handler_t *handler, knot_node_t *first_nsec3_node, knot_node_t *last_nsec3_node); @@ -218,7 +218,7 @@ int zone_do_sem_checks(knot_zone_contents_t *zone, int check_level, * * \return KNOT_E* */ -int sem_check_node_plain(const knot_zone_contents_t *zone, +int sem_check_node_plain(const zone_contents_t *zone, const knot_node_t *node, err_handler_t *handler, bool only_mandatory, diff --git a/src/knot/zone/zone-diff.c b/src/knot/zone/zone-diff.c index fafe13f361..917aa7fb2c 100644 --- a/src/knot/zone/zone-diff.c +++ b/src/knot/zone/zone-diff.c @@ -36,16 +36,16 @@ static int knot_zone_diff_rdata(const knot_rrset_t *rrset1, const knot_rrset_t *rrset2, knot_changeset_t *changeset); -static int knot_zone_diff_load_soas(const knot_zone_contents_t *zone1, - const knot_zone_contents_t *zone2, +static int knot_zone_diff_load_soas(const zone_contents_t *zone1, + const zone_contents_t *zone2, knot_changeset_t *changeset) { if (zone1 == NULL || zone2 == NULL || changeset == NULL) { return KNOT_EINVAL; } - const knot_node_t *apex1 = knot_zone_contents_apex(zone1); - const knot_node_t *apex2 = knot_zone_contents_apex(zone2); + const knot_node_t *apex1 = zone_contents_apex(zone1); + const knot_node_t *apex2 = zone_contents_apex(zone2); if (apex1 == NULL || apex2 == NULL) { dbg_zonediff("zone_diff: " "both zones must have apex nodes.\n"); @@ -661,8 +661,8 @@ static int knot_zone_diff_load_trees(knot_zone_tree_t *nodes1, } -static int knot_zone_diff_load_content(const knot_zone_contents_t *zone1, - const knot_zone_contents_t *zone2, +static int knot_zone_diff_load_content(const zone_contents_t *zone1, + const zone_contents_t *zone2, knot_changeset_t *changeset) { int result; @@ -678,8 +678,8 @@ static int knot_zone_diff_load_content(const knot_zone_contents_t *zone1, } -static int knot_zone_contents_diff(const knot_zone_contents_t *zone1, - const knot_zone_contents_t *zone2, +static int zone_contents_diff(const zone_contents_t *zone1, + const zone_contents_t *zone2, knot_changeset_t *changeset) { if (zone1 == NULL || zone2 == NULL) { @@ -694,15 +694,15 @@ static int knot_zone_contents_diff(const knot_zone_contents_t *zone1, return knot_zone_diff_load_content(zone1, zone2, changeset); } -int knot_zone_contents_create_diff(const knot_zone_contents_t *z1, - const knot_zone_contents_t *z2, +int zone_contents_create_diff(const zone_contents_t *z1, + const zone_contents_t *z2, knot_changeset_t *changeset) { if (z1 == NULL || z2 == NULL) { dbg_zonediff("zone_diff: create_changesets: NULL arguments.\n"); return KNOT_EINVAL; } - int ret = knot_zone_contents_diff(z1, z2, changeset); + int ret = zone_contents_diff(z1, z2, changeset); if (ret != KNOT_EOK) { dbg_zonediff("zone_diff: create_changesets: " "Could not diff zones. " diff --git a/src/knot/zone/zone-diff.h b/src/knot/zone/zone-diff.h index fb46b0856b..051efccf1f 100644 --- a/src/knot/zone/zone-diff.h +++ b/src/knot/zone/zone-diff.h @@ -19,14 +19,14 @@ #include <stdint.h> -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "knot/updates/changesets.h" /*! * \brief Create diff between two zone trees. * */ -int knot_zone_contents_create_diff(const knot_zone_contents_t *z1, - const knot_zone_contents_t *z2, +int zone_contents_create_diff(const zone_contents_t *z1, + const zone_contents_t *z2, knot_changeset_t *changeset); /*! diff --git a/src/knot/zone/zone-dump.c b/src/knot/zone/zone-dump.c index 2624482612..dd4c7942e5 100644 --- a/src/knot/zone/zone-dump.c +++ b/src/knot/zone/zone-dump.c @@ -134,7 +134,7 @@ static int node_dump_text(knot_node_t *node, void *data) return KNOT_EOK; } -int zone_dump_text(knot_zone_contents_t *zone, const struct sockaddr_storage *from, FILE *file) +int zone_dump_text(zone_contents_t *zone, const struct sockaddr_storage *from, FILE *file) { if (zone == NULL || file == NULL) { return KNOT_EINVAL; @@ -164,19 +164,19 @@ int zone_dump_text(knot_zone_contents_t *zone, const struct sockaddr_storage *fr // Dump standard zone records without rrsigs. params.dump_rrsig = false; params.dump_nsec = false; - ret = knot_zone_contents_tree_apply_inorder(zone, node_dump_text, ¶ms); + ret = zone_contents_tree_apply_inorder(zone, node_dump_text, ¶ms); if (ret != KNOT_EOK) { return ret; } // Dump DNSSEC signatures if secured. - if (knot_zone_contents_is_signed(zone)) { + if (zone_contents_is_signed(zone)) { fprintf(file, ";; DNSSEC signatures\n"); // Dump rrsig records. params.dump_rrsig = true; params.dump_nsec = false; - ret = knot_zone_contents_tree_apply_inorder(zone, node_dump_text, + ret = zone_contents_tree_apply_inorder(zone, node_dump_text, ¶ms); if (ret != KNOT_EOK) { return ret; @@ -189,7 +189,7 @@ int zone_dump_text(knot_zone_contents_t *zone, const struct sockaddr_storage *fr params.dump_rrsig = false; params.dump_nsec = true; - ret = knot_zone_contents_nsec3_apply_inorder(zone, node_dump_text, + ret = zone_contents_nsec3_apply_inorder(zone, node_dump_text, ¶ms); if (ret != KNOT_EOK) { return ret; @@ -199,18 +199,18 @@ int zone_dump_text(knot_zone_contents_t *zone, const struct sockaddr_storage *fr params.dump_rrsig = true; params.dump_nsec = false; - ret = knot_zone_contents_nsec3_apply_inorder(zone, node_dump_text, + ret = zone_contents_nsec3_apply_inorder(zone, node_dump_text, ¶ms); if (ret != KNOT_EOK) { return ret; } - } else if (knot_zone_contents_is_signed(zone)) { + } else if (zone_contents_is_signed(zone)) { fprintf(file, ";; DNSSEC NSEC chain\n"); // Dump nsec records. params.dump_rrsig = false; params.dump_nsec = true; - ret = knot_zone_contents_tree_apply_inorder(zone, node_dump_text, + ret = zone_contents_tree_apply_inorder(zone, node_dump_text, ¶ms); if (ret != KNOT_EOK) { return ret; diff --git a/src/knot/zone/zone-dump.h b/src/knot/zone/zone-dump.h index c7fd3b327e..2e1292b204 100644 --- a/src/knot/zone/zone-dump.h +++ b/src/knot/zone/zone-dump.h @@ -39,7 +39,7 @@ * \retval KNOT_EOK on success. * \retval < 0 if error. */ -int zone_dump_text(knot_zone_contents_t *zone, const struct sockaddr_storage *from, FILE *file); +int zone_dump_text(zone_contents_t *zone, const struct sockaddr_storage *from, FILE *file); #endif // _KNOTD_ZONEDUMP_H_ diff --git a/src/knot/zone/zone.c b/src/knot/zone/zone.c index fd53897583..1648f48ff9 100644 --- a/src/knot/zone/zone.c +++ b/src/knot/zone/zone.c @@ -25,7 +25,7 @@ #include "knot/server/zones.h" #include "knot/zone/node.h" #include "knot/zone/zone.h" -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "libknot/common.h" #include "libknot/dname.h" #include "libknot/dnssec/random.h" @@ -109,7 +109,7 @@ zone_t* zone_new(conf_zone_t *conf) set_acl(&zone->notify_in, &conf->acl.notify_in); set_acl(&zone->update_in, &conf->acl.update_in); - /* Initialize IXFR database. */ + // Initialize XFR database zone->ixfr_db = journal_open(conf->ixfr_db, conf->ixfr_fslimit, JOURNAL_DIRTY); if (zone->ixfr_db == NULL) { char ebuf[256] = {0}; @@ -150,20 +150,20 @@ void zone_free(zone_t **zone_ptr) conf_free_zone(zone->conf); /* Free zone contents. */ - knot_zone_contents_deep_free(&zone->contents); + zone_contents_deep_free(&zone->contents); free(zone); *zone_ptr = NULL; } -knot_zone_contents_t *zone_switch_contents(zone_t *zone, - knot_zone_contents_t *new_contents) +zone_contents_t *zone_switch_contents(zone_t *zone, + zone_contents_t *new_contents) { if (zone == NULL) { return NULL; } - knot_zone_contents_t *old_contents; + zone_contents_t *old_contents; old_contents = rcu_xchg_pointer(&zone->contents, new_contents); return old_contents; diff --git a/src/knot/zone/zone.h b/src/knot/zone/zone.h index c1cf40c221..d4671f9b18 100644 --- a/src/knot/zone/zone.h +++ b/src/knot/zone/zone.h @@ -34,7 +34,7 @@ #include "knot/server/journal.h" #include "knot/updates/acl.h" #include "knot/zone/events.h" -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "libknot/dname.h" /*! @@ -56,7 +56,7 @@ typedef struct zone_t { ref_t ref; /*!< Reference counting. */ knot_dname_t *name; - knot_zone_contents_t *contents; + zone_contents_t *contents; zone_flag_t flags; @@ -130,8 +130,8 @@ static inline void zone_release(zone_t *zone) /*! * \brief Atomically switch the content of the zone. */ -knot_zone_contents_t *zone_switch_contents(zone_t *zone, - knot_zone_contents_t *new_contents); +zone_contents_t *zone_switch_contents(zone_t *zone, + zone_contents_t *new_contents); /*! * \brief Return zone master interface. diff --git a/src/knot/zone/zonedb.h b/src/knot/zone/zonedb.h index 7791c7efa1..29f161e4ef 100644 --- a/src/knot/zone/zonedb.h +++ b/src/knot/zone/zonedb.h @@ -32,7 +32,7 @@ #include "knot/zone/node.h" #include "knot/zone/zone.h" -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "libknot/dname.h" #include "common/hhash.h" diff --git a/src/knot/zone/zone-create.c b/src/knot/zone/zonefile.c similarity index 90% rename from src/knot/zone/zone-create.c rename to src/knot/zone/zonefile.c index 5f16eeb6d4..87dd008adf 100644 --- a/src/knot/zone/zone-create.c +++ b/src/knot/zone/zonefile.c @@ -30,10 +30,10 @@ #include "common/crc.h" #include "libknot/common.h" #include "knot/zone/semantic-check.h" -#include "knot/zone/zone-contents.h" +#include "knot/zone/contents.h" #include "knot/dnssec/zone-nsec.h" #include "knot/other/debug.h" -#include "knot/zone/zone-create.h" +#include "knot/zone/zonefile.h" #include "zscanner/file_loader.h" #include "libknot/rdata.h" @@ -99,7 +99,7 @@ int zcreator_step(zcreator_t *zc, knot_rrset_t *rr) n = NULL; } knot_rrset_t *zone_rrset = NULL; - int ret = knot_zone_contents_add_rr(zc->z, rr, &n, &zone_rrset); + int ret = zone_contents_add_rr(zc->z, rr, &n, &zone_rrset); if (ret < 0) { if (!handle_err(zc, rr, ret)) { // Fatal error @@ -177,7 +177,7 @@ static void loader_process(const scanner_t *scanner) } } -static knot_zone_contents_t *create_zone_from_name(const char *origin) +static zone_contents_t *create_zone_from_name(const char *origin) { if (origin == NULL) { return NULL; @@ -187,19 +187,20 @@ static knot_zone_contents_t *create_zone_from_name(const char *origin) return NULL; } knot_dname_to_lower(owner); - knot_zone_contents_t *z = knot_zone_contents_new(owner); + zone_contents_t *z = zone_contents_new(owner); knot_dname_free(&owner); return z; } -int zonefile_open(zloader_t *loader, const conf_zone_t *conf) +int zonefile_open(zloader_t *loader, const char *source, const char *origin, + bool semantic_checks) { if (!loader || !conf) { return KNOT_EINVAL; } /* Check zone file. */ - if (access(conf->file, F_OK | R_OK) != 0) { + if (access(source, F_OK | R_OK) != 0) { return KNOT_EACCES; } @@ -211,7 +212,7 @@ int zonefile_open(zloader_t *loader, const conf_zone_t *conf) } memset(zc, 0, sizeof(zcreator_t)); - zc->z = create_zone_from_name(conf->name); + zc->z = create_zone_from_name(origin); if (zc->z == NULL) { free(zc); return KNOT_ENOMEM; @@ -219,7 +220,7 @@ int zonefile_open(zloader_t *loader, const conf_zone_t *conf) /* Create file loader. */ memset(loader, 0, sizeof(zloader_t)); - loader->file_loader = file_loader_create(conf->file, conf->name, + loader->file_loader = file_loader_create(source, origin, KNOT_CLASS_IN, 3600, loader_process, process_error, zc); @@ -228,15 +229,15 @@ int zonefile_open(zloader_t *loader, const conf_zone_t *conf) return KNOT_ERROR; } - loader->source = strdup(conf->file); - loader->origin = strdup(conf->name); + loader->source = strdup(source); + loader->origin = strdup(origin); loader->creator = zc; - loader->semantic_checks = conf->enable_checks; + loader->semantic_checks = semantic_checks; return KNOT_EOK; } -knot_zone_contents_t *zonefile_load(zloader_t *loader) +zone_contents_t *zonefile_load(zloader_t *loader) { dbg_zload("zload: load: Loading zone, loader: %p.\n", loader); if (!loader) { @@ -276,7 +277,7 @@ knot_zone_contents_t *zonefile_load(zloader_t *loader) knot_node_t *first_nsec3_node = NULL; knot_node_t *last_nsec3_node = NULL; - int kret = knot_zone_contents_adjust_full(zc->z, + int kret = zone_contents_adjust_full(zc->z, &first_nsec3_node, &last_nsec3_node); if (kret != KNOT_EOK) { log_zone_error("%s: Failed to finalize zone contents: %s\n", @@ -293,10 +294,10 @@ knot_zone_contents_t *zonefile_load(zloader_t *loader) const knot_rrset_t *nsec3param_rr = knot_node_rrset(zc->z->apex, KNOT_RRTYPE_NSEC3PARAM); - if (knot_zone_contents_is_signed(zc->z) && nsec3param_rr == NULL) { + if (zone_contents_is_signed(zc->z) && nsec3param_rr == NULL) { /* Set check level to DNSSEC. */ check_level = SEM_CHECK_NSEC; - } else if (knot_zone_contents_is_signed(zc->z) && nsec3param_rr) { + } else if (zone_contents_is_signed(zc->z) && nsec3param_rr) { check_level = SEM_CHECK_NSEC3; } err_handler_t err_handler; @@ -312,7 +313,7 @@ knot_zone_contents_t *zonefile_load(zloader_t *loader) return zc->z; fail: - knot_zone_contents_deep_free(&zc->z); + zone_contents_deep_free(&zc->z); return NULL; } diff --git a/src/knot/zone/zone-create.h b/src/knot/zone/zonefile.h similarity index 87% rename from src/knot/zone/zone-create.h rename to src/knot/zone/zonefile.h index e181a07293..7c0e199797 100644 --- a/src/knot/zone/zone-create.h +++ b/src/knot/zone/zonefile.h @@ -27,6 +27,7 @@ #ifndef _KNOT_ZONELOAD_H_ #define _KNOT_ZONELOAD_H_ +#include <stdbool.h> #include <stdio.h> #include "knot/zone/zone.h" @@ -36,7 +37,7 @@ * \brief Zone creator structure. */ typedef struct zcreator { - knot_zone_contents_t *z; /*!< Created zone. */ + zone_contents_t *z; /*!< Created zone. */ knot_node_t *last_node; /*!< Last used node, use to save zone lookup. */ int ret; /*!< Return value. */ } zcreator_t; @@ -57,12 +58,15 @@ typedef struct zloader_t { * \brief Open zone file for loading. * * \param zl Output zone loader. - * \param conf Zone configuration. + * \param source Source file name. + * \param origin Zone origin. + * \param semantic_checks Perform semantic checks. * * \retval Initialized loader on success. * \retval NULL on error. */ -int zonefile_open(zloader_t *loader, const conf_zone_t *conf); +int zonefile_open(zloader_t *loader, const char *source, const char *origin, + bool semantic_checks); /*! * \brief Loads zone from a zone file. @@ -72,7 +76,7 @@ int zonefile_open(zloader_t *loader, const conf_zone_t *conf); * \retval Loaded zone contents on success. * \retval NULL otherwise. */ -knot_zone_contents_t *zonefile_load(zloader_t *loader); +zone_contents_t *zonefile_load(zloader_t *loader); /*! * \brief Close zone file loader. diff --git a/tests/process_query.c b/tests/process_query.c index 437119dc77..51f9e467ee 100644 --- a/tests/process_query.c +++ b/tests/process_query.c @@ -46,7 +46,7 @@ void create_root_zone(server_t *server, mm_ctx_t *mm) conf->name = strdup("."); zone_t *root = zone_new(conf); - root->contents = knot_zone_contents_new(root->name); + root->contents = zone_contents_new(root->name); knot_dname_t *root_name = knot_dname_copy(root->name); knot_rrset_t *soa_rrset = knot_rrset_new(root_name, @@ -57,7 +57,7 @@ void create_root_zone(server_t *server, mm_ctx_t *mm) /* Bake the zone. */ knot_node_t *first_nsec3 = NULL, *last_nsec3 = NULL; - knot_zone_contents_adjust_full(root->contents, &first_nsec3, &last_nsec3); + zone_contents_adjust_full(root->contents, &first_nsec3, &last_nsec3); /* Switch zone db. */ knot_zonedb_free(&server->zone_db); -- GitLab