1 /* 2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 3 * 4 * This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 * 8 * See the COPYRIGHT file distributed with this work for additional 9 * information regarding copyright ownership. 10 */ 11 12 #ifndef DNS_NCACHE_H 13 #define DNS_NCACHE_H 1 14 15 /***** 16 ***** Module Info 17 *****/ 18 19 /*! \file dns/ncache.h 20 *\brief 21 * DNS Ncache 22 * 23 * XXX TBS XXX 24 * 25 * MP: 26 *\li The caller must ensure any required synchronization. 27 * 28 * Reliability: 29 *\li No anticipated impact. 30 * 31 * Resources: 32 *\li TBS 33 * 34 * Security: 35 *\li No anticipated impact. 36 * 37 * Standards: 38 *\li RFC2308 39 */ 40 41 #include <stdbool.h> 42 43 #include <isc/lang.h> 44 #include <isc/stdtime.h> 45 46 #include <dns/types.h> 47 48 ISC_LANG_BEGINDECLS 49 50 /*% 51 * _OMITDNSSEC: 52 * Omit DNSSEC records when rendering. 53 */ 54 #define DNS_NCACHETOWIRE_OMITDNSSEC 0x0001 55 56 isc_result_t 57 dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node, 58 dns_rdatatype_t covers, isc_stdtime_t now, dns_ttl_t minttl, 59 dns_ttl_t maxttl, dns_rdataset_t *addedrdataset); 60 isc_result_t 61 dns_ncache_addoptout(dns_message_t *message, dns_db_t *cache, 62 dns_dbnode_t *node, dns_rdatatype_t covers, 63 isc_stdtime_t now, dns_ttl_t minttl, dns_ttl_t maxttl, 64 bool optout, dns_rdataset_t *addedrdataset); 65 /*%< 66 * Convert the authority data from 'message' into a negative cache 67 * rdataset, and store it in 'cache' at 'node' with a TTL limited to 68 * 'maxttl'. 69 * 70 * \li dns_ncache_add produces a negative cache entry with a trust of no 71 * more than answer 72 * \li dns_ncache_addoptout produces a negative cache entry which will have 73 * a trust of secure if all the records that make up the entry are secure. 74 * 75 * The 'covers' argument is the RR type whose nonexistence we are caching, 76 * or dns_rdatatype_any when caching a NXDOMAIN response. 77 * 78 * 'optout' indicates a DNS_RDATASETATTR_OPTOUT should be set. 79 * 80 * Note: 81 *\li If 'addedrdataset' is not NULL, then it will be attached to the added 82 * rdataset. See dns_db_addrdataset() for more details. 83 * 84 * Requires: 85 *\li 'message' is a valid message with a properly formatting negative cache 86 * authority section. 87 * 88 *\li The requirements of dns_db_addrdataset() apply to 'cache', 'node', 89 * 'now', and 'addedrdataset'. 90 * 91 * Returns: 92 *\li #ISC_R_SUCCESS 93 *\li #ISC_R_NOSPACE 94 * 95 *\li Any result code of dns_db_addrdataset() is a possible result code 96 * of dns_ncache_add(). 97 */ 98 99 isc_result_t 100 dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx, 101 isc_buffer_t *target, unsigned int options, 102 unsigned int *countp); 103 /*%< 104 * Convert the negative caching rdataset 'rdataset' to wire format, 105 * compressing names as specified in 'cctx', and storing the result in 106 * 'target'. If 'omit_dnssec' is set, DNSSEC records will not 107 * be added to 'target'. 108 * 109 * Notes: 110 *\li The number of RRs added to target will be added to *countp. 111 * 112 * Requires: 113 *\li 'rdataset' is a valid negative caching rdataset. 114 * 115 *\li 'rdataset' is not empty. 116 * 117 *\li 'countp' is a valid pointer. 118 * 119 * Ensures: 120 *\li On a return of ISC_R_SUCCESS, 'target' contains a wire format 121 * for the data contained in 'rdataset'. Any error return leaves 122 * the buffer unchanged. 123 * 124 *\li *countp has been incremented by the number of RRs added to 125 * target. 126 * 127 * Returns: 128 *\li #ISC_R_SUCCESS - all ok 129 *\li #ISC_R_NOSPACE - 'target' doesn't have enough room 130 * 131 *\li Any error returned by dns_rdata_towire(), dns_rdataset_next(), 132 * dns_name_towire(). 133 */ 134 135 isc_result_t 136 dns_ncache_getrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name, 137 dns_rdatatype_t type, dns_rdataset_t *rdataset); 138 /*%< 139 * Search the negative caching rdataset for an rdataset with the 140 * specified name and type. 141 * 142 * Requires: 143 *\li 'ncacherdataset' is a valid negative caching rdataset. 144 * 145 *\li 'ncacherdataset' is not empty. 146 * 147 *\li 'name' is a valid name. 148 * 149 *\li 'type' is not SIG, or a meta-RR type. 150 * 151 *\li 'rdataset' is a valid disassociated rdataset. 152 * 153 * Ensures: 154 *\li On a return of ISC_R_SUCCESS, 'rdataset' is bound to the found 155 * rdataset. 156 * 157 * Returns: 158 *\li #ISC_R_SUCCESS - the rdataset was found. 159 *\li #ISC_R_NOTFOUND - the rdataset was not found. 160 * 161 */ 162 163 isc_result_t 164 dns_ncache_getsigrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name, 165 dns_rdatatype_t covers, dns_rdataset_t *rdataset); 166 /*%< 167 * Similar to dns_ncache_getrdataset() but get the rrsig that matches. 168 */ 169 170 void 171 dns_ncache_current(dns_rdataset_t *ncacherdataset, dns_name_t *found, 172 dns_rdataset_t *rdataset); 173 174 /*%< 175 * Extract the current rdataset and name from a ncache entry. 176 * 177 * Requires: 178 * \li 'ncacherdataset' to be valid and to be a negative cache entry 179 * \li 'found' to be valid. 180 * \li 'rdataset' to be unassociated. 181 */ 182 183 ISC_LANG_ENDDECLS 184 185 #endif /* DNS_NCACHE_H */ 186