Commit 2f167e3b authored by Jan Kadlec's avatar Jan Kadlec

new_node: changeset application using new node

- only basic functionality with leaks
parent eab009d3
This diff is collapsed.
......@@ -202,8 +202,6 @@ int xfrin_switch_zone(zone_t *zone,
knot_zone_contents_t *new_contents,
int transfer_type);
void xfrin_cleanup_successful_update(knot_zone_contents_t *zone);
void xfrin_rollback_update(knot_zone_contents_t *old_contents,
knot_zone_contents_t **new_contents);
......
......@@ -279,22 +279,21 @@ knot_rrset_t *knot_node_create_rrset(const knot_node_t *node, uint16_t type)
/*----------------------------------------------------------------------------*/
knot_rrset_t *knot_node_remove_rrset(knot_node_t *node, uint16_t type)
void knot_node_remove_rrset(knot_node_t *node, uint16_t type)
{
if (node == NULL) {
return NULL;
return;
}
for (int i = 0; i < node->rrset_count; ++i) {
if (node->rrs[i].type == type) {
knot_rrset_t *ret = rrset_from_rr_data(node, i, NULL);
memmove(node->rrs + i, node->rrs + i + 1, (node->rrset_count - i - 1) * sizeof(struct rr_data));
--node->rrset_count;
return ret;
return;
}
}
return NULL;
return;
}
/*----------------------------------------------------------------------------*/
......
......@@ -157,7 +157,7 @@ knot_rrs_t *knot_node_get_rrs(const knot_node_t *node, uint16_t type);
*/
knot_rrset_t *knot_node_create_rrset(const knot_node_t *node, uint16_t type);
knot_rrset_t *knot_node_remove_rrset(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.
......
......@@ -1471,3 +1471,55 @@ bool knot_zone_contents_is_signed(const knot_zone_contents_t *zone)
{
return knot_node_rrtype_is_signed(zone->apex, KNOT_RRTYPE_SOA);
}
knot_node_t *zone_contents_get_node_for_rr(knot_zone_contents_t *zone,
const knot_rrset_t *rrset)
{
if (zone == NULL || rrset == NULL) {
return NULL;
}
knot_node_t *node;
const bool nsec3 = knot_rrset_is_nsec3rel(rrset);
if (!nsec3) {
node = knot_zone_contents_get_node(zone, rrset->owner);
} else {
node = knot_zone_contents_get_nsec3_node(zone, rrset->owner);
}
if (node == NULL) {
int ret = KNOT_EOK;
node = knot_node_new(rrset->owner, NULL, 0);
if (!nsec3) {
ret = knot_zone_contents_add_node(zone, node, 1, 0);
} else {
ret = knot_zone_contents_add_nsec3_node(zone, node, 1, 0);
}
if (ret != KNOT_EOK) {
knot_node_free(&node);
return NULL;
}
return node;
} else {
return node;
}
}
knot_node_t *zone_contents_find_node_for_rr(knot_zone_contents_t *zone,
const knot_rrset_t *rrset)
{
if (zone == NULL || rrset == NULL) {
return NULL;
}
knot_node_t *node;
const bool nsec3 = knot_rrset_is_nsec3rel(rrset);
if (!nsec3) {
node = knot_zone_contents_get_node(zone, rrset->owner);
} else {
node = knot_zone_contents_get_nsec3_node(zone, rrset->owner);
}
return node;
}
......@@ -29,6 +29,7 @@
#include "knot/zone/node.h"
#include "libknot/dnssec/nsec3.h"
#include "common/lists.h"
#include "knot/zone/zone-tree.h"
......@@ -69,6 +70,8 @@ typedef struct knot_zone_contents_t {
* - 0xx - ANY queries enabled
*/
uint8_t flags;
list_t old_data;
list_t new_data;
} knot_zone_contents_t;
/*!< \brief Helper linked list list for CNAME loop checking */
......@@ -442,6 +445,12 @@ uint32_t knot_zone_serial(const knot_zone_contents_t *zone);
*/
bool knot_zone_contents_is_signed(const knot_zone_contents_t *zone);
knot_node_t *zone_contents_get_node_for_rr(knot_zone_contents_t *zone,
const knot_rrset_t *rrset);
knot_node_t *zone_contents_find_node_for_rr(knot_zone_contents_t *zone,
const knot_rrset_t *rrset);
#endif
/*! @} */
......@@ -270,7 +270,6 @@ knot_rrs_t *knot_rrs_new(mm_ctx_t *mm)
void knot_rrs_init(knot_rrs_t *rrs)
{
if (rrs) {
rrs->flags = 0;
rrs->rr_count = 0;
rrs->data = NULL;
}
......
......@@ -9,13 +9,7 @@
typedef uint8_t knot_rr_t;
enum rrs_flags {
RRS_OLD = 1 << 0,
RRS_NEW = 1 << 1
};
typedef struct knot_rrs {
uint8_t flags;
uint16_t rr_count;
knot_rr_t *data;
} knot_rrs_t;
......
......@@ -1281,7 +1281,7 @@ int knot_rrset_intersection(const knot_rrset_t *a, const knot_rrset_t *b,
knot_rrset_t *out, mm_ctx_t *mm)
{
if (a == NULL || b == NULL || !knot_dname_is_equal(a->owner, b->owner) ||
a->type != b->type || a->rclass != b->rclass) {
a->type != b->type) {
return KNOT_EINVAL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment