Commit 821b509f authored by Dominik Taborsky's avatar Dominik Taborsky

zone-api: add zone_update _add and _remove RR functions.

parent 77fb144b
......@@ -465,14 +465,14 @@ static int add_rr_to_chgset(const knot_rrset_t *rr,
return KNOT_EOK;
}
return changeset_add_rrset(&update->change, rr);
return zone_update_add(update, rr);
}
/*!< \brief Adds RR into remove section of changeset if it is deemed worthy. */
static int rem_rr_to_chgset(const knot_rrset_t *rr,
zone_update_t *update)
{
return changeset_rem_rrset(&update->change, rr);
return zone_update_remove(update, rr);
}
/*!< \brief Adds all RRs from RRSet into remove section of changeset. */
......
......@@ -258,6 +258,37 @@ void zone_update_clear(zone_update_t *update)
}
}
int zone_update_add(zone_update_t *update, const knot_rrset_t *rrset)
{
if (update->flags & UPDATE_WRITING_ITER) {
return changeset_add_rrset(&update->iteration_changes, rrset);
} else if (update->flags & UPDATE_INCREMENTAL) {
return changeset_add_rrset(&update->change, rrset);
} else if (update->flags & UPDATE_FULL) {
zone_node_t *n = NULL;
return zone_contents_add_rr(update->new_cont, rrset, &n);
} else {
return KNOT_EINVAL;
}
}
int zone_update_remove(zone_update_t *update, const knot_rrset_t *rrset)
{
if (update->flags & UPDATE_WRITING_ITER) {
return changeset_rem_rrset(&update->iteration_changes, rrset);
} else if (update->flags & UPDATE_INCREMENTAL) {
return changeset_rem_rrset(&update->change, rrset);
} else {
// Removing from zone during creation does not make sense, ignore.
/* The comment right above does not make sense when the following line
* was uncommented. Anyway, right now we don't have a nice and clean way
* to remove an RR. FIXME
*/
//return zone_contents_remove_rr(update->new_cont, rrset);
return KNOT_ENOTSUP;
}
}
static bool apex_rr_changed(const zone_node_t *old_apex,
const zone_node_t *new_apex,
uint16_t type)
......
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