summaryrefslogtreecommitdiffstats
path: root/daemon/zimport.h
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/zimport.h')
-rw-r--r--daemon/zimport.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/daemon/zimport.h b/daemon/zimport.h
new file mode 100644
index 0000000..5bbd992
--- /dev/null
+++ b/daemon/zimport.h
@@ -0,0 +1,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);
+