1933707f3Ssthen /* 2933707f3Ssthen * iterator/iter_utils.h - iterative resolver module utility functions. 3933707f3Ssthen * 4933707f3Ssthen * Copyright (c) 2007, NLnet Labs. All rights reserved. 5933707f3Ssthen * 6933707f3Ssthen * This software is open source. 7933707f3Ssthen * 8933707f3Ssthen * Redistribution and use in source and binary forms, with or without 9933707f3Ssthen * modification, are permitted provided that the following conditions 10933707f3Ssthen * are met: 11933707f3Ssthen * 12933707f3Ssthen * Redistributions of source code must retain the above copyright notice, 13933707f3Ssthen * this list of conditions and the following disclaimer. 14933707f3Ssthen * 15933707f3Ssthen * Redistributions in binary form must reproduce the above copyright notice, 16933707f3Ssthen * this list of conditions and the following disclaimer in the documentation 17933707f3Ssthen * and/or other materials provided with the distribution. 18933707f3Ssthen * 19933707f3Ssthen * Neither the name of the NLNET LABS nor the names of its contributors may 20933707f3Ssthen * be used to endorse or promote products derived from this software without 21933707f3Ssthen * specific prior written permission. 22933707f3Ssthen * 23933707f3Ssthen * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 245d76a658Ssthen * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 255d76a658Ssthen * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 265d76a658Ssthen * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 275d76a658Ssthen * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 285d76a658Ssthen * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 295d76a658Ssthen * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 305d76a658Ssthen * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 315d76a658Ssthen * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 325d76a658Ssthen * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 335d76a658Ssthen * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34933707f3Ssthen */ 35933707f3Ssthen 36933707f3Ssthen /** 37933707f3Ssthen * \file 38933707f3Ssthen * 39933707f3Ssthen * This file contains functions to assist the iterator module. 40933707f3Ssthen * Configuration options. Forward zones. 41933707f3Ssthen */ 42933707f3Ssthen 43933707f3Ssthen #ifndef ITERATOR_ITER_UTILS_H 44933707f3Ssthen #define ITERATOR_ITER_UTILS_H 45933707f3Ssthen #include "iterator/iter_resptype.h" 465d76a658Ssthen struct sldns_buffer; 47933707f3Ssthen struct iter_env; 48933707f3Ssthen struct iter_hints; 49933707f3Ssthen struct iter_forwards; 50933707f3Ssthen struct config_file; 51933707f3Ssthen struct module_env; 52933707f3Ssthen struct delegpt_addr; 53933707f3Ssthen struct delegpt; 54933707f3Ssthen struct regional; 55933707f3Ssthen struct msg_parse; 56933707f3Ssthen struct ub_randstate; 57933707f3Ssthen struct query_info; 58933707f3Ssthen struct reply_info; 59933707f3Ssthen struct module_qstate; 60933707f3Ssthen struct sock_list; 61933707f3Ssthen struct ub_packed_rrset_key; 62191f22c6Ssthen struct module_stack; 63191f22c6Ssthen struct outside_network; 64933707f3Ssthen 657dd170e2Ssthen /* max number of lookups in the cache for target nameserver names. 667dd170e2Ssthen * This stops, for large delegations, N*N lookups in the cache. */ 677dd170e2Ssthen #define ITERATOR_NAME_CACHELOOKUP_MAX 3 687dd170e2Ssthen /* max number of lookups in the cache for parentside glue for nameserver names 697dd170e2Ssthen * This stops, for larger delegations, N*N lookups in the cache. 707dd170e2Ssthen * It is a little larger than the nonpside max, so it allows a couple extra 717dd170e2Ssthen * lookups of parent side glue. */ 727dd170e2Ssthen #define ITERATOR_NAME_CACHELOOKUP_MAX_PSIDE 5 737dd170e2Ssthen 74933707f3Ssthen /** 75933707f3Ssthen * Process config options and set iterator module state. 76933707f3Ssthen * Sets default values if no config is found. 77933707f3Ssthen * @param iter_env: iterator module state. 78933707f3Ssthen * @param cfg: config options. 79933707f3Ssthen * @return 0 on error. 80933707f3Ssthen */ 81933707f3Ssthen int iter_apply_cfg(struct iter_env* iter_env, struct config_file* cfg); 82933707f3Ssthen 83933707f3Ssthen /** 84933707f3Ssthen * Select a valid, nice target to send query to. 85933707f3Ssthen * Sorting and removing unsuitable targets is combined. 86933707f3Ssthen * 87933707f3Ssthen * @param iter_env: iterator module global state, with ip6 enabled and 88933707f3Ssthen * do-not-query-addresses. 89933707f3Ssthen * @param env: environment with infra cache (lameness, rtt info). 90933707f3Ssthen * @param dp: delegation point with result list. 91933707f3Ssthen * @param name: zone name (for lameness check). 92933707f3Ssthen * @param namelen: length of name. 93933707f3Ssthen * @param qtype: query type that we want to send. 94933707f3Ssthen * @param dnssec_lame: set to 1, if a known dnssec-lame server is selected 95933707f3Ssthen * these are not preferred, but are used as a last resort. 96933707f3Ssthen * @param chase_to_rd: set to 1 if a known recursion lame server is selected 97933707f3Ssthen * these are not preferred, but are used as a last resort. 98933707f3Ssthen * @param open_target: number of currently outstanding target queries. 99933707f3Ssthen * If we wait for these, perhaps more server addresses become available. 100933707f3Ssthen * @param blacklist: the IP blacklist to use. 10120237c55Ssthen * @param prefetch: if not 0, prefetch is in use for this query. 10220237c55Ssthen * This means the query can have different timing, because prefetch is 10320237c55Ssthen * not waited upon by the downstream client, and thus a good time to 10420237c55Ssthen * perform exploration of other targets. 105933707f3Ssthen * @return best target or NULL if no target. 106933707f3Ssthen * if not null, that target is removed from the result list in the dp. 107933707f3Ssthen */ 108933707f3Ssthen struct delegpt_addr* iter_server_selection(struct iter_env* iter_env, 109933707f3Ssthen struct module_env* env, struct delegpt* dp, uint8_t* name, 110933707f3Ssthen size_t namelen, uint16_t qtype, int* dnssec_lame, 11120237c55Ssthen int* chase_to_rd, int open_target, struct sock_list* blacklist, 11220237c55Ssthen time_t prefetch); 113933707f3Ssthen 114933707f3Ssthen /** 115933707f3Ssthen * Allocate dns_msg from parsed msg, in regional. 116933707f3Ssthen * @param pkt: packet. 117933707f3Ssthen * @param msg: parsed message (cleaned and ready for regional allocation). 118933707f3Ssthen * @param regional: regional to use for allocation. 119933707f3Ssthen * @return newly allocated dns_msg, or NULL on memory error. 120933707f3Ssthen */ 1215d76a658Ssthen struct dns_msg* dns_alloc_msg(struct sldns_buffer* pkt, struct msg_parse* msg, 122933707f3Ssthen struct regional* regional); 123933707f3Ssthen 124933707f3Ssthen /** 125933707f3Ssthen * Copy a dns_msg to this regional. 126933707f3Ssthen * @param from: dns message, also in regional. 127933707f3Ssthen * @param regional: regional to use for allocation. 128933707f3Ssthen * @return newly allocated dns_msg, or NULL on memory error. 129933707f3Ssthen */ 130933707f3Ssthen struct dns_msg* dns_copy_msg(struct dns_msg* from, struct regional* regional); 131933707f3Ssthen 132933707f3Ssthen /** 133933707f3Ssthen * Allocate a dns_msg with malloc/alloc structure and store in dns cache. 134933707f3Ssthen * @param env: environment, with alloc structure and dns cache. 135933707f3Ssthen * @param qinf: query info, the query for which answer is stored. 136933707f3Ssthen * @param rep: reply in dns_msg from dns_alloc_msg for example. 137933707f3Ssthen * @param is_referral: If true, then the given message to be stored is a 138933707f3Ssthen * referral. The cache implementation may use this as a hint. 139933707f3Ssthen * @param leeway: prefetch TTL leeway to expire old rrsets quicker. 140d8d14d0cSsthen * @param pside: true if dp is parentside, thus message is 'fresh' and NS 141d8d14d0cSsthen * can be prefetch-updates. 142933707f3Ssthen * @param region: to copy modified (cache is better) rrs back to. 14357dceb2aSbrad * @param flags: with BIT_CD for dns64 AAAA translated queries. 144d1e2768aSsthen * @param qstarttime: time of query start. 145191f22c6Ssthen * return void, because we are not interested in alloc errors, 1463dcb24b8Ssthen * the iterator and validator can operate on the results in their 1473dcb24b8Ssthen * scratch space (the qstate.region) and are not dependent on the cache. 1483dcb24b8Ssthen * It is useful to log the alloc failure (for the server operator), 1493dcb24b8Ssthen * but the query resolution can continue without cache storage. 150933707f3Ssthen */ 1513dcb24b8Ssthen void iter_dns_store(struct module_env* env, struct query_info* qinf, 152229e174cSsthen struct reply_info* rep, int is_referral, time_t leeway, int pside, 153d1e2768aSsthen struct regional* region, uint16_t flags, time_t qstarttime); 154933707f3Ssthen 155933707f3Ssthen /** 156933707f3Ssthen * Select randomly with n/m probability. 157933707f3Ssthen * For shuffle NS records for address fetching. 158933707f3Ssthen * @param rnd: random table 159933707f3Ssthen * @param n: probability. 160933707f3Ssthen * @param m: divisor for probability. 161933707f3Ssthen * @return true with n/m probability. 162933707f3Ssthen */ 163933707f3Ssthen int iter_ns_probability(struct ub_randstate* rnd, int n, int m); 164933707f3Ssthen 165933707f3Ssthen /** 166933707f3Ssthen * Mark targets that result in a dependency cycle as done, so they 167933707f3Ssthen * will not get selected as targets. 168933707f3Ssthen * @param qstate: query state. 169933707f3Ssthen * @param dp: delegpt to mark ns in. 170933707f3Ssthen */ 171933707f3Ssthen void iter_mark_cycle_targets(struct module_qstate* qstate, struct delegpt* dp); 172933707f3Ssthen 173933707f3Ssthen /** 174933707f3Ssthen * Mark targets that result in a dependency cycle as done, so they 175933707f3Ssthen * will not get selected as targets. For the parent-side lookups. 176933707f3Ssthen * @param qstate: query state. 177933707f3Ssthen * @param dp: delegpt to mark ns in. 178933707f3Ssthen */ 179933707f3Ssthen void iter_mark_pside_cycle_targets(struct module_qstate* qstate, 180933707f3Ssthen struct delegpt* dp); 181933707f3Ssthen 182933707f3Ssthen /** 183933707f3Ssthen * See if delegation is useful or offers immediately no targets for 184933707f3Ssthen * further recursion. 185933707f3Ssthen * @param qinfo: query name and type 186933707f3Ssthen * @param qflags: query flags with RD flag 187933707f3Ssthen * @param dp: delegpt to check. 1880bdb4f62Ssthen * @param supports_ipv4: if we support ipv4 for lookups to the target. 1890bdb4f62Ssthen * if not, then the IPv4 addresses are useless. 1900bdb4f62Ssthen * @param supports_ipv6: if we support ipv6 for lookups to the target. 1910bdb4f62Ssthen * if not, then the IPv6 addresses are useless. 1928b7325afSsthen * @param use_nat64: if we support NAT64 for lookups to the target. 1938b7325afSsthen * if yes, IPv4 addresses are useful even if we don't support IPv4. 194933707f3Ssthen * @return true if dp is useless. 195933707f3Ssthen */ 196933707f3Ssthen int iter_dp_is_useless(struct query_info* qinfo, uint16_t qflags, 1978b7325afSsthen struct delegpt* dp, int supports_ipv4, int supports_ipv6, 1988b7325afSsthen int use_nat64); 199933707f3Ssthen 200933707f3Ssthen /** 20120237c55Ssthen * See if qname has DNSSEC needs. This is true if there is a trust anchor above 20220237c55Ssthen * it. Whether there is an insecure delegation to the data is unknown. 2032ee382b6Ssthen * @param env: environment with anchors. 2042ee382b6Ssthen * @param qinfo: query name and class. 2052ee382b6Ssthen * @return true if trust anchor above qname, false if no anchor or insecure 2062ee382b6Ssthen * point above qname. 2072ee382b6Ssthen */ 20820237c55Ssthen int iter_qname_indicates_dnssec(struct module_env* env, 2092ee382b6Ssthen struct query_info *qinfo); 2102ee382b6Ssthen 2112ee382b6Ssthen /** 212933707f3Ssthen * See if delegation is expected to have DNSSEC information (RRSIGs) in 213933707f3Ssthen * its answers, or not. Inspects delegation point (name), trust anchors, 214933707f3Ssthen * and delegation message (DS RRset) to determine this. 215933707f3Ssthen * @param env: module env with trust anchors. 216933707f3Ssthen * @param dp: delegation point. 217933707f3Ssthen * @param msg: delegation message, with DS if a secure referral. 218933707f3Ssthen * @param dclass: class of query. 219bdfc4d55Sflorian * @return 1 if dnssec is expected, 0 if not or insecure point above qname. 220933707f3Ssthen */ 221933707f3Ssthen int iter_indicates_dnssec(struct module_env* env, struct delegpt* dp, 222933707f3Ssthen struct dns_msg* msg, uint16_t dclass); 223933707f3Ssthen 224933707f3Ssthen /** 225933707f3Ssthen * See if a message contains DNSSEC. 226933707f3Ssthen * This is examined by looking for RRSIGs. With DNSSEC a valid answer, 227933707f3Ssthen * nxdomain, nodata, referral or cname reply has RRSIGs in answer or auth 228933707f3Ssthen * sections, sigs on answer data, SOA, DS, or NSEC/NSEC3 records. 229933707f3Ssthen * @param msg: message to examine. 230933707f3Ssthen * @return true if DNSSEC information was found. 231933707f3Ssthen */ 232933707f3Ssthen int iter_msg_has_dnssec(struct dns_msg* msg); 233933707f3Ssthen 234933707f3Ssthen /** 235933707f3Ssthen * See if a message is known to be from a certain zone. 236933707f3Ssthen * This looks for SOA or NS rrsets, for answers. 237933707f3Ssthen * For referrals, when one label is delegated, the zone is detected. 238933707f3Ssthen * Does not look at signatures. 239933707f3Ssthen * @param msg: the message to inspect. 240933707f3Ssthen * @param dp: delegation point with zone name to look for. 241933707f3Ssthen * @param type: type of message. 242933707f3Ssthen * @param dclass: class of query. 243933707f3Ssthen * @return true if message is certain to be from zone in dp->name. 244933707f3Ssthen * false if not sure (empty msg), or not from the zone. 245933707f3Ssthen */ 246933707f3Ssthen int iter_msg_from_zone(struct dns_msg* msg, struct delegpt* dp, 247933707f3Ssthen enum response_type type, uint16_t dclass); 248933707f3Ssthen 249933707f3Ssthen /** 250933707f3Ssthen * Check if two replies are equal 251933707f3Ssthen * For fallback procedures 252933707f3Ssthen * @param p: reply one. The reply has rrset data pointers in region. 253933707f3Ssthen * Does not check rrset-IDs 254933707f3Ssthen * @param q: reply two 2555d76a658Ssthen * @param region: scratch buffer. 256933707f3Ssthen * @return if one and two are equal. 257933707f3Ssthen */ 2585d76a658Ssthen int reply_equal(struct reply_info* p, struct reply_info* q, struct regional* region); 259933707f3Ssthen 260933707f3Ssthen /** 26135fa0a9cSbrad * Remove unused bits from the reply if possible. 26235fa0a9cSbrad * So that caps-for-id (0x20) fallback is more likely to be successful. 26335fa0a9cSbrad * This removes like, the additional section, and NS record in the authority 26435fa0a9cSbrad * section if those records are gratuitous (not for a referral). 26535fa0a9cSbrad * @param rep: the reply to strip stuff out of. 26635fa0a9cSbrad */ 26735fa0a9cSbrad void caps_strip_reply(struct reply_info* rep); 26835fa0a9cSbrad 26935fa0a9cSbrad /** 270a58bff56Ssthen * see if reply has a 'useful' rcode for capsforid comparison, so 271a58bff56Ssthen * not SERVFAIL or REFUSED, and thus NOERROR or NXDOMAIN. 272a58bff56Ssthen * @param rep: reply to check. 273a58bff56Ssthen * @return true if the rcode is a bad type of message. 274a58bff56Ssthen */ 275a58bff56Ssthen int caps_failed_rcode(struct reply_info* rep); 276a58bff56Ssthen 277a58bff56Ssthen /** 278bdfc4d55Sflorian * Store parent-side rrset in separate rrset cache entries for later 279933707f3Ssthen * last-resort * lookups in case the child-side versions of this information 280933707f3Ssthen * fails. 281933707f3Ssthen * @param env: environment with cache, time, ... 282933707f3Ssthen * @param rrset: the rrset to store (copied). 283933707f3Ssthen * Failure to store is logged, but otherwise ignored. 284933707f3Ssthen */ 285933707f3Ssthen void iter_store_parentside_rrset(struct module_env* env, 286933707f3Ssthen struct ub_packed_rrset_key* rrset); 287933707f3Ssthen 288933707f3Ssthen /** 289933707f3Ssthen * Store parent-side NS records from a referral message 290933707f3Ssthen * @param env: environment with cache, time, ... 291933707f3Ssthen * @param rep: response with NS rrset. 292933707f3Ssthen * Failure to store is logged, but otherwise ignored. 293933707f3Ssthen */ 294933707f3Ssthen void iter_store_parentside_NS(struct module_env* env, struct reply_info* rep); 295933707f3Ssthen 296933707f3Ssthen /** 297933707f3Ssthen * Store parent-side negative element, the parentside rrset does not exist, 298933707f3Ssthen * creates an rrset with empty rdata in the rrset cache with PARENTSIDE flag. 299933707f3Ssthen * @param env: environment with cache, time, ... 300933707f3Ssthen * @param qinfo: the identity of the rrset that is missing. 301933707f3Ssthen * @param rep: delegation response or answer response, to glean TTL from. 302933707f3Ssthen * (malloc) failure is logged but otherwise ignored. 303933707f3Ssthen */ 304933707f3Ssthen void iter_store_parentside_neg(struct module_env* env, 305933707f3Ssthen struct query_info* qinfo, struct reply_info* rep); 306933707f3Ssthen 307933707f3Ssthen /** 308933707f3Ssthen * Add parent NS record if that exists in the cache. This is both new 309933707f3Ssthen * information and acts like a timeout throttle on retries. 310933707f3Ssthen * @param env: query env with rrset cache and time. 311933707f3Ssthen * @param dp: delegation point to store result in. Also this dp is used to 312933707f3Ssthen * see which NS name is needed. 313933707f3Ssthen * @param region: region to alloc result in. 314933707f3Ssthen * @param qinfo: pertinent information, the qclass. 315933707f3Ssthen * @return false on malloc failure. 316933707f3Ssthen * if true, the routine worked and if such cached information 317933707f3Ssthen * existed dp->has_parent_side_NS is set true. 318933707f3Ssthen */ 319933707f3Ssthen int iter_lookup_parent_NS_from_cache(struct module_env* env, 320933707f3Ssthen struct delegpt* dp, struct regional* region, struct query_info* qinfo); 321933707f3Ssthen 322933707f3Ssthen /** 323933707f3Ssthen * Add parent-side glue if that exists in the cache. This is both new 324933707f3Ssthen * information and acts like a timeout throttle on retries to fetch them. 325933707f3Ssthen * @param env: query env with rrset cache and time. 326933707f3Ssthen * @param dp: delegation point to store result in. Also this dp is used to 327933707f3Ssthen * see which NS name is needed. 328933707f3Ssthen * @param region: region to alloc result in. 329933707f3Ssthen * @param qinfo: pertinent information, the qclass. 330933707f3Ssthen * @return: true, it worked, no malloc failures, and new addresses (lame) 331933707f3Ssthen * have been added, giving extra options as query targets. 332933707f3Ssthen */ 333933707f3Ssthen int iter_lookup_parent_glue_from_cache(struct module_env* env, 334933707f3Ssthen struct delegpt* dp, struct regional* region, struct query_info* qinfo); 335933707f3Ssthen 336933707f3Ssthen /** 337933707f3Ssthen * Lookup next root-hint or root-forward entry. 338933707f3Ssthen * @param hints: the hints. 339933707f3Ssthen * @param fwd: the forwards. 340933707f3Ssthen * @param c: the class to start searching at. 0 means find first one. 341933707f3Ssthen * @return false if no classes found, true if found and returned in c. 342933707f3Ssthen */ 343933707f3Ssthen int iter_get_next_root(struct iter_hints* hints, struct iter_forwards* fwd, 344933707f3Ssthen uint16_t* c); 345933707f3Ssthen 346933707f3Ssthen /** 347933707f3Ssthen * Remove DS records that are inappropriate before they are cached. 348933707f3Ssthen * @param msg: the response to scrub. 349933707f3Ssthen * @param ns: RRSET that is the NS record for the referral. 350933707f3Ssthen * if NULL, then all DS records are removed from the authority section. 351933707f3Ssthen * @param z: zone name that the response is from. 352933707f3Ssthen */ 353933707f3Ssthen void iter_scrub_ds(struct dns_msg* msg, struct ub_packed_rrset_key* ns, 354933707f3Ssthen uint8_t* z); 355933707f3Ssthen 356933707f3Ssthen /** 357550cf4a9Ssthen * Prepare an NXDOMAIN message to be used for a subdomain answer by removing all 358550cf4a9Ssthen * RRs from the ANSWER section. 359550cf4a9Ssthen * @param msg: the response to scrub. 360550cf4a9Ssthen */ 361550cf4a9Ssthen void iter_scrub_nxdomain(struct dns_msg* msg); 362550cf4a9Ssthen 363550cf4a9Ssthen /** 364933707f3Ssthen * Remove query attempts from all available ips. For 0x20. 365933707f3Ssthen * @param dp: delegpt. 366933707f3Ssthen * @param d: decrease. 367e21c60efSsthen * @param outbound_msg_retry: number of retries of outgoing queries 368933707f3Ssthen */ 369e21c60efSsthen void iter_dec_attempts(struct delegpt* dp, int d, int outbound_msg_retry); 370933707f3Ssthen 371933707f3Ssthen /** 372933707f3Ssthen * Add retry counts from older delegpt to newer delegpt. 373933707f3Ssthen * Does not waste time on timeout'd (or other failing) addresses. 374933707f3Ssthen * @param dp: new delegationpoint. 375933707f3Ssthen * @param old: old delegationpoint. 376e21c60efSsthen * @param outbound_msg_retry: number of retries of outgoing queries 377933707f3Ssthen */ 378e21c60efSsthen void iter_merge_retry_counts(struct delegpt* dp, struct delegpt* old, 379e21c60efSsthen int outbound_msg_retry); 380933707f3Ssthen 381d8d14d0cSsthen /** 382d8d14d0cSsthen * See if a DS response (type ANSWER) is too low: a nodata answer with 383d8d14d0cSsthen * a SOA record in the authority section at-or-below the qchase.qname. 384d8d14d0cSsthen * Also returns true if we are not sure (i.e. empty message, CNAME nosig). 385d8d14d0cSsthen * @param msg: the response. 386d8d14d0cSsthen * @param dp: the dp name is used to check if the RRSIG gives a clue that 387d8d14d0cSsthen * it was originated from the correct nameserver. 388d8d14d0cSsthen * @return true if too low. 389d8d14d0cSsthen */ 390d8d14d0cSsthen int iter_ds_toolow(struct dns_msg* msg, struct delegpt* dp); 391d8d14d0cSsthen 392d8d14d0cSsthen /** 393d8d14d0cSsthen * See if delegpt can go down a step to the qname or not 394d8d14d0cSsthen * @param qinfo: the query name looked up. 395d8d14d0cSsthen * @param dp: checked if the name can go lower to the qname 396d8d14d0cSsthen * @return true if can go down, false if that would not be possible. 397d8d14d0cSsthen * the current response seems to be the one and only, best possible, response. 398d8d14d0cSsthen */ 399d8d14d0cSsthen int iter_dp_cangodown(struct query_info* qinfo, struct delegpt* dp); 400d8d14d0cSsthen 4013150e5f6Ssthen /** 4023150e5f6Ssthen * Lookup if no_cache is set in stub or fwd. 4033150e5f6Ssthen * @param qstate: query state with env with hints and fwds. 4043150e5f6Ssthen * @param qinf: query name to lookup for. 405191f22c6Ssthen * @param retdpname: returns NULL or the deepest enclosing name of fwd or stub. 406191f22c6Ssthen * This is the name under which the closest lookup is going to happen. 407191f22c6Ssthen * Used for NXDOMAIN checks, above that it is an nxdomain from a 408191f22c6Ssthen * different server and zone. You can pass NULL to not get it. 409191f22c6Ssthen * @param retdpnamelen: returns the length of the dpname. 410*2bdc0ed1Ssthen * @param dpname_storage: this is where the dpname buf is stored, if any. 411*2bdc0ed1Ssthen * So that caller can manage the buffer. 412*2bdc0ed1Ssthen * @param dpname_storage_len: size of dpname_storage buffer. 4133150e5f6Ssthen * @return true if no_cache is set in stub or fwd. 4143150e5f6Ssthen */ 4153150e5f6Ssthen int iter_stub_fwd_no_cache(struct module_qstate *qstate, 416*2bdc0ed1Ssthen struct query_info *qinf, uint8_t** retdpname, size_t* retdpnamelen, 417*2bdc0ed1Ssthen uint8_t* dpname_storage, size_t dpname_storage_len); 418191f22c6Ssthen 419191f22c6Ssthen /** 420191f22c6Ssthen * Set support for IP4 and IP6 depending on outgoing interfaces 421191f22c6Ssthen * in the outside network. If none, no support, so no use to lookup 422191f22c6Ssthen * the AAAA and then attempt to use it if there is no outgoing-interface 423191f22c6Ssthen * for it. 424191f22c6Ssthen * @param mods: modstack to find iterator module in. 425191f22c6Ssthen * @param env: module env, find iterator module (if one) in there. 426191f22c6Ssthen * @param outnet: outside network structure. 427191f22c6Ssthen */ 428191f22c6Ssthen void iterator_set_ip46_support(struct module_stack* mods, 429191f22c6Ssthen struct module_env* env, struct outside_network* outnet); 4303150e5f6Ssthen 431933707f3Ssthen #endif /* ITERATOR_ITER_UTILS_H */ 432