1 /* 2 * Copyright (c) 2009 NLNet Labs. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 21 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 23 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 */ 26 27 #ifndef SIGNER_DOMAIN_H 28 #define SIGNER_DOMAIN_H 29 30 #include "config.h" 31 #include <ldns/ldns.h> 32 #include <time.h> 33 34 35 typedef struct domain_struct domain_type; 36 37 #include "status.h" 38 #include "signer/rrset.h" 39 #include "signer/signconf.h" 40 #include "signer/zone.h" 41 42 #define SE_NSEC_RDATA_NXT 0 43 #define SE_NSEC_RDATA_BITMAP 1 44 #define SE_NSEC3_RDATA_NSEC3PARAMS 4 45 #define SE_NSEC3_RDATA_NXT 4 46 #define SE_NSEC3_RDATA_BITMAP 5 47 48 /** 49 * Domain. 50 * 51 */ 52 struct domain_struct { 53 denial_type* denial; 54 zone_type* zone; 55 ldns_rbnode_t* node; 56 ldns_rdf* dname; 57 domain_type* parent; 58 rrset_type* rrsets; 59 unsigned is_new : 1; 60 unsigned is_apex : 1; /* apex */ 61 }; 62 63 /** 64 * Log domain name. 65 * \param[in] rdf domain name 66 * \param[in] pre log message 67 * \param[in] level log level 68 * 69 */ 70 void log_dname(ldns_rdf* rdf, const char* pre, int level); 71 72 /** 73 * Create domain. 74 * \param[in] zoneptr zone reference 75 * \param[in] dname owner name 76 * \return domain_type* domain 77 * 78 */ 79 domain_type* domain_create(zone_type* zone, ldns_rdf* dname); 80 81 /** 82 * Count the number of RRsets at this domain with RRs that have is_added. 83 * \param[in] domain domain 84 * \return size_t number of RRsets 85 * 86 */ 87 size_t domain_count_rrset_is_added(domain_type* domain); 88 89 /** 90 * Look up RRset at this domain. 91 * \param[in] domain the domain 92 * \param[in] rrtype RRtype 93 * \return rrset_type* RRset, if found 94 * 95 */ 96 rrset_type* domain_lookup_rrset(domain_type* domain, ldns_rr_type rrtype); 97 98 /** 99 * Add RRset to domain. 100 * \param[in] domain domain 101 * \param[in] rrset RRset 102 * 103 */ 104 void domain_add_rrset(domain_type* domain, rrset_type* rrset); 105 106 /** 107 * Apply differences at domain. 108 * \param[in] domain domain 109 * \param[in] is_ixfr true if incremental change 110 * \param[in] more_coming more transactions possible 111 * 112 */ 113 void domain_diff(domain_type* domain, unsigned is_ixfr, unsigned more_coming); 114 115 /** 116 * Rollback differences at domain. 117 * \param[in] domain domain 118 * \param[in] keepsc keep RRs that did not came from the adapter 119 * 120 */ 121 void domain_rollback(domain_type* domain, int keepsc); 122 123 /** 124 * Check whether a domain is an empty non-terminal to an unsigned delegation. 125 * \param[in] domain domain 126 * \return int yes or no 127 * 128 */ 129 int domain_ent2unsignedns(domain_type* domain); 130 131 /** 132 * Check whether a domain is a delegation, regardless of parent. 133 * \param[in] domain domain 134 * \return ldns_rr_type RRtype that hints whether the domain is occluded. 135 * LDNS_RR_TYPE_NS Unsigned delegation 136 * LDNS_RR_TYPE_DS Signed delegation 137 * LDNS_RR_TYPE_SOA Authoritative data (or signed delegation) 138 * 139 */ 140 ldns_rr_type domain_is_delegpt(domain_type* domain); 141 142 /** 143 * Check whether the domain is occluded. 144 * \param[in] domain domain 145 * \return ldns_rr_type RRtype that hints whether the domain is occluded. 146 * LDNS_RR_TYPE_DNAME Occluded 147 * LDNS_RR_TYPE_A Glue 148 * LDNS_RR_TYPE_SOA Authoritative data or delegation 149 * 150 */ 151 ldns_rr_type domain_is_occluded(domain_type* domain); 152 153 /** 154 * Print domain. 155 * \param[in] fd file descriptor 156 * \param[in] domain domain 157 * \param[out] status status 158 * 159 */ 160 void domain_print(FILE* fd, domain_type* domain, ods_status* status); 161 162 /** 163 * Clean up domain. 164 * \param[in] domain domain to cleanup 165 * 166 */ 167 void domain_cleanup(domain_type* domain); 168 169 /** 170 * Backup domain. 171 * \param[in] fd file descriptor 172 * \param[in] domain domain 173 * \param[in] sigs do RRSIGS if true, otherwise do RRset 174 * 175 */ 176 void domain_backup2(FILE* fd, domain_type* domain, int sigs); 177 178 #endif /* SIGNER_DOMAIN_H */ 179