1 1.1 christos /* 2 1.1 christos * iterator/iter_utils.h - iterative resolver module utility functions. 3 1.1 christos * 4 1.1 christos * Copyright (c) 2007, NLnet Labs. All rights reserved. 5 1.1 christos * 6 1.1 christos * This software is open source. 7 1.1 christos * 8 1.1 christos * Redistribution and use in source and binary forms, with or without 9 1.1 christos * modification, are permitted provided that the following conditions 10 1.1 christos * are met: 11 1.1 christos * 12 1.1 christos * Redistributions of source code must retain the above copyright notice, 13 1.1 christos * this list of conditions and the following disclaimer. 14 1.1 christos * 15 1.1 christos * Redistributions in binary form must reproduce the above copyright notice, 16 1.1 christos * this list of conditions and the following disclaimer in the documentation 17 1.1 christos * and/or other materials provided with the distribution. 18 1.1 christos * 19 1.1 christos * Neither the name of the NLNET LABS nor the names of its contributors may 20 1.1 christos * be used to endorse or promote products derived from this software without 21 1.1 christos * specific prior written permission. 22 1.1 christos * 23 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 1.1 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 1.1 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 1.1 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 1.1 christos * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 1.1 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 1.1 christos * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 1.1 christos * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 1.1 christos * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 1.1 christos * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 1.1 christos * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 1.1 christos */ 35 1.1 christos 36 1.1 christos /** 37 1.1 christos * \file 38 1.1 christos * 39 1.1 christos * This file contains functions to assist the iterator module. 40 1.1 christos * Configuration options. Forward zones. 41 1.1 christos */ 42 1.1 christos 43 1.1 christos #ifndef ITERATOR_ITER_UTILS_H 44 1.1 christos #define ITERATOR_ITER_UTILS_H 45 1.1 christos #include "iterator/iter_resptype.h" 46 1.1 christos struct sldns_buffer; 47 1.1 christos struct iter_env; 48 1.1 christos struct iter_hints; 49 1.1 christos struct iter_forwards; 50 1.1 christos struct config_file; 51 1.1 christos struct module_env; 52 1.1 christos struct delegpt_addr; 53 1.1 christos struct delegpt; 54 1.1 christos struct regional; 55 1.1 christos struct msg_parse; 56 1.1 christos struct ub_randstate; 57 1.1 christos struct query_info; 58 1.1 christos struct reply_info; 59 1.1 christos struct module_qstate; 60 1.1 christos struct sock_list; 61 1.1 christos struct ub_packed_rrset_key; 62 1.1.1.6 christos struct module_stack; 63 1.1.1.6 christos struct outside_network; 64 1.1.1.8 christos struct iter_nat64; 65 1.1.1.6 christos 66 1.1.1.6 christos /* max number of lookups in the cache for target nameserver names. 67 1.1.1.6 christos * This stops, for large delegations, N*N lookups in the cache. */ 68 1.1.1.6 christos #define ITERATOR_NAME_CACHELOOKUP_MAX 3 69 1.1.1.6 christos /* max number of lookups in the cache for parentside glue for nameserver names 70 1.1.1.6 christos * This stops, for larger delegations, N*N lookups in the cache. 71 1.1.1.6 christos * It is a little larger than the nonpside max, so it allows a couple extra 72 1.1.1.6 christos * lookups of parent side glue. */ 73 1.1.1.6 christos #define ITERATOR_NAME_CACHELOOKUP_MAX_PSIDE 5 74 1.1 christos 75 1.1 christos /** 76 1.1 christos * Process config options and set iterator module state. 77 1.1 christos * Sets default values if no config is found. 78 1.1 christos * @param iter_env: iterator module state. 79 1.1 christos * @param cfg: config options. 80 1.1 christos * @return 0 on error. 81 1.1 christos */ 82 1.1 christos int iter_apply_cfg(struct iter_env* iter_env, struct config_file* cfg); 83 1.1 christos 84 1.1 christos /** 85 1.1 christos * Select a valid, nice target to send query to. 86 1.1 christos * Sorting and removing unsuitable targets is combined. 87 1.1.1.9 christos * Adds records to the infra cache if not already there. 88 1.1 christos * 89 1.1 christos * @param iter_env: iterator module global state, with ip6 enabled and 90 1.1 christos * do-not-query-addresses. 91 1.1 christos * @param env: environment with infra cache (lameness, rtt info). 92 1.1 christos * @param dp: delegation point with result list. 93 1.1 christos * @param name: zone name (for lameness check). 94 1.1 christos * @param namelen: length of name. 95 1.1 christos * @param qtype: query type that we want to send. 96 1.1 christos * @param dnssec_lame: set to 1, if a known dnssec-lame server is selected 97 1.1 christos * these are not preferred, but are used as a last resort. 98 1.1 christos * @param chase_to_rd: set to 1 if a known recursion lame server is selected 99 1.1 christos * these are not preferred, but are used as a last resort. 100 1.1 christos * @param open_target: number of currently outstanding target queries. 101 1.1 christos * If we wait for these, perhaps more server addresses become available. 102 1.1 christos * @param blacklist: the IP blacklist to use. 103 1.1.1.3 christos * @param prefetch: if not 0, prefetch is in use for this query. 104 1.1.1.3 christos * This means the query can have different timing, because prefetch is 105 1.1.1.3 christos * not waited upon by the downstream client, and thus a good time to 106 1.1.1.3 christos * perform exploration of other targets. 107 1.1 christos * @return best target or NULL if no target. 108 1.1 christos * if not null, that target is removed from the result list in the dp. 109 1.1 christos */ 110 1.1 christos struct delegpt_addr* iter_server_selection(struct iter_env* iter_env, 111 1.1 christos struct module_env* env, struct delegpt* dp, uint8_t* name, 112 1.1 christos size_t namelen, uint16_t qtype, int* dnssec_lame, 113 1.1.1.3 christos int* chase_to_rd, int open_target, struct sock_list* blacklist, 114 1.1.1.3 christos time_t prefetch); 115 1.1 christos 116 1.1 christos /** 117 1.1 christos * Allocate dns_msg from parsed msg, in regional. 118 1.1 christos * @param pkt: packet. 119 1.1 christos * @param msg: parsed message (cleaned and ready for regional allocation). 120 1.1 christos * @param regional: regional to use for allocation. 121 1.1 christos * @return newly allocated dns_msg, or NULL on memory error. 122 1.1 christos */ 123 1.1 christos struct dns_msg* dns_alloc_msg(struct sldns_buffer* pkt, struct msg_parse* msg, 124 1.1 christos struct regional* regional); 125 1.1 christos 126 1.1 christos /** 127 1.1 christos * Copy a dns_msg to this regional. 128 1.1 christos * @param from: dns message, also in regional. 129 1.1 christos * @param regional: regional to use for allocation. 130 1.1 christos * @return newly allocated dns_msg, or NULL on memory error. 131 1.1 christos */ 132 1.1 christos struct dns_msg* dns_copy_msg(struct dns_msg* from, struct regional* regional); 133 1.1 christos 134 1.1 christos /** 135 1.1 christos * Allocate a dns_msg with malloc/alloc structure and store in dns cache. 136 1.1 christos * @param env: environment, with alloc structure and dns cache. 137 1.1 christos * @param qinf: query info, the query for which answer is stored. 138 1.1 christos * @param rep: reply in dns_msg from dns_alloc_msg for example. 139 1.1 christos * @param is_referral: If true, then the given message to be stored is a 140 1.1 christos * referral. The cache implementation may use this as a hint. 141 1.1 christos * @param leeway: prefetch TTL leeway to expire old rrsets quicker. 142 1.1 christos * @param pside: true if dp is parentside, thus message is 'fresh' and NS 143 1.1 christos * can be prefetch-updates. 144 1.1 christos * @param region: to copy modified (cache is better) rrs back to. 145 1.1 christos * @param flags: with BIT_CD for dns64 AAAA translated queries. 146 1.1.1.6 christos * @param qstarttime: time of query start. 147 1.1.1.8 christos * @param is_valrec: if the query is validation recursion and does not get 148 1.1.1.6 christos * return void, because we are not interested in alloc errors, 149 1.1 christos * the iterator and validator can operate on the results in their 150 1.1 christos * scratch space (the qstate.region) and are not dependent on the cache. 151 1.1 christos * It is useful to log the alloc failure (for the server operator), 152 1.1 christos * but the query resolution can continue without cache storage. 153 1.1 christos */ 154 1.1 christos void iter_dns_store(struct module_env* env, struct query_info* qinf, 155 1.1 christos struct reply_info* rep, int is_referral, time_t leeway, int pside, 156 1.1.1.8 christos struct regional* region, uint16_t flags, time_t qstarttime, 157 1.1.1.8 christos int is_valrec); 158 1.1 christos 159 1.1 christos /** 160 1.1 christos * Select randomly with n/m probability. 161 1.1 christos * For shuffle NS records for address fetching. 162 1.1 christos * @param rnd: random table 163 1.1 christos * @param n: probability. 164 1.1 christos * @param m: divisor for probability. 165 1.1 christos * @return true with n/m probability. 166 1.1 christos */ 167 1.1 christos int iter_ns_probability(struct ub_randstate* rnd, int n, int m); 168 1.1 christos 169 1.1 christos /** 170 1.1 christos * Mark targets that result in a dependency cycle as done, so they 171 1.1 christos * will not get selected as targets. 172 1.1 christos * @param qstate: query state. 173 1.1 christos * @param dp: delegpt to mark ns in. 174 1.1 christos */ 175 1.1 christos void iter_mark_cycle_targets(struct module_qstate* qstate, struct delegpt* dp); 176 1.1 christos 177 1.1 christos /** 178 1.1 christos * Mark targets that result in a dependency cycle as done, so they 179 1.1 christos * will not get selected as targets. For the parent-side lookups. 180 1.1 christos * @param qstate: query state. 181 1.1 christos * @param dp: delegpt to mark ns in. 182 1.1 christos */ 183 1.1 christos void iter_mark_pside_cycle_targets(struct module_qstate* qstate, 184 1.1 christos struct delegpt* dp); 185 1.1 christos 186 1.1 christos /** 187 1.1 christos * See if delegation is useful or offers immediately no targets for 188 1.1 christos * further recursion. 189 1.1 christos * @param qinfo: query name and type 190 1.1 christos * @param qflags: query flags with RD flag 191 1.1 christos * @param dp: delegpt to check. 192 1.1.1.6 christos * @param supports_ipv4: if we support ipv4 for lookups to the target. 193 1.1.1.6 christos * if not, then the IPv4 addresses are useless. 194 1.1.1.6 christos * @param supports_ipv6: if we support ipv6 for lookups to the target. 195 1.1.1.6 christos * if not, then the IPv6 addresses are useless. 196 1.1.1.7 christos * @param use_nat64: if we support NAT64 for lookups to the target. 197 1.1.1.7 christos * if yes, IPv4 addresses are useful even if we don't support IPv4. 198 1.1 christos * @return true if dp is useless. 199 1.1 christos */ 200 1.1.1.7 christos int iter_dp_is_useless(struct query_info* qinfo, uint16_t qflags, 201 1.1.1.7 christos struct delegpt* dp, int supports_ipv4, int supports_ipv6, 202 1.1.1.7 christos int use_nat64); 203 1.1 christos 204 1.1 christos /** 205 1.1.1.3 christos * See if qname has DNSSEC needs. This is true if there is a trust anchor above 206 1.1.1.3 christos * it. Whether there is an insecure delegation to the data is unknown. 207 1.1 christos * @param env: environment with anchors. 208 1.1 christos * @param qinfo: query name and class. 209 1.1 christos * @return true if trust anchor above qname, false if no anchor or insecure 210 1.1 christos * point above qname. 211 1.1 christos */ 212 1.1.1.3 christos int iter_qname_indicates_dnssec(struct module_env* env, 213 1.1 christos struct query_info *qinfo); 214 1.1 christos 215 1.1 christos /** 216 1.1 christos * See if delegation is expected to have DNSSEC information (RRSIGs) in 217 1.1 christos * its answers, or not. Inspects delegation point (name), trust anchors, 218 1.1 christos * and delegation message (DS RRset) to determine this. 219 1.1 christos * @param env: module env with trust anchors. 220 1.1 christos * @param dp: delegation point. 221 1.1 christos * @param msg: delegation message, with DS if a secure referral. 222 1.1 christos * @param dclass: class of query. 223 1.1.1.3 christos * @return 1 if dnssec is expected, 0 if not or insecure point above qname. 224 1.1 christos */ 225 1.1 christos int iter_indicates_dnssec(struct module_env* env, struct delegpt* dp, 226 1.1 christos struct dns_msg* msg, uint16_t dclass); 227 1.1 christos 228 1.1 christos /** 229 1.1 christos * See if a message contains DNSSEC. 230 1.1 christos * This is examined by looking for RRSIGs. With DNSSEC a valid answer, 231 1.1 christos * nxdomain, nodata, referral or cname reply has RRSIGs in answer or auth 232 1.1 christos * sections, sigs on answer data, SOA, DS, or NSEC/NSEC3 records. 233 1.1 christos * @param msg: message to examine. 234 1.1 christos * @return true if DNSSEC information was found. 235 1.1 christos */ 236 1.1 christos int iter_msg_has_dnssec(struct dns_msg* msg); 237 1.1 christos 238 1.1 christos /** 239 1.1 christos * See if a message is known to be from a certain zone. 240 1.1 christos * This looks for SOA or NS rrsets, for answers. 241 1.1 christos * For referrals, when one label is delegated, the zone is detected. 242 1.1 christos * Does not look at signatures. 243 1.1 christos * @param msg: the message to inspect. 244 1.1 christos * @param dp: delegation point with zone name to look for. 245 1.1 christos * @param type: type of message. 246 1.1 christos * @param dclass: class of query. 247 1.1 christos * @return true if message is certain to be from zone in dp->name. 248 1.1 christos * false if not sure (empty msg), or not from the zone. 249 1.1 christos */ 250 1.1 christos int iter_msg_from_zone(struct dns_msg* msg, struct delegpt* dp, 251 1.1 christos enum response_type type, uint16_t dclass); 252 1.1 christos 253 1.1 christos /** 254 1.1 christos * Check if two replies are equal 255 1.1 christos * For fallback procedures 256 1.1 christos * @param p: reply one. The reply has rrset data pointers in region. 257 1.1 christos * Does not check rrset-IDs 258 1.1 christos * @param q: reply two 259 1.1 christos * @param region: scratch buffer. 260 1.1 christos * @return if one and two are equal. 261 1.1 christos */ 262 1.1 christos int reply_equal(struct reply_info* p, struct reply_info* q, struct regional* region); 263 1.1 christos 264 1.1 christos /** 265 1.1 christos * Remove unused bits from the reply if possible. 266 1.1 christos * So that caps-for-id (0x20) fallback is more likely to be successful. 267 1.1 christos * This removes like, the additional section, and NS record in the authority 268 1.1 christos * section if those records are gratuitous (not for a referral). 269 1.1 christos * @param rep: the reply to strip stuff out of. 270 1.1 christos */ 271 1.1 christos void caps_strip_reply(struct reply_info* rep); 272 1.1 christos 273 1.1 christos /** 274 1.1 christos * see if reply has a 'useful' rcode for capsforid comparison, so 275 1.1 christos * not SERVFAIL or REFUSED, and thus NOERROR or NXDOMAIN. 276 1.1 christos * @param rep: reply to check. 277 1.1 christos * @return true if the rcode is a bad type of message. 278 1.1 christos */ 279 1.1 christos int caps_failed_rcode(struct reply_info* rep); 280 1.1 christos 281 1.1 christos /** 282 1.1.1.2 christos * Store parent-side rrset in separate rrset cache entries for later 283 1.1 christos * last-resort * lookups in case the child-side versions of this information 284 1.1 christos * fails. 285 1.1 christos * @param env: environment with cache, time, ... 286 1.1 christos * @param rrset: the rrset to store (copied). 287 1.1 christos * Failure to store is logged, but otherwise ignored. 288 1.1 christos */ 289 1.1 christos void iter_store_parentside_rrset(struct module_env* env, 290 1.1 christos struct ub_packed_rrset_key* rrset); 291 1.1 christos 292 1.1 christos /** 293 1.1 christos * Store parent-side NS records from a referral message 294 1.1 christos * @param env: environment with cache, time, ... 295 1.1 christos * @param rep: response with NS rrset. 296 1.1 christos * Failure to store is logged, but otherwise ignored. 297 1.1 christos */ 298 1.1 christos void iter_store_parentside_NS(struct module_env* env, struct reply_info* rep); 299 1.1 christos 300 1.1 christos /** 301 1.1 christos * Store parent-side negative element, the parentside rrset does not exist, 302 1.1 christos * creates an rrset with empty rdata in the rrset cache with PARENTSIDE flag. 303 1.1 christos * @param env: environment with cache, time, ... 304 1.1 christos * @param qinfo: the identity of the rrset that is missing. 305 1.1 christos * @param rep: delegation response or answer response, to glean TTL from. 306 1.1 christos * (malloc) failure is logged but otherwise ignored. 307 1.1 christos */ 308 1.1 christos void iter_store_parentside_neg(struct module_env* env, 309 1.1 christos struct query_info* qinfo, struct reply_info* rep); 310 1.1 christos 311 1.1 christos /** 312 1.1 christos * Add parent NS record if that exists in the cache. This is both new 313 1.1 christos * information and acts like a timeout throttle on retries. 314 1.1 christos * @param env: query env with rrset cache and time. 315 1.1 christos * @param dp: delegation point to store result in. Also this dp is used to 316 1.1 christos * see which NS name is needed. 317 1.1 christos * @param region: region to alloc result in. 318 1.1 christos * @param qinfo: pertinent information, the qclass. 319 1.1 christos * @return false on malloc failure. 320 1.1 christos * if true, the routine worked and if such cached information 321 1.1 christos * existed dp->has_parent_side_NS is set true. 322 1.1 christos */ 323 1.1 christos int iter_lookup_parent_NS_from_cache(struct module_env* env, 324 1.1 christos struct delegpt* dp, struct regional* region, struct query_info* qinfo); 325 1.1 christos 326 1.1 christos /** 327 1.1 christos * Add parent-side glue if that exists in the cache. This is both new 328 1.1 christos * information and acts like a timeout throttle on retries to fetch them. 329 1.1 christos * @param env: query env with rrset cache and time. 330 1.1 christos * @param dp: delegation point to store result in. Also this dp is used to 331 1.1 christos * see which NS name is needed. 332 1.1 christos * @param region: region to alloc result in. 333 1.1 christos * @param qinfo: pertinent information, the qclass. 334 1.1 christos * @return: true, it worked, no malloc failures, and new addresses (lame) 335 1.1 christos * have been added, giving extra options as query targets. 336 1.1 christos */ 337 1.1 christos int iter_lookup_parent_glue_from_cache(struct module_env* env, 338 1.1 christos struct delegpt* dp, struct regional* region, struct query_info* qinfo); 339 1.1 christos 340 1.1 christos /** 341 1.1 christos * Lookup next root-hint or root-forward entry. 342 1.1 christos * @param hints: the hints. 343 1.1 christos * @param fwd: the forwards. 344 1.1 christos * @param c: the class to start searching at. 0 means find first one. 345 1.1 christos * @return false if no classes found, true if found and returned in c. 346 1.1 christos */ 347 1.1 christos int iter_get_next_root(struct iter_hints* hints, struct iter_forwards* fwd, 348 1.1 christos uint16_t* c); 349 1.1 christos 350 1.1 christos /** 351 1.1 christos * Remove DS records that are inappropriate before they are cached. 352 1.1 christos * @param msg: the response to scrub. 353 1.1 christos * @param ns: RRSET that is the NS record for the referral. 354 1.1 christos * if NULL, then all DS records are removed from the authority section. 355 1.1 christos * @param z: zone name that the response is from. 356 1.1 christos */ 357 1.1 christos void iter_scrub_ds(struct dns_msg* msg, struct ub_packed_rrset_key* ns, 358 1.1 christos uint8_t* z); 359 1.1 christos 360 1.1 christos /** 361 1.1.1.5 christos * Prepare an NXDOMAIN message to be used for a subdomain answer by removing all 362 1.1.1.5 christos * RRs from the ANSWER section. 363 1.1.1.5 christos * @param msg: the response to scrub. 364 1.1.1.5 christos */ 365 1.1.1.5 christos void iter_scrub_nxdomain(struct dns_msg* msg); 366 1.1.1.5 christos 367 1.1.1.5 christos /** 368 1.1 christos * Remove query attempts from all available ips. For 0x20. 369 1.1 christos * @param dp: delegpt. 370 1.1 christos * @param d: decrease. 371 1.1.1.6 christos * @param outbound_msg_retry: number of retries of outgoing queries 372 1.1 christos */ 373 1.1.1.6 christos void iter_dec_attempts(struct delegpt* dp, int d, int outbound_msg_retry); 374 1.1 christos 375 1.1 christos /** 376 1.1 christos * Add retry counts from older delegpt to newer delegpt. 377 1.1 christos * Does not waste time on timeout'd (or other failing) addresses. 378 1.1 christos * @param dp: new delegationpoint. 379 1.1 christos * @param old: old delegationpoint. 380 1.1.1.6 christos * @param outbound_msg_retry: number of retries of outgoing queries 381 1.1 christos */ 382 1.1.1.6 christos void iter_merge_retry_counts(struct delegpt* dp, struct delegpt* old, 383 1.1.1.6 christos int outbound_msg_retry); 384 1.1 christos 385 1.1 christos /** 386 1.1 christos * See if a DS response (type ANSWER) is too low: a nodata answer with 387 1.1 christos * a SOA record in the authority section at-or-below the qchase.qname. 388 1.1 christos * Also returns true if we are not sure (i.e. empty message, CNAME nosig). 389 1.1 christos * @param msg: the response. 390 1.1 christos * @param dp: the dp name is used to check if the RRSIG gives a clue that 391 1.1 christos * it was originated from the correct nameserver. 392 1.1 christos * @return true if too low. 393 1.1 christos */ 394 1.1 christos int iter_ds_toolow(struct dns_msg* msg, struct delegpt* dp); 395 1.1 christos 396 1.1 christos /** 397 1.1 christos * See if delegpt can go down a step to the qname or not 398 1.1 christos * @param qinfo: the query name looked up. 399 1.1 christos * @param dp: checked if the name can go lower to the qname 400 1.1 christos * @return true if can go down, false if that would not be possible. 401 1.1 christos * the current response seems to be the one and only, best possible, response. 402 1.1 christos */ 403 1.1 christos int iter_dp_cangodown(struct query_info* qinfo, struct delegpt* dp); 404 1.1 christos 405 1.1.1.4 christos /** 406 1.1.1.4 christos * Lookup if no_cache is set in stub or fwd. 407 1.1.1.4 christos * @param qstate: query state with env with hints and fwds. 408 1.1.1.4 christos * @param qinf: query name to lookup for. 409 1.1.1.6 christos * @param retdpname: returns NULL or the deepest enclosing name of fwd or stub. 410 1.1.1.6 christos * This is the name under which the closest lookup is going to happen. 411 1.1.1.6 christos * Used for NXDOMAIN checks, above that it is an nxdomain from a 412 1.1.1.6 christos * different server and zone. You can pass NULL to not get it. 413 1.1.1.6 christos * @param retdpnamelen: returns the length of the dpname. 414 1.1.1.8 christos * @param dpname_storage: this is where the dpname buf is stored, if any. 415 1.1.1.8 christos * So that caller can manage the buffer. 416 1.1.1.8 christos * @param dpname_storage_len: size of dpname_storage buffer. 417 1.1.1.4 christos * @return true if no_cache is set in stub or fwd. 418 1.1.1.4 christos */ 419 1.1.1.4 christos int iter_stub_fwd_no_cache(struct module_qstate *qstate, 420 1.1.1.8 christos struct query_info *qinf, uint8_t** retdpname, size_t* retdpnamelen, 421 1.1.1.8 christos uint8_t* dpname_storage, size_t dpname_storage_len); 422 1.1.1.6 christos 423 1.1.1.6 christos /** 424 1.1.1.6 christos * Set support for IP4 and IP6 depending on outgoing interfaces 425 1.1.1.6 christos * in the outside network. If none, no support, so no use to lookup 426 1.1.1.6 christos * the AAAA and then attempt to use it if there is no outgoing-interface 427 1.1.1.6 christos * for it. 428 1.1.1.6 christos * @param mods: modstack to find iterator module in. 429 1.1.1.6 christos * @param env: module env, find iterator module (if one) in there. 430 1.1.1.6 christos * @param outnet: outside network structure. 431 1.1.1.6 christos */ 432 1.1.1.6 christos void iterator_set_ip46_support(struct module_stack* mods, 433 1.1.1.6 christos struct module_env* env, struct outside_network* outnet); 434 1.1.1.4 christos 435 1.1.1.8 christos /** 436 1.1.1.8 christos * Read config string that represents the target fetch policy. 437 1.1.1.8 christos * @param target_fetch_policy: alloced on return. 438 1.1.1.8 christos * @param max_dependency_depth: set on return. 439 1.1.1.8 christos * @param str: the config string 440 1.1.1.8 christos * @return false on failure. 441 1.1.1.8 christos */ 442 1.1.1.8 christos int read_fetch_policy(int** target_fetch_policy, int* max_dependency_depth, 443 1.1.1.8 christos const char* str); 444 1.1.1.8 christos 445 1.1.1.8 christos /** 446 1.1.1.8 christos * Create caps exempt data structure. 447 1.1.1.8 christos * @return NULL on failure. 448 1.1.1.8 christos */ 449 1.1.1.8 christos struct rbtree_type* caps_white_create(void); 450 1.1.1.8 christos 451 1.1.1.8 christos /** 452 1.1.1.8 christos * Delete caps exempt data structure. 453 1.1.1.8 christos * @param caps_white: caps exempt tree. 454 1.1.1.8 christos */ 455 1.1.1.8 christos void caps_white_delete(struct rbtree_type* caps_white); 456 1.1.1.8 christos 457 1.1.1.8 christos /** 458 1.1.1.8 christos * Apply config caps whitelist items to name tree 459 1.1.1.8 christos * @param ntree: caps exempt tree. 460 1.1.1.8 christos * @param cfg: config with options. 461 1.1.1.8 christos */ 462 1.1.1.8 christos int caps_white_apply_cfg(struct rbtree_type* ntree, struct config_file* cfg); 463 1.1.1.8 christos 464 1.1.1.8 christos /** 465 1.1.1.8 christos * Apply config for nat64 466 1.1.1.8 christos * @param nat64: the nat64 state. 467 1.1.1.8 christos * @param cfg: config with options. 468 1.1.1.8 christos * @return false on failure. 469 1.1.1.8 christos */ 470 1.1.1.8 christos int nat64_apply_cfg(struct iter_nat64* nat64, struct config_file* cfg); 471 1.1.1.8 christos 472 1.1.1.8 christos /** 473 1.1.1.8 christos * Limit NSEC and NSEC3 TTL in response, RFC9077 474 1.1.1.8 christos * @param msg: dns message, the SOA record ttl is used to restrict ttls 475 1.1.1.8 christos * of NSEC and NSEC3 RRsets. If no SOA record, nothing happens. 476 1.1.1.8 christos */ 477 1.1.1.8 christos void limit_nsec_ttl(struct dns_msg* msg); 478 1.1.1.8 christos 479 1.1.1.8 christos /** 480 1.1.1.8 christos * Make the response minimal. Removed authority and additional section, 481 1.1.1.8 christos * that works when there is an answer in the answer section. 482 1.1.1.8 christos * @param rep: reply to modify. 483 1.1.1.8 christos */ 484 1.1.1.8 christos void iter_make_minimal(struct reply_info* rep); 485 1.1.1.8 christos 486 1.1 christos #endif /* ITERATOR_ITER_UTILS_H */ 487