Commit 9f79a236 authored by Jan Včelák's avatar Jan Včelák 🚀

Merge branch 'bye-bye-getters' into 'master'

parents 3336f97f c694f8c7
......@@ -123,7 +123,7 @@ static int cmd_remote_print_reply(const knot_rrset_t *rr)
return KNOT_EMALF;
}
uint16_t rr_count = knot_rrset_rr_count(rr);
uint16_t rr_count = rr->rrs.rr_count;
for (uint16_t i = 0; i < rr_count; i++) {
/* Parse TXT. */
remote_print_txt(rr, i);
......
......@@ -99,7 +99,7 @@ static int remote_rdata_apply(server_t *s, remote_cmdargs_t* a, remote_zonef_t *
continue;
}
uint16_t rr_count = knot_rrset_rr_count(rr);
uint16_t rr_count = rr->rrs.rr_count;
for (uint16_t i = 0; i < rr_count; i++) {
const knot_dname_t *dn = knot_ns_name(&rr->rrs, i);
rcu_read_lock();
......@@ -537,7 +537,7 @@ static void log_command(const char *cmd, const remote_cmdargs_t* args)
continue;
}
uint16_t rr_count = knot_rrset_rr_count(rr);
uint16_t rr_count = rr->rrs.rr_count;
for (uint16_t j = 0; j < rr_count; j++) {
const knot_dname_t *dn = knot_ns_name(&rr->rrs, j);
char *name = knot_dname_to_str(dn);
......@@ -842,7 +842,7 @@ int remote_create_ns(knot_rrset_t *rr, const char *d)
int remote_print_txt(const knot_rrset_t *rr, uint16_t i)
{
if (!rr || knot_rrset_rr_count(rr) < 1) {
if (!rr || rr->rrs.rr_count < 1) {
return -1;
}
......
......@@ -93,7 +93,7 @@ static int connect_nsec_nodes(knot_node_t *a, knot_node_t *b,
assert(b);
assert(data);
if (b->rrset_count == 0 || knot_node_is_non_auth(b)) {
if (b->rrset_count == 0 || b->flags & KNOT_NODE_FLAGS_NONAUTH) {
return NSEC_NODE_SKIP;
}
......@@ -132,7 +132,7 @@ static int connect_nsec_nodes(knot_node_t *a, knot_node_t *b,
dbg_dnssec_detail("NSECs not equal, replacing.\n");
// Mark the node so that we do not sign this NSEC
knot_node_set_removed_nsec(a);
a->flags |= KNOT_NODE_FLAGS_REMOVED_NSEC;
ret = knot_nsec_changeset_remove(a, data->changeset);
if (ret != KNOT_EOK) {
knot_rrset_free(&new_nsec, NULL);
......
......@@ -175,8 +175,8 @@ static void free_nsec3_tree(knot_zone_tree_t *nodes)
for (/* NOP */; !hattrie_iter_finished(it); hattrie_iter_next(it)) {
knot_node_t *node = (knot_node_t *)*hattrie_iter_val(it);
// newly allocated NSEC3 nodes
knot_rdataset_t *nsec3 = knot_node_get_rdataset(node, KNOT_RRTYPE_NSEC3);
knot_rdataset_t *rrsig = knot_node_get_rdataset(node, KNOT_RRTYPE_RRSIG);
knot_rdataset_t *nsec3 = knot_node_rdataset(node, KNOT_RRTYPE_NSEC3);
knot_rdataset_t *rrsig = knot_node_rdataset(node, KNOT_RRTYPE_RRSIG);
knot_rdataset_clear(nsec3, NULL);
knot_rdataset_clear(rrsig, NULL);
knot_node_free(&node);
......@@ -283,11 +283,12 @@ static knot_node_t *create_nsec3_node(knot_dname_t *owner,
assert(apex_node);
assert(rr_types);
uint8_t flags = 0;
knot_node_t *new_node = knot_node_new(owner, apex_node, flags);
knot_node_t *new_node = knot_node_new(owner);
if (!new_node) {
return NULL;
}
knot_node_set_parent(new_node, apex_node);
knot_rrset_t nsec3_rrset;
int ret = create_nsec3_rrset(&nsec3_rrset, owner, nsec3_params,
......@@ -367,7 +368,7 @@ static int connect_nsec3_nodes(knot_node_t *a, knot_node_t *b,
assert(a->rrset_count == 1);
knot_rdataset_t *a_rrs = knot_node_get_rdataset(a, KNOT_RRTYPE_NSEC3);
knot_rdataset_t *a_rrs = knot_node_rdataset(a, KNOT_RRTYPE_NSEC3);
assert(a_rrs);
uint8_t algorithm = knot_nsec3_algorithm(a_rrs, 0);
if (algorithm == 0) {
......@@ -440,9 +441,9 @@ static int create_nsec3_nodes(const knot_zone_contents_t *zone, uint32_t ttl,
break;
}
if (knot_node_rrtype_exists(node, KNOT_RRTYPE_NSEC)) {
knot_node_set_removed_nsec(node);
node->flags |= KNOT_NODE_FLAGS_REMOVED_NSEC;
}
if (knot_node_is_non_auth(node) || knot_node_is_empty(node)) {
if (node->flags & KNOT_NODE_FLAGS_NONAUTH || node->flags & KNOT_NODE_FLAGS_EMPTY) {
hattrie_iter_next(it);
continue;
}
......@@ -480,7 +481,7 @@ static int create_nsec3_nodes(const knot_zone_contents_t *zone, uint32_t ttl,
*/
static bool nsec3_is_empty(knot_node_t *node)
{
if (knot_node_children(node) > 0) {
if (node->children > 0) {
return false;
}
......@@ -499,12 +500,12 @@ static int nsec3_mark_empty(knot_node_t **node_p, void *data)
UNUSED(data);
knot_node_t *node = *node_p;
if (!knot_node_is_empty(node) && nsec3_is_empty(node)) {
if (!(node->flags & KNOT_NODE_FLAGS_EMPTY) && nsec3_is_empty(node)) {
/*!
* Mark this node and all parent nodes that meet the same
* criteria as empty.
*/
knot_node_set_empty(node);
node->flags |= KNOT_NODE_FLAGS_EMPTY;
if (node->parent) {
/* We must decrease the parent's children count,
......@@ -548,13 +549,13 @@ static int nsec3_reset(knot_node_t **node_p, void *data)
UNUSED(data);
knot_node_t *node = *node_p;
if (knot_node_is_empty(node)) {
if (node->flags & KNOT_NODE_FLAGS_EMPTY) {
/* If node was marked as empty, increase its parent's children
* count.
*/
node->parent->children++;
/* Clear the 'empty' flag. */
knot_node_clear_empty(node);
node->flags &= ~KNOT_NODE_FLAGS_EMPTY;
}
return KNOT_EOK;
......
......@@ -136,7 +136,7 @@ static int mark_nsec3(knot_rrset_t *rrset, void *data)
}
if (node != NULL) {
knot_node_set_removed_nsec(node);
node->flags |= KNOT_NODE_FLAGS_REMOVED_NSEC;
}
}
......
......@@ -78,7 +78,7 @@ static bool valid_signature_exists(const knot_rrset_t *covered,
return false;
}
uint16_t rrsigs_rdata_count = knot_rrset_rr_count(rrsigs);
uint16_t rrsigs_rdata_count = rrsigs->rrs.rr_count;
for (uint16_t i = 0; i < rrsigs_rdata_count; i++) {
uint16_t keytag = knot_rrsig_key_tag(&rrsigs->rrs, i);
uint16_t type_covered = knot_rrsig_type_covered(&rrsigs->rrs, i);
......@@ -238,7 +238,7 @@ static int remove_expired_rrsigs(const knot_rrset_t *covered,
return KNOT_EOK;
}
uint16_t rrsig_rdata_count = knot_rrset_rr_count(&synth_rrsig);
uint16_t rrsig_rdata_count = synth_rrsig.rrs.rr_count;
for (uint16_t i = 0; i < rrsig_rdata_count; i++) {
const knot_zone_key_t *key;
key = get_matching_zone_key(&synth_rrsig, i, zone_keys);
......@@ -459,7 +459,7 @@ static int remove_standalone_rrsigs(const knot_node_t *node,
return KNOT_EOK;
}
uint16_t rrsigs_rdata_count = knot_rrset_rr_count(rrsigs);
uint16_t rrsigs_rdata_count = rrsigs->rrs.rr_count;
for (uint16_t i = 0; i < rrsigs_rdata_count; ++i) {
uint16_t type_covered = knot_rrsig_type_covered(&rrsigs->rrs, i);
if (!knot_node_rrtype_exists(node, type_covered)) {
......@@ -569,13 +569,13 @@ static int sign_node(knot_node_t **node, void *data)
return KNOT_EOK;
}
if (knot_node_is_non_auth(*node)) {
if ((*node)->flags & KNOT_NODE_FLAGS_NONAUTH) {
return KNOT_EOK;
}
int result = sign_node_rrsets(*node, args->zone_keys, args->policy,
args->changeset, &args->expires_at);
knot_node_clear_removed_nsec(*node);
(*node)->flags &= ~KNOT_NODE_FLAGS_REMOVED_NSEC;
return result;
}
......@@ -696,7 +696,7 @@ static bool dnskey_exists_in_zone(const knot_rrset_t *dnskeys,
assert(!knot_rrset_empty(dnskeys));
assert(key);
uint16_t dnskeys_rdata_count = knot_rrset_rr_count(dnskeys);
uint16_t dnskeys_rdata_count = dnskeys->rrs.rr_count;
for (uint16_t i = 0; i < dnskeys_rdata_count; i++) {
uint8_t *rdata = knot_rrset_rr_rdata(dnskeys, i);
uint16_t rdata_size = knot_rrset_rr_size(dnskeys, i);
......@@ -757,7 +757,7 @@ static int remove_invalid_dnskeys(const knot_rrset_t *soa,
goto done;
}
uint16_t dnskeys_rdata_count = knot_rrset_rr_count(dnskeys);
uint16_t dnskeys_rdata_count = dnskeys->rrs.rr_count;
for (uint16_t i = 0; i < dnskeys_rdata_count; i++) {
uint8_t *rdata = knot_rrset_rr_rdata(dnskeys, i);
uint16_t rdata_size = knot_rrset_rr_size(dnskeys, i);
......@@ -921,7 +921,7 @@ static int update_dnskeys_rrsigs(const knot_rrset_t *dnskeys,
}
// add unknown keys from zone
uint16_t dnskeys_rdata_count = knot_rrset_rr_count(dnskeys);
uint16_t dnskeys_rdata_count = dnskeys->rrs.rr_count;
for (uint16_t i = 0; i < dnskeys_rdata_count; i++) {
uint8_t *rdata = knot_rrset_rr_rdata(dnskeys, i);
uint16_t rdata_size = knot_rrset_rr_size(dnskeys, i);
......@@ -1478,7 +1478,7 @@ int knot_zone_sign_rr_should_be_signed(const knot_node_t *node,
}
// SOA and DNSKEYs are handled separately in the zone apex
if (knot_node_is_apex(node)) {
if (node->flags & KNOT_NODE_FLAGS_APEX) {
if (rrset->type == KNOT_RRTYPE_SOA) {
return KNOT_EOK;
}
......@@ -1489,7 +1489,7 @@ int knot_zone_sign_rr_should_be_signed(const knot_node_t *node,
}
// At delegation points we only want to sign NSECs and DSs
if (knot_node_is_deleg_point(node)) {
if ((node->flags & KNOT_NODE_FLAGS_DELEG)) {
if (!(rrset->type == KNOT_RRTYPE_NSEC ||
rrset->type == KNOT_RRTYPE_DS)) {
return KNOT_EOK;
......@@ -1497,7 +1497,7 @@ int knot_zone_sign_rr_should_be_signed(const knot_node_t *node,
}
// These RRs have their signatures stored in changeset already
if (knot_node_is_removed_nsec(node)
if (node->flags & KNOT_NODE_FLAGS_REMOVED_NSEC
&& ((rrset->type == KNOT_RRTYPE_NSEC)
|| (rrset->type == KNOT_RRTYPE_NSEC3))) {
return KNOT_EOK;
......
......@@ -33,7 +33,7 @@ static int put_rrsets(knot_pkt_t *pkt, knot_node_t *node, struct axfr_proc *stat
{
int ret = KNOT_EOK;
int i = state->cur_rrset;
int rrset_count = knot_node_rrset_count(node);
uint16_t rrset_count = node->rrset_count;
unsigned flags = KNOT_PF_NOTRUNC;
/* Append all RRs. */
......
......@@ -192,7 +192,7 @@ static int put_answer(knot_pkt_t *pkt, uint16_t type, struct query_data *qdata)
knot_wire_set_tc(pkt->wire);
return KNOT_ESPACE;
}
for (unsigned i = 0; i < knot_node_rrset_count(qdata->node); ++i) {
for (unsigned i = 0; i < qdata->node->rrset_count; ++i) {
rrset = knot_node_rrset_at(qdata->node, i);
ret = ns_put_rr(pkt, &rrset, NULL, compr_hint, 0, qdata);
if (ret != KNOT_EOK) {
......@@ -285,8 +285,8 @@ static int put_authority_soa(knot_pkt_t *pkt, struct query_data *qdata,
static int put_delegation(knot_pkt_t *pkt, struct query_data *qdata)
{
/* Find closest delegation point. */
while (!knot_node_is_deleg_point(qdata->node)) {
qdata->node = knot_node_parent(qdata->node);
while (!(qdata->node->flags & KNOT_NODE_FLAGS_DELEG)) {
qdata->node = qdata->node->parent;
}
/* Insert NS record. */
......@@ -310,7 +310,7 @@ static int put_additional(knot_pkt_t *pkt, const knot_rrset_t *rr,
const knot_node_t *node = NULL;
/* All RRs should have additional node cached or NULL. */
uint16_t rr_rdata_count = knot_rrset_rr_count(rr);
uint16_t rr_rdata_count = rr->rrs.rr_count;
for (uint16_t i = 0; i < rr_rdata_count; i++) {
hint = knot_pkt_compr_hint(info, COMPR_HINT_RDATA + i);
node = rr->additional[i];
......@@ -438,7 +438,7 @@ static int name_found(knot_pkt_t *pkt, struct query_data *qdata)
/* DS query is answered normally, but everything else at/below DP
* triggers referral response. */
if (qtype != KNOT_RRTYPE_DS &&
(knot_node_is_deleg_point(qdata->node) || knot_node_is_non_auth(qdata->node))) {
((qdata->node->flags & KNOT_NODE_FLAGS_DELEG) || qdata->node->flags & KNOT_NODE_FLAGS_NONAUTH)) {
dbg_ns("%s: solving REFERRAL\n", __func__);
return DELEG;
}
......@@ -468,7 +468,7 @@ static int name_not_found(knot_pkt_t *pkt, struct query_data *qdata)
dbg_ns("%s(%p, %p)\n", __func__, pkt, qdata);
/* Name is covered by wildcard. */
if (knot_node_has_wildcard_child(qdata->encloser)) {
if (qdata->encloser->flags & KNOT_NODE_FLAGS_WILDCARD_CHILD) {
dbg_ns("%s: name %p covered by wildcard\n", __func__, qdata->name);
/* Find wildcard child in the zone. */
......@@ -502,7 +502,7 @@ static int name_not_found(knot_pkt_t *pkt, struct query_data *qdata)
}
/* Name is below delegation. */
if (knot_node_is_deleg_point(qdata->encloser)) {
if ((qdata->encloser->flags & KNOT_NODE_FLAGS_DELEG)) {
dbg_ns("%s: name below delegation point %p\n", __func__, qdata->name);
qdata->node = qdata->encloser;
return DELEG;
......@@ -693,7 +693,7 @@ int ns_put_rr(knot_pkt_t *pkt, const knot_rrset_t *rr,
const knot_rrset_t *rrsigs, uint16_t compr_hint,
uint32_t flags, struct query_data *qdata)
{
if (knot_rrset_rr_count(rr) < 1) {
if (rr->rrs.rr_count < 1) {
dbg_ns("%s: refusing to put empty RR of type %u\n", __func__, rr->type);
return KNOT_EMALF;
}
......
......@@ -53,7 +53,7 @@ static int ixfr_put_rrlist(knot_pkt_t *pkt, struct ixfr_proc *ixfr, list_t *list
* rejoin the iteration at any point. */
while(ixfr->cur->next) {
knot_rr_ln_t *rr_item = (knot_rr_ln_t *)(ixfr->cur);
if (knot_rrset_rr_count(rr_item->rr) > 0) {
if (rr_item->rr->rrs.rr_count > 0) {
IXFR_SAFE_PUT(pkt, rr_item->rr);
} else {
dbg_ns("%s: empty RR %p, skipping\n", __func__, rr_item->rr);
......
......@@ -155,8 +155,7 @@ static int ns_put_nsec3_closest_encloser_proof(
if (knot_zone_contents_nsec3params(zone) == NULL) {
dbg_ns_exec_verb(
char *name = knot_dname_to_str(knot_node_owner(
knot_zone_contents_apex(zone)));
char *name = knot_dname_to_str(zone->apex->owner);
dbg_ns_verb("No NSEC3PARAM found in zone %s.\n", name);
free(name);
);
......@@ -164,7 +163,7 @@ dbg_ns_exec_verb(
}
dbg_ns_exec_detail(
char *name = knot_dname_to_str(knot_node_owner(*closest_encloser));
char *name = knot_dname_to_str((*closest_encloser)->owner);
dbg_ns_detail("Closest encloser: %s\n", name);
free(name);
);
......@@ -174,10 +173,10 @@ dbg_ns_exec_detail(
*/
const knot_node_t *nsec3_node = NULL;
const knot_dname_t *next_closer = NULL;
while ((nsec3_node = knot_node_nsec3_node((*closest_encloser)))
while ((nsec3_node = (*closest_encloser)->nsec3_node)
== NULL) {
next_closer = knot_node_owner((*closest_encloser));
*closest_encloser = knot_node_parent(*closest_encloser);
next_closer = (*closest_encloser)->owner;
*closest_encloser = (*closest_encloser)->parent;
if (*closest_encloser == NULL) {
// there are no NSEC3s to add
return KNOT_EOK;
......@@ -212,8 +211,8 @@ dbg_ns_exec_verb(
*/
if (next_closer == NULL) {
// create the "next closer" name by appending from qname
knot_dname_t *new_next_closer = ns_next_closer(
knot_node_owner(*closest_encloser), qname);
knot_dname_t *new_next_closer = ns_next_closer((*closest_encloser)->owner,
qname);
if (new_next_closer == NULL) {
return KNOT_ERROR; /*servfail */
......@@ -286,14 +285,6 @@ static int ns_put_nsec_wildcard(const knot_zone_contents_t *zone,
if (previous == NULL) {
previous = knot_zone_contents_find_previous(zone, qname);
assert(previous != NULL);
/*!
* \todo isn't this handled in adjusting?
* knot_zone_contents_adjust_node_in_tree_ptr()
*/
while (!knot_node_is_auth(previous)) {
previous = knot_node_previous(previous);
}
}
knot_rrset_t rrset = knot_node_rrset(previous, KNOT_RRTYPE_NSEC);
......@@ -432,8 +423,8 @@ static int ns_put_nsec_nsec3_wildcard_answer(const knot_node_t *node,
// if wildcard answer, add NSEC / NSEC3
int ret = KNOT_EOK;
if (knot_dname_is_wildcard(knot_node_owner(node))
&& !knot_dname_is_equal(qname, knot_node_owner(node))) {
if (knot_dname_is_wildcard(node->owner)
&& !knot_dname_is_equal(qname, node->owner)) {
dbg_ns_verb("Adding NSEC/NSEC3 for wildcard answer.\n");
if (knot_is_nsec3_enabled(zone)) {
ret = ns_put_nsec3_wildcard(zone, closest_encloser,
......@@ -480,14 +471,6 @@ static int ns_put_nsec_nxdomain(const knot_dname_t *qname,
/*! \todo Check version. */
previous = knot_zone_contents_find_previous(zone, qname);
assert(previous != NULL);
/*!
* \todo isn't this handled in adjusting?
* knot_zone_contents_adjust_node_in_tree_ptr()
*/
while (!knot_node_is_auth(previous)) {
previous = knot_node_previous(previous);
}
}
dbg_ns_exec_verb(
......@@ -526,21 +509,19 @@ dbg_ns_exec_verb(
const knot_node_t *prev_new = previous;
while (knot_dname_cmp(knot_node_owner(prev_new),
wildcard) > 0) {
while (knot_dname_cmp(prev_new->owner, wildcard) > 0) {
dbg_ns_exec_verb(
char *name = knot_dname_to_str(knot_node_owner(prev_new));
char *name = knot_dname_to_str(prev_new->owner);
dbg_ns_verb("Previous node: %s\n", name);
free(name);
);
assert(prev_new != knot_zone_contents_apex(zone));
prev_new = knot_node_previous(prev_new);
assert(prev_new != zone->apex);
prev_new = prev_new->prev;
}
assert(knot_dname_cmp(knot_node_owner(prev_new),
wildcard) < 0);
assert(knot_dname_cmp(prev_new->owner, wildcard) < 0);
dbg_ns_exec_verb(
char *name = knot_dname_to_str(knot_node_owner(prev_new));
char *name = knot_dname_to_str(prev_new->owner);
dbg_ns_verb("Previous node: %s\n", name);
free(name);
);
......@@ -665,7 +646,7 @@ static int ns_put_nsec_nsec3_nodata(const knot_node_t *node,
knot_pkt_t *resp)
{
// This case must be handled first, before handling the wildcard case
if (knot_node_rrset_count(node) == 0 && !knot_is_nsec3_enabled(zone)) {
if (node->rrset_count == 0 && !knot_is_nsec3_enabled(zone)) {
// node is an empty non-terminal => NSEC for NXDOMAIN
return ns_put_nsec_nxdomain(qname, zone, previous,
closest_encloser, qdata, resp);
......@@ -687,7 +668,7 @@ static int ns_put_nsec_nsec3_nodata(const knot_node_t *node,
/* RFC5155 7.2.3-7.2.5 common proof. */
dbg_ns("%s: adding NSEC3 NODATA\n", __func__);
const knot_node_t *nsec3_node = knot_node_nsec3_node(node);
const knot_node_t *nsec3_node = node->nsec3_node;
if (nsec3_node) {
ret = ns_put_nsec3_from_node(nsec3_node, qdata, resp);
} else {
......@@ -722,7 +703,7 @@ int nsec_prove_wildcards(knot_pkt_t *pkt, struct query_data *qdata)
WALK_LIST(item, qdata->wildcards) {
ret = ns_put_nsec_nsec3_wildcard_answer(
item->node,
knot_node_parent(item->node),
item->node->parent,
NULL, qdata->zone->contents,
item->sname, qdata,
pkt);
......
......@@ -32,7 +32,7 @@ static size_t rr_binary_size(const knot_rrset_t *rrset, size_t rdata_pos)
static uint64_t rrset_binary_size(const knot_rrset_t *rrset)
{
if (rrset == NULL || knot_rrset_rr_count(rrset) == 0) {
if (rrset == NULL || rrset->rrs.rr_count == 0) {
return 0;
}
uint64_t size = sizeof(uint64_t) + // size at the beginning
......@@ -40,7 +40,7 @@ static uint64_t rrset_binary_size(const knot_rrset_t *rrset)
sizeof(uint16_t) + // type
sizeof(uint16_t) + // class
sizeof(uint16_t); //RR count
uint16_t rdata_count = knot_rrset_rr_count(rrset);
uint16_t rdata_count = rrset->rrs.rr_count;
for (uint16_t i = 0; i < rdata_count; i++) {
/* Space to store length of one RR. */
size += sizeof(uint32_t);
......@@ -109,7 +109,7 @@ int rrset_serialize(const knot_rrset_t *rrset, uint8_t *stream, size_t *size)
size_t offset = sizeof(uint64_t);
/* Save RR count. */
const uint16_t rr_count = knot_rrset_rr_count(rrset);
const uint16_t rr_count = rrset->rrs.rr_count;
memcpy(stream + offset, &rr_count, sizeof(uint16_t));
offset += sizeof(uint16_t);
/* Save owner. */
......
......@@ -560,8 +560,7 @@ int knot_ns_switch_zone(knot_ns_xfr_t *xfr)
* a reload occurs when transfer is pending. */
zone_t *z = xfr->zone;
if (z == NULL) {
char *name = knot_dname_to_str(knot_node_owner(
knot_zone_contents_apex(zone)));
char *name = knot_dname_to_str(zone->apex->owner);
dbg_xfr("Failed to replace zone %s, old zone "
"not found\n", name);
free(name);
......
......@@ -1140,7 +1140,7 @@ int zones_save_zone(const knot_ns_xfr_t *xfr)
/* 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 = new_zone->apex->owner;
int r = knot_dname_cmp(cur_name, new_name);
knot_dname_free(&cur_name, NULL);
if (r != 0) {
......
......@@ -164,7 +164,7 @@ static int check_in_use(const knot_zone_contents_t *zone,
if (node == NULL) {
*rcode = KNOT_RCODE_NXDOMAIN;
return KNOT_EPREREQ;
} else if (knot_node_rrset_count(node) == 0) {
} else if (node->rrset_count == 0) {
*rcode = KNOT_RCODE_NXDOMAIN;
return KNOT_EPREREQ;
}
......@@ -183,7 +183,7 @@ static int check_not_in_use(const knot_zone_contents_t *zone,
const knot_node_t *node = knot_zone_contents_find_node(zone, dname);
if (node == NULL) {
return KNOT_EOK;
} else if (knot_node_rrset_count(node) == 0) {
} else if (node->rrset_count == 0) {
return KNOT_EOK;
}
......@@ -194,7 +194,7 @@ static int check_not_in_use(const knot_zone_contents_t *zone,
/*!< \brief Returns true if rrset has 0 data or RDATA of size 0 (we need TTL). */
static bool rrset_empty(const knot_rrset_t *rrset)
{
uint16_t rr_count = knot_rrset_rr_count(rrset);
uint16_t rr_count = rrset->rrs.rr_count;
if (rr_count == 0) {
return true;
}
......
......@@ -81,10 +81,9 @@ int xfrin_transfer_needed(const knot_zone_contents_t *zone,
* Retrieve the local Serial
*/
const knot_rdataset_t *soa_rrs =
knot_node_rdataset(knot_zone_contents_apex(zone), KNOT_RRTYPE_SOA);
knot_node_rdataset(zone->apex, KNOT_RRTYPE_SOA);
if (soa_rrs == NULL) {
char *name = knot_dname_to_str(knot_node_owner(
knot_zone_contents_apex(zone)));
char *name = knot_dname_to_str(zone->apex->owner);
dbg_xfrin("SOA RRSet missing in the zone %s!\n", name);
free(name);
return KNOT_ERROR;
......@@ -698,7 +697,7 @@ static int xfrin_replace_rrs_with_copy(knot_node_t *node,
static void clear_new_rrs(knot_node_t *node, uint16_t type)
{
knot_rdataset_t *new_rrs = knot_node_get_rdataset(node, type);
knot_rdataset_t *new_rrs = knot_node_rdataset(node, type);
if (new_rrs) {
knot_rdataset_clear(new_rrs, NULL);
}
......@@ -774,7 +773,7 @@ static int remove_rr(knot_node_t *node, const knot_rrset_t *rr,
return ret;
}
knot_rdataset_t *changed_rrs = knot_node_get_rdataset(node, rr->type);
knot_rdataset_t *changed_rrs = knot_node_rdataset(node, rr->type);
// Subtract changeset RRS from node RRS.
ret = knot_rdataset_subtract(changed_rrs, &rr->rrs, NULL);
if (ret != KNOT_EOK) {
......@@ -842,7 +841,7 @@ static int add_rr(knot_node_t *node, const knot_rrset_t *rr,
}
// Extract copy, merge into it
knot_rdataset_t *changed_rrs = knot_node_get_rdataset(node, rr->type);
knot_rdataset_t *changed_rrs = knot_node_rdataset(node, rr->type);
ret = knot_rdataset_merge(changed_rrs, &rr->rrs, NULL);
if (ret != KNOT_EOK) {
clear_new_rrs(node, rr->type);
......@@ -869,7 +868,7 @@ static int add_rr(knot_node_t *node, const knot_rrset_t *rr,
}
// Get changed RRS and store for possible rollback.
knot_rdataset_t *rrs = knot_node_get_rdataset(node, rr->type);
knot_rdataset_t *rrs = knot_node_rdataset(node, rr->type);
int ret = add_new_data(chset, rrs->data);
if (ret != KNOT_EOK) {
knot_rdataset_clear(rrs, NULL);
......@@ -980,7 +979,7 @@ static int xfrin_mark_empty(knot_node_t **node_p, void *data)
list_t *l = (list_t *)data;
assert(data);
if (node->rrset_count == 0 && node->children == 0 &&
!knot_node_is_empty(node)) {
!(node->flags & KNOT_NODE_FLAGS_EMPTY)) {
/*!
* Mark this node and all parent nodes that have 0 RRSets and
* no children for removal.
......@@ -989,11 +988,11 @@ static int xfrin_mark_empty(knot_node_t **node_p, void *data)
if (ret != KNOT_EOK) {
return ret;
}
knot_node_set_empty(node);
node->flags |= KNOT_NODE_FLAGS_EMPTY;
if (node->parent) {
if (knot_node_has_wildcard_child(node->parent)
if ((node->parent->flags & KNOT_NODE_FLAGS_WILDCARD_CHILD)
&& knot_dname_is_wildcard(node->owner)) {
knot_node_clear_wildcard_child(node->parent);
node->parent->flags &= ~KNOT_NODE_FLAGS_WILDCARD_CHILD;
}
node->parent->children--;
// Recurse using the parent node
......@@ -1092,7 +1091,7 @@ int xfrin_prepare_zone_copy(knot_zone_contents_t *old_contents,
return ret;
}
assert(knot_zone_contents_apex(contents_copy) != NULL);
assert(contents_copy->apex != NULL);
*new_contents = contents_copy;
......@@ -1141,7 +1140,7 @@ int xfrin_finalize_updated_zone(knot_zone_contents_t *contents_copy,
return ret;
}
assert(knot_zone_contents_apex(contents_copy) != NULL);
assert(contents_copy->apex != NULL);
return KNOT_EOK;
}
......@@ -1251,7 +1250,7 @@ int xfrin_apply_changesets(zone_t *zone,
return ret;
}
}
assert(knot_zone_contents_apex(contents_copy) != NULL);
assert(contents_copy->apex != NULL);
/*!
* \todo Test failure of IXFR.
......
This diff is collapsed.
......@@ -89,37 +89,31 @@ struct rr_data {
/*----------------------------------------------------------------------------*/
/*! \brief Flags used to mark nodes with some property. */
typedef enum {
/*! \brief Empty flag initializer. */
KNOT_NODE_FLAGS_NULL = 0 << 0,
/*! \brief Node is authoritative. */
KNOT_NODE_FLAGS_AUTH = 1 << 0,
/*! \brief Node is a delegation point (i.e. marking a zone cut). */
KNOT_NODE_FLAGS_DELEG = 1 << 0,
KNOT_NODE_FLAGS_DELEG = 1 << 1,
/*! \brief Node is not authoritative (i.e. below a zone cut). */
KNOT_NODE_FLAGS_NONAUTH = 1 << 1,
KNOT_NODE_FLAGS_NONAUTH = 1 << 2,
/*! \brief Node is an apex node. */
KNOT_NODE_FLAGS_APEX = 1 << 2,
KNOT_NODE_FLAGS_APEX = 1 << 3,
/*! \brief NSEC/NSEC3 was removed from this node. */
KNOT_NODE_FLAGS_REMOVED_NSEC = 1 << 3,
/*! \brief Node is empty and will be deleted after update.
* \todo Remove after dname refactoring, update description in node. */
KNOT_NODE_FLAGS_EMPTY = 1 << 4,
KNOT_NODE_FLAGS_REMOVED_NSEC = 1 << 4,
/*! \brief Node is empty and will be deleted after update. */
KNOT_NODE_FLAGS_EMPTY = 1 << 5,
/*! \brief Node has a wildcard child. */
KNOT_NODE_FLAGS_WILDCARD_CHILD = 1 << 5
KNOT_NODE_FLAGS_WILDCARD_CHILD = 1 << 6
} knot_node_flags_t;
/*----------------------------------------------------------------------------*/
/*!
* \brief Creates and initializes new node structure.
*
* \todo Owner reference counter will be increased.
*
* \param owner Owner of the created node.
* \param parent Parent of the created node.
* \param flags Document me.
*
* \todo Document missing parameters.
*
* \return Newly created node or NULL if an error occured.
*/
knot_node_t *knot_node_new(const knot_dname_t *owner, knot_node_t *parent,
uint8_t flags);
knot_node_t *knot_node_new(const knot_dname_t *owner);
/*!
* \brief Adds an RRSet to the node.
......@@ -132,8 +126,7 @@ knot_node_t *knot_node_new(const knot_dname_t *owner, knot_node_t *parent,
*/
int knot_node_add_rrset(knot_node_t *node, const knot_rrset_t *rrset, bool *ttl_err);
const knot_rdataset_t *knot_node_rdataset(const knot_node_t *node, uint16_t type);
knot_rdataset_t *knot_node_get_rdataset(const knot_node_t *node, uint16_t type);
knot_rdataset_t *knot_node_rdataset(const knot_node_t *node, uint16_t type);
/*!
* \brief Returns the RRSet of the given type from the node (non-const version).
......@@ -148,27 +141,6 @@ knot_rrset_t *knot_node_create_rrset(const knot_node_t *node, uint16_t type);
void knot_node_remove_rrset(knot_node_t *node, uint16_t type);
/*!
* \brief Returns number of RRSets in the node.
*
* \param node Node to get the RRSet count from.
*
* \return Number of RRSets in \a node.
*/
short knot_node_rrset_count(const knot_node_t *node);
/*!
* \brief Returns the parent of the node.
*
* \param node Node to get the parent of.
*
* \return Parent node of the given node or NULL if no parent has been set (e.g.
* node in a zone apex has no parent).