apply.h 2.52 KB
Newer Older
1
/*!
2
 * \file apply.h
3 4
 *
 * \author Lubos Slovak <lubos.slovak@nic.cz>
5
 * \author Jan Kadlec <jan.kadlec@nic.cz>
6
 *
7
 * \brief Changesets application and update helpers.
8
 *
Lubos Slovak's avatar
Lubos Slovak committed
9
 * \addtogroup xfr
10 11
 * @{
 */
12
/*  Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
Lubos Slovak's avatar
Lubos Slovak committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26

    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
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
27

28
#pragma once
29 30 31 32

#include <stdint.h>
#include <string.h>

33
#include "knot/zone/zone.h"
34
#include "knot/updates/changesets.h"
35

36 37 38 39 40 41
/*!
 * \brief Applies changesets *with* zone shallow copy.
 *
 * \param zone          Zone to be updated.
 * \param chsets        Changes to be made.
 * \param new_contents  New zone will be returned using this arg.
42
 *
43 44
 * \return KNOT_E*
 */
45
int apply_changesets(zone_t *zone, changesets_t *chsets,
46
                     zone_contents_t **new_contents);
47

48 49 50 51 52 53 54 55 56
/*!
 * \brief Applies changesets directly to the zone, without copying it.
 *
 * \param contents Zone contents to apply the changesets to. Will be modified.
 * \param chsets   Changesets to be applied to the zone.
 *
 * \retval KNOT_EOK if successful.
 * \retval KNOT_EINVAL if given one of the arguments is NULL.
 * \return Other error code if the application went wrong.
57
 */
58
int apply_changesets_directly(zone_contents_t *contents,
59
                              changesets_t *chsets);
60

61 62 63 64
/*!
 * \brief Cleanups successful update. (IXFR, DNSSEC, DDNS).
 * \param chgs  Changesets used to create the update.
 */
65
void update_cleanup(changesets_t *chgs);
Jan Kadlec's avatar
Jan Kadlec committed
66

67 68 69 70 71 72
/*!
 * \brief Rollbacks failed update (IXFR, DNSSEC, DDNS).
 *
 * \param chgs          Changesets used to create the update.
 * \param new_contents  Created zone contents.
 */
73
void update_rollback(changesets_t *chgs, zone_contents_t **new_contents);
Jan Kadlec's avatar
Jan Kadlec committed
74

75 76 77 78 79 80 81
/*!
 * \brief Frees old zone contents - i.e. contents that were used to create the
 *        shallow copy, but are now obsolete.
 * \note Exported because of update.c, zone.c.
 * \param contents  Contents to free.
 */
void update_free_old_zone(zone_contents_t **contents);
82 83

/*! @} */