Commit 225fd8d3 authored by Libor Peltan's avatar Libor Peltan Committed by Daniel Salzman

updates: apply changeset feature (with preapply fix)

parent a6f82225
......@@ -144,7 +144,7 @@ static bool can_remove(const zone_node_t *node, const knot_rrset_t *rr)
}
/*! \brief Removes all RRs from changeset from zone contents. */
static int apply_remove(apply_ctx_t *ctx, changeset_t *chset)
static int apply_remove(apply_ctx_t *ctx, const changeset_t *chset)
{
changeset_iter_t itt;
changeset_iter_rem(&itt, chset);
......@@ -165,7 +165,7 @@ static int apply_remove(apply_ctx_t *ctx, changeset_t *chset)
}
/*! \brief Adds all RRs from changeset into zone contents. */
static int apply_add(apply_ctx_t *ctx, changeset_t *chset)
static int apply_add(apply_ctx_t *ctx, const changeset_t *chset)
{
changeset_iter_t itt;
changeset_iter_add(&itt, chset);
......@@ -185,7 +185,7 @@ static int apply_add(apply_ctx_t *ctx, changeset_t *chset)
}
/*! \brief Apply single change to zone contents structure. */
static int apply_single(apply_ctx_t *ctx, changeset_t *chset)
static int apply_single(apply_ctx_t *ctx, const changeset_t *chset)
{
/*
* Applies one changeset to the zone. Checks if the changeset may be
......@@ -362,7 +362,7 @@ int apply_remove_rr(apply_ctx_t *ctx, const knot_rrset_t *rr)
return KNOT_EOK;
}
int apply_replace_soa(apply_ctx_t *ctx, changeset_t *chset)
int apply_replace_soa(apply_ctx_t *ctx, const changeset_t *chset)
{
zone_contents_t *contents = ctx->contents;
......@@ -480,7 +480,7 @@ int apply_changesets_directly(apply_ctx_t *ctx, list_t *chsets)
return zone_contents_adjust_full(ctx->contents);
}
int apply_changeset_directly(apply_ctx_t *ctx, changeset_t *ch)
int apply_changeset_directly(apply_ctx_t *ctx, const changeset_t *ch)
{
if (ctx == NULL || ctx->contents == NULL || ch == NULL) {
return KNOT_EINVAL;
......
......@@ -89,7 +89,7 @@ int apply_remove_rr(apply_ctx_t *ctx, const knot_rrset_t *rr);
*
* \return KNOT_E*
*/
int apply_replace_soa(apply_ctx_t *ctx, changeset_t *ch);
int apply_replace_soa(apply_ctx_t *ctx, const changeset_t *ch);
/*!
* \brief Prepares the new zone contents for signing.
......@@ -146,7 +146,7 @@ int apply_changesets_directly(apply_ctx_t *ctx, list_t *chsets);
*
* \return KNOT_E*
*/
int apply_changeset_directly(apply_ctx_t *ctx, changeset_t *ch);
int apply_changeset_directly(apply_ctx_t *ctx, const changeset_t *ch);
/*!
* \brief Finalizes the zone contents for publishing.
......
/* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -364,6 +364,30 @@ int zone_update_remove_node(zone_update_t *update, const knot_dname_t *owner)
return KNOT_EOK;
}
int zone_update_apply_changeset(zone_update_t *update, const changeset_t *changes)
{
int ret = KNOT_EOK;
if (update->flags & UPDATE_INCREMENTAL) {
ret = changeset_merge(&update->change, changes);
}
if (ret == KNOT_EOK) {
ret = apply_changeset_directly(&update->a_ctx, changes);
}
return ret;
}
int zone_update_apply_changeset_fix(zone_update_t *update, changeset_t *changes)
{
int ret = changeset_cancelout(changes);
if (ret == KNOT_EOK) {
ret = changeset_preapply_fix(update->new_cont, changes);
}
if (ret == KNOT_EOK) {
ret = zone_update_apply_changeset(update, changes);
}
return ret;
}
static bool apex_rr_changed(const zone_node_t *old_apex,
const zone_node_t *new_apex,
uint16_t type)
......
......@@ -184,6 +184,26 @@ int zone_update_remove_rrset(zone_update_t *update, knot_dname_t *owner, uint16_
*/
int zone_update_remove_node(zone_update_t *update, const knot_dname_t *owner);
/*!
* \brief Adds and removes RRsets to/from the zone according to the changeset.
*
* \param update Zone update.
* \param changes Changes to be made in zone.
*
* \return KNOT_E*
*/
int zone_update_apply_changeset(zone_update_t *update, const changeset_t *changes);
/*!
* \brief Applies a changeset to zone, the changeset is modified to contain only really added/removed rdata.
*
* \param update Zone update.
* \param changes In: changes to be made in zone; out: changes really made in zone.
*
* \return KNOT_E*
*/
int zone_update_apply_changeset_fix(zone_update_t *update, changeset_t *changes);
/*!
* \brief Commits all changes to the zone, signs it, saves changes to journal.
*
......
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