summaryrefslogtreecommitdiffstats
path: root/daemon/zimport.h
blob: 5bbd992b08f98cd4b299f16e7b37d4dfcfef6a25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*  Copyright (C) CZ.NIC, z.s.p.o. <knot-resolver@labs.nic.cz>
 *  SPDX-License-Identifier: GPL-3.0-or-later
 */

#pragma once

#include <stdbool.h>
#include <libknot/rrset.h>
#include "lib/defines.h"

/**
 * Completion callback
 *
 * @param state  0 for OK completion, < 0 for errors (unfinished)
 * @param param  pointer to user data
 */
typedef void (*zi_callback)(int state, void *param);
typedef struct {
	/* Parser, see zs_init() */
	const char *zone_file;
	const char *origin;
	uint32_t ttl;

	/// Source of time: current real time, or file modification time.
	enum { ZI_STAMP_NOW = 0, ZI_STAMP_MTIM } time_src;

	/* Validator */
	bool downgrade; /// true -> disable validation
	bool zonemd; /// true -> verify zonemd
	const knot_rrset_t *ds; /// NULL -> use trust anchors

	zi_callback cb;
	void *cb_param;
} zi_config_t;

/** Import zone from a file.
 *
 * Error can be directly returned in the first phase (parsing + ZONEMD);
 * otherwise it will be kr_ok() and config->cb gets (optionally) called finally.
 *
 * Large zone would pause other processing for longer time;
 * that's generally not advisable.
 *
 * Zone origin is detected from SOA, but it's certainly not perfect now.
 */
KR_EXPORT
int zi_zone_import(const zi_config_t config);