1 /*------------------------------------------------------------------------------ 2 * 3 * Copyright (c) 2011-2021, EURid vzw. All rights reserved. 4 * The YADIFA TM software product is provided under the BSD 3-clause license: 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * * Neither the name of EURid nor the names of its contributors may be 16 * used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 *------------------------------------------------------------------------------ 32 * 33 */ 34 35 #pragma once 36 37 #include <dnscore/sys_types.h> 38 39 /** 40 * For backward compatibility 41 * 42 * @param path 43 */ 44 45 void journal_set_xfr_path(const char *path); 46 47 /** 48 * For backward compatibility 49 * 50 * @return 51 */ 52 53 const char* journal_get_xfr_path(); 54 55 /** 56 * The database does not know zone types. The only one that does is the server. 57 * So it makes sense to provide it a way to chose where the DB will store journals. 58 * This is especially important with the new master/slave journal separation 59 * 60 * The default provider returns something based on the XFR path (journal_set_xfr_path) 61 * 62 */ 63 64 #define ZDB_ZONE_PATH_PROVIDER_ZONE_PATH 1 // want the full path of the directory for the zone 65 #define ZDB_ZONE_PATH_PROVIDER_ZONE_FILE 2 // want the full path of the file for the zone 66 #define ZDB_ZONE_PATH_PROVIDER_AXFR_PATH 3 // want the full path of the directory for the image of the zone (AXFR) 67 #define ZDB_ZONE_PATH_PROVIDER_AXFR_FILE 4 // want the full path of the directory for the image of the zone (AXFR) 68 #define ZDB_ZONE_PATH_PROVIDER_IXFR_PATH 5 // want the full path of the file for the incremental of the zone (IXFR/journal) 69 #define ZDB_ZONE_PATH_PROVIDER_IXFR_FILE 6 // want the full path of the file for the incremental of the zone (IXFR/journal) 70 #define ZDB_ZONE_PATH_PROVIDER_DNSKEY_PATH 7 // want the full path containing the DNSKEY keypairs for the zone (smart signing, key management) 71 #define ZDB_ZONE_PATH_PROVIDER_RNDSUFFIX 64 // appends a suffix to the file name (.SUFFIX), useful for temporary files/files being build 72 #define ZDB_ZONE_PATH_PROVIDER_MKDIR 128 // create the path before returning 73 74 typedef ya_result zdb_zone_path_provider_callback(const u8* domain_fqdn, char *path_buffer, u32 path_buffer_size, u32 flags); 75 76 /** 77 * Sets the provider. 78 * 79 * Note that the provider should return the length of the strings it returns. 80 * 81 * @param provider the provider or NULL to reset to the default one. 82 */ 83 84 void zdb_zone_path_set_provider(zdb_zone_path_provider_callback *provider); 85 zdb_zone_path_provider_callback *zdb_zone_path_get_provider(); 86 87 struct zdb_zone_path_provider_buffer 88 { 89 void *ptr; 90 u32 size; 91 }; 92 93 typedef struct zdb_zone_path_provider_buffer zdb_zone_path_provider_buffer; 94 95 union zdb_zone_info_provider_data 96 { 97 bool _bool; 98 u8 _u8; 99 u16 _u16; 100 u32 _u32; 101 u64 _u64; 102 ya_result _result; 103 void *_ptr; 104 zdb_zone_path_provider_buffer _buffer; 105 }; 106 107 typedef union zdb_zone_info_provider_data zdb_zone_info_provider_data; 108 109 /** 110 * Zone info should be renamed into zone ctrl (not to be mixed with the server ctrl) 111 * The zone ctrl may become a superset of the path provider 112 * The zdb_zone_path_provider_data could become a generic high-level type 113 */ 114 115 typedef ya_result zdb_zone_info_provider_callback(const u8 *origin, zdb_zone_info_provider_data *data, u32 flags); 116 117 #define ZDB_ZONE_INFO_PROVIDER_STORED_SERIAL 0x100 // u32 118 #define ZDB_ZONE_INFO_PROVIDER_MAX_JOURNAL_SIZE 0x101 // u32 119 #define ZDB_ZONE_INFO_PROVIDER_ZONE_TYPE 0x102 // u8 (ZT_MASTER, ZT_SLAVE, ...) 120 121 #define ZDB_ZONE_INFO_PROVIDER_STORE_TRIGGER 0x10000 // NULL, enqueues the storage of the zone 122 #define ZDB_ZONE_INFO_PROVIDER_STORE_NOW 0x10001 // ?, stores the zone now, in this thread 123 #define ZDB_ZONE_INFO_PROVIDER_STORE_IN_PROGRESS 0x10002 // ?, stores the zone now, in this thread 124 125 126 void zdb_zone_info_set_provider(zdb_zone_info_provider_callback *data); 127 zdb_zone_info_provider_callback *zdb_zone_info_get_provider(); 128 129 ya_result zdb_zone_info_get_stored_serial(const u8 *origin, u32 *serial); 130 131 ya_result zdb_zone_info_get_zone_max_journal_size(const u8 *origin, u32 *size); 132 133 ya_result zdb_zone_info_get_zone_type(const u8 *origin, u8 *zt); 134 135 ya_result zdb_zone_info_store_locked_zone(const u8 *origin); 136 137 ya_result zdb_zone_info_background_store_zone(const u8 *origin); 138 139 /** 140 * 141 * Should not be used anymore. 142 * 143 * @param origin 144 * @param minimum_serial 145 * @return 146 */ 147 148 ya_result zdb_zone_info_background_store_zone_and_wait_for_serial(const u8 *origin, u32 minimum_serial); 149 150 ya_result zdb_zone_info_background_store_in_progress(const u8 *origin); 151 152 153 /** @} */ 154