1 /* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> 2 * SPDX-License-Identifier: GPL-3.0-or-later 3 */ 4 5 #pragma once 6 7 #include <stdbool.h> 8 9 struct worker_ctx; 10 /** Zone import context (opaque). */ 11 struct zone_import_ctx; 12 13 /** 14 * Completion callback 15 * 16 * @param state -1 - fail 17 * 0 - success 18 * 1 - success, but there are non-critical errors 19 * @param pointer to user data 20 */ 21 typedef void (*zi_callback)(int state, void *param); 22 23 /** 24 * Allocate and initialize zone import context. 25 * 26 * @param worker pointer to worker state 27 * @return NULL or pointer to zone import context. 28 */ 29 struct zone_import_ctx *zi_allocate(struct worker_ctx *worker, 30 zi_callback cb, void *param); 31 32 /** Free zone import context. */ 33 void zi_free(struct zone_import_ctx *z_import); 34 35 /** 36 * Import zone from file. 37 * 38 * @note only root zone import is supported; origin must be NULL or "." 39 * @param z_import pointer to zone import context 40 * @param zone_file zone file name 41 * @param origin default origin 42 * @param rclass default class 43 * @param ttl default ttl 44 * @return 0 or an error code 45 */ 46 int zi_zone_import(struct zone_import_ctx *z_import, 47 const char *zone_file, const char *origin, 48 uint16_t rclass, uint32_t ttl); 49 50 /** 51 * Check if import already in process. 52 * 53 * @param z_import pointer to zone import context. 54 * @return true if import already in process; false otherwise. 55 */ 56 bool zi_import_started(struct zone_import_ctx *z_import); 57