#include "config.h"
#include "iterator/iterator.h"
#include "iterator/iter_utils.h"
#include "iterator/iter_hints.h"
#include "iterator/iter_fwd.h"
#include "iterator/iter_donotq.h"
#include "iterator/iter_delegpt.h"
#include "iterator/iter_resptype.h"
#include "iterator/iter_scrub.h"
#include "services/cache/dns.h"
#include "services/cache/infra.h"
#include "util/module.h"
#include "util/netevent.h"
#include "util/net_help.h"
#include "util/regional.h"
#include "util/data/dname.h"
#include "util/data/msgencode.h"
#include "util/fptr_wlist.h"
Functions | |
int | iter_init (struct module_env *env, int id) |
iterator init | |
void | iter_deinit (struct module_env *env, int id) |
iterator deinit | |
static int | iter_new (struct module_qstate *qstate, int id) |
new query for iterator | |
static int | next_state (struct iter_qstate *iq, enum iter_state nextstate) |
Transition to the next state. | |
static int | final_state (struct iter_qstate *iq) |
Transition an event to its final state. | |
static void | error_supers (struct module_qstate *qstate, int id, struct module_qstate *super) |
Callback routine to handle errors in parent query states. | |
static int | error_response (struct module_qstate *qstate, int id, int rcode) |
Return an error to the client. | |
static int | prepend_is_duplicate (struct ub_packed_rrset_key **sets, size_t to, struct ub_packed_rrset_key *dup) |
check if prepend item is duplicate item | |
static int | iter_prepend (struct iter_qstate *iq, struct dns_msg *msg, struct regional *region) |
prepend the prepend list in the answer and authority section of dns_msg | |
static int | iter_add_prepend_answer (struct module_qstate *qstate, struct iter_qstate *iq, struct ub_packed_rrset_key *rrset) |
Add rrset to ANSWER prepend list. | |
static int | iter_add_prepend_auth (struct module_qstate *qstate, struct iter_qstate *iq, struct ub_packed_rrset_key *rrset) |
Add rrset to AUTHORITY prepend list. | |
static int | handle_cname_response (struct module_qstate *qstate, struct iter_qstate *iq, struct dns_msg *msg, uint8_t **mname, size_t *mname_len) |
Given a CNAME response (defined as a response containing a CNAME or DNAME that does not answer the request), process the response, modifying the state as necessary. | |
static int | generate_sub_request (uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, struct module_qstate *qstate, int id, struct iter_qstate *iq, enum iter_state initial_state, enum iter_state final_state, struct module_qstate **subq_ret) |
Generate a subrequest. | |
static int | prime_root (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id, uint16_t qclass) |
Generate and send a root priming request. | |
static int | prime_stub (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id, uint8_t *qname, uint16_t qclass) |
Generate and process a stub priming request. | |
static int | forward_request (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie) |
See if the query needs forwarding. | |
static int | processInitRequest (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id) |
Process the initial part of the request handling. | |
static int | processInitRequest2 (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id) |
Process the second part of the initial request handling. | |
static int | processInitRequest3 (struct module_qstate *qstate, struct iter_qstate *iq) |
Process the third part of the initial request handling. | |
static int | generate_target_query (struct module_qstate *qstate, struct iter_qstate *iq, int id, uint8_t *name, size_t namelen, uint16_t qtype, uint16_t qclass) |
Given a basic query, generate a "target" query. | |
static int | query_for_targets (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id, int maxtargets, int *num) |
Given an event at a certain state, generate zero or more target queries for it's current delegation point. | |
static int | processQueryTargets (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id) |
This is the request event state where the request will be sent to one of its current query targets. | |
static int | processQueryResponse (struct module_qstate *qstate, struct iter_qstate *iq, int id) |
Process the query response. | |
static void | prime_supers (struct module_qstate *qstate, int id, struct module_qstate *forq) |
Return priming query results to interestes super querystates. | |
static int | processPrimeResponse (struct module_qstate *qstate, int id) |
This handles the response to a priming query. | |
static void | processTargetResponse (struct module_qstate *qstate, int id, struct module_qstate *forq) |
Do final processing on responses to target queries. | |
static int | processFinished (struct module_qstate *qstate, struct iter_qstate *iq, int id) |
This handles the final state for first-tier responses (i.e., responses to externally generated queries). | |
void | iter_inform_super (struct module_qstate *qstate, int id, struct module_qstate *super) |
Return priming query results to interestes super querystates. | |
static void | iter_handle (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id) |
Handle iterator state. | |
static void | process_request (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id) |
This is the primary entry point for processing request events. | |
static void | process_response (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id, struct outbound_entry *outbound, enum module_ev event) |
process authoritative server reply | |
void | iter_operate (struct module_qstate *qstate, enum module_ev event, int id, struct outbound_entry *outbound) |
iterator operate on a query | |
void | iter_clear (struct module_qstate *qstate, int id) |
iterator cleanup query state | |
size_t | iter_get_mem (struct module_env *env, int id) |
iterator alloc size routine | |
struct module_func_block * | iter_get_funcblock () |
Get the iterator function block. | |
const char * | iter_state_to_string (enum iter_state state) |
Get iterator state as a string. | |
int | iter_state_is_responsestate (enum iter_state s) |
See if iterator state is a response state. | |
Variables | |
static struct module_func_block | iter_block |
The iterator function block. |
static int next_state | ( | struct iter_qstate * | iq, | |
enum iter_state | nextstate | |||
) | [static] |
Transition to the next state.
This can be used to advance a currently processing event. It cannot be used to reactivate a forEvent.
iq,: | iterator query state | |
nextstate | The state to transition to. |
References iter_state_is_responsestate(), log_err(), iter_qstate::response, and iter_qstate::state.
Referenced by final_state(), processInitRequest(), processInitRequest2(), processInitRequest3(), processQueryResponse(), and processQueryTargets().
static int final_state | ( | struct iter_qstate * | iq | ) | [static] |
Transition an event to its final state.
Final states always either return a result up the module chain, or reactivate a dependent event. Which final state to transtion to is set in the module state for the event when it was created, and depends on the original purpose of the event.
The response is stored in the qstate->buf buffer.
iq,: | iterator query state |
References iter_qstate::final_state, and next_state().
Referenced by processInitRequest(), processInitRequest3(), and processQueryResponse().
static void error_supers | ( | struct module_qstate * | qstate, | |
int | id, | |||
struct module_qstate * | super | |||
) | [static] |
Callback routine to handle errors in parent query states.
qstate,: | query state that failed. | |
id,: | module id. | |
super,: | super state. |
References delegpt_find_ns(), delegpt_log(), iter_qstate::dp, log_assert, log_query_info(), module_qstate::minfo, iter_qstate::num_target_queries, module_qstate::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, QUERYTARGETS_STATE, delegpt_ns::resolved, iter_qstate::state, VERB_ALGO, and verbose().
Referenced by iter_inform_super().
static int error_response | ( | struct module_qstate * | qstate, | |
int | id, | |||
int | rcode | |||
) | [static] |
Return an error to the client.
qstate,: | our query state | |
id,: | module id | |
rcode,: | error code (DNS errcode). |
References module_qstate::ext_state, module_finished, delegpt_ns::name, module_qstate::return_msg, module_qstate::return_rcode, VERB_QUERY, and verbose().
Referenced by iter_operate(), prime_stub(), process_response(), processFinished(), processInitRequest(), processQueryResponse(), and processQueryTargets().
static int iter_add_prepend_answer | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct ub_packed_rrset_key * | rrset | |||
) | [static] |
Add rrset to ANSWER prepend list.
qstate,: | query state. | |
iq,: | iterator query state. | |
rrset,: | rrset to add. |
References iter_qstate::an_prepend_last, iter_qstate::an_prepend_list, iter_prep_list::next, module_qstate::region, regional_alloc(), and iter_prep_list::rrset.
Referenced by handle_cname_response().
static int iter_add_prepend_auth | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct ub_packed_rrset_key * | rrset | |||
) | [static] |
Add rrset to AUTHORITY prepend list.
qstate,: | query state. | |
iq,: | iterator query state. | |
rrset,: | rrset to add. |
References iter_prep_list::next, iter_qstate::ns_prepend_last, iter_qstate::ns_prepend_list, module_qstate::region, regional_alloc(), and iter_prep_list::rrset.
Referenced by handle_cname_response().
static int handle_cname_response | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct dns_msg * | msg, | |||
uint8_t ** | mname, | |||
size_t * | mname_len | |||
) | [static] |
Given a CNAME response (defined as a response containing a CNAME or DNAME that does not answer the request), process the response, modifying the state as necessary.
This follows the CNAME/DNAME chain and returns the final query name.
sets the new query name, after following the CNAME/DNAME chain.
qstate,: | query state. | |
iq,: | iterator query state. | |
msg,: | the response. | |
mname,: | returned target new query name. | |
mname_len,: | length of mname. |
References reply_info::an_numrrsets, packed_rrset_key::dname, dname_strict_subdomain_c(), get_cname_target(), iter_add_prepend_answer(), iter_add_prepend_auth(), reply_info::ns_numrrsets, iter_qstate::qchase, query_info::qname, query_info::qname_len, query_dname_compare(), dns_msg::rep, ub_packed_rrset_key::rk, reply_info::rrsets, and packed_rrset_key::type.
Referenced by processInitRequest(), and processQueryResponse().
static int generate_sub_request | ( | uint8_t * | qname, | |
size_t | qnamelen, | |||
uint16_t | qtype, | |||
uint16_t | qclass, | |||
struct module_qstate * | qstate, | |||
int | id, | |||
struct iter_qstate * | iq, | |||
enum iter_state | initial_state, | |||
enum iter_state | final_state, | |||
struct module_qstate ** | subq_ret | |||
) | [static] |
Generate a subrequest.
Generate a local request event. Local events are tied to this module, and have a correponding (first tier) event that is waiting for this event to resolve to continue.
qname | The query name for this request. | |
qnamelen | length of qname | |
qtype | The query type for this request. | |
qclass | The query class for this request. | |
qstate | The event that is generating this event. | |
id,: | module id. | |
iq,: | The iterator state that is generating this event. | |
initial_state | The initial response state (normally this is QUERY_RESP_STATE, unless it is known that the request won't need iterative processing | |
final_state | The final state for the response to this request. | |
subq_ret,: | if newly allocated, the subquerystate, or NULL if it does not need initialisation. |
References module_env::attach_sub, BIT_CD, BIT_RD, iter_qstate::chase_flags, module_qstate::curmod, iter_qstate::depth, module_qstate::env, module_qstate::ext_state, iter_qstate::final_state, fptr_ok, fptr_whitelist_modenv_attach_sub(), fptr_whitelist_modenv_kill_sub(), INIT_REQUEST_STATE, module_env::kill_sub, log_err(), module_qstate::minfo, module_state_initial, iter_qstate::num_current_queries, iter_qstate::num_target_queries, outbound_list_init(), iter_qstate::outlist, PRIME_RESP_STATE, iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, module_qstate::query_flags, iter_qstate::refetch_glue, module_qstate::region, regional_alloc(), and iter_qstate::state.
Referenced by generate_target_query(), prime_root(), and prime_stub().
static int prime_root | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id, | |||
uint16_t | qclass | |||
) | [static] |
Generate and send a root priming request.
qstate,: | the qtstate that triggered the need to prime. | |
iq,: | iterator query state. | |
ie,: | iterator global state. | |
id,: | module id. | |
qclass,: | the class to prime. |
References delegpt_copy(), iter_qstate::dp, module_qstate::ext_state, generate_sub_request(), iter_env::hints, hints_lookup_root(), log_err(), module_qstate::minfo, module_wait_subquery, iter_qstate::num_target_queries, PRIME_RESP_STATE, QUERYTARGETS_STATE, module_qstate::region, VERB_ALGO, VERB_DETAIL, and verbose().
Referenced by processInitRequest().
static int prime_stub | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id, | |||
uint8_t * | qname, | |||
uint16_t | qclass | |||
) | [static] |
Generate and process a stub priming request.
This method tests for the need to prime a stub zone, so it is safe to call for every request.
qstate,: | the qtstate that triggered the need to prime. | |
iq,: | iterator query state. | |
ie,: | iterator global state. | |
id,: | module id. | |
qname,: | request name. | |
qclass,: | the class to prime. |
References delegpt_copy(), iter_qstate::dp, module_qstate::env, error_response(), module_qstate::ext_state, fptr_ok, fptr_whitelist_modenv_kill_sub(), generate_sub_request(), iter_env::hints, hints_lookup_stub(), module_env::kill_sub, log_err(), log_nametypeclass(), module_qstate::minfo, module_wait_subquery, delegpt::name, delegpt::namelen, iter_qstate::num_target_queries, PRIME_RESP_STATE, QUERYTARGETS_STATE, module_qstate::region, VERB_DETAIL, and iter_qstate::wait_priming_stub.
Referenced by processInitRequest2().
static int forward_request | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie | |||
) | [static] |
See if the query needs forwarding.
qstate,: | query state. | |
iq,: | iterator query state. | |
ie,: | iterator shared global environment. |
References BIT_RD, iter_qstate::chase_flags, delegpt_copy(), iter_qstate::dp, forwards_lookup(), iter_env::fwds, iter_qstate::qchase, query_info::qclass, query_info::qname, module_qstate::region, VERB_ALGO, and verbose().
Referenced by processInitRequest().
static int processInitRequest | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id | |||
) | [static] |
Process the initial part of the request handling.
This state roughly corresponds to resolver algorithms steps 1 (find answer in cache) and 2 (find the best servers to ask).
Note that all requests start here, and query restarts revisit this state.
This state either generates: 1) a response, from cache or error, 2) a priming event, or 3) forwards the request to the next state (init2, generally).
qstate,: | query state. | |
iq,: | iterator query state. | |
ie,: | iterator shared global environment. | |
id,: | module id. |
References iter_qstate::deleg_msg, delegpt_copy(), delegpt_log(), iter_qstate::depth, dname_is_root(), dname_remove_label(), dns_cache_find_delegation(), dns_cache_lookup(), iter_qstate::dp, module_qstate::env, error_response(), final_state(), forward_request(), handle_cname_response(), iter_env::hints, hints_lookup_root(), INIT_REQUEST_2_STATE, INIT_REQUEST_STATE, iter_dp_is_useless(), log_dns_msg(), log_err(), log_query_info(), iter_env::max_dependency_depth, MAX_RESTART_COUNT, delegpt::name, delegpt::namelen, next_state(), module_env::now, prime_root(), iter_qstate::qchase, query_info::qclass, dns_msg::qinfo, module_qstate::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, iter_qstate::query_restart_count, QUERYTARGETS_STATE, iter_qstate::refetch_glue, module_qstate::region, dns_msg::rep, iter_qstate::response, RESPONSE_TYPE_CNAME, response_type_from_cache(), module_env::scratch, VERB_ALGO, VERB_DETAIL, VERB_QUERY, verbose(), and verbosity.
Referenced by iter_handle().
static int processInitRequest2 | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id | |||
) | [static] |
Process the second part of the initial request handling.
This state basically exists so that queries that generate root priming events have the same init processing as ones that do not. Request events that reach this state must have a valid currentDelegationPoint set.
This part is primarly handling stub zone priming. Events that reach this state must have a current delegation point.
qstate,: | query state. | |
iq,: | iterator query state. | |
ie,: | iterator shared global environment. | |
id,: | module id. |
References INIT_REQUEST_3_STATE, log_query_info(), next_state(), prime_stub(), iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, query_info::qname, and VERB_QUERY.
Referenced by iter_handle().
static int processInitRequest3 | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq | |||
) | [static] |
Process the third part of the initial request handling.
This state exists as a separate state so that queries that generate stub priming events will get the tail end of the init process but not repeat the stub priming check.
qstate,: | query state. | |
iq,: | iterator query state. |
References BIT_RD, iter_qstate::chase_flags, iter_qstate::deleg_msg, iter_qstate::dnssec_expected, iter_qstate::dp, module_qstate::env, final_state(), iter_indicates_dnssec(), log_dns_msg(), log_query_info(), next_state(), iter_qstate::qchase, query_info::qclass, dns_msg::qinfo, module_qstate::qinfo, module_qstate::query_flags, QUERYTARGETS_STATE, dns_msg::rep, iter_qstate::response, VERB_ALGO, VERB_QUERY, and verbosity.
Referenced by iter_handle().
static int generate_target_query | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
int | id, | |||
uint8_t * | name, | |||
size_t | namelen, | |||
uint16_t | qtype, | |||
uint16_t | qclass | |||
) | [static] |
Given a basic query, generate a "target" query.
These are subordinate queries for missing delegation point target addresses.
qstate,: | query state. | |
iq,: | iterator query state. | |
id,: | module id. | |
name,: | target qname. | |
namelen,: | target qname length. | |
qtype,: | target qtype (either A or AAAA). | |
qclass,: | target qclass. |
References delegpt_copy(), dname_subdomain_c(), iter_qstate::dp, FINISHED_STATE, generate_sub_request(), INIT_REQUEST_STATE, log_nametypeclass(), module_qstate::minfo, delegpt::name, iter_qstate::refetch_glue, module_qstate::region, VERB_ALGO, VERB_QUERY, and verbose().
Referenced by query_for_targets().
static int query_for_targets | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id, | |||
int | maxtargets, | |||
int * | num | |||
) | [static] |
Given an event at a certain state, generate zero or more target queries for it's current delegation point.
qstate,: | query state. | |
iq,: | iterator query state. | |
ie,: | iterator shared global environment. | |
id,: | module id. | |
maxtargets,: | The maximum number of targets to query for. if it is negative, there is no maximum number of targets. | |
num,: | returns the number of queries generated and processed, which may be zero if there were no missing targets. |
References delegpt_count_missing_targets(), iter_qstate::dp, module_qstate::env, module_qstate::ext_state, generate_target_query(), iter_mark_cycle_targets(), iter_ns_probability(), log_assert, module_wait_subquery, delegpt_ns::name, delegpt_ns::namelen, delegpt_ns::next, delegpt::nslist, iter_qstate::qchase, query_info::qclass, delegpt_ns::resolved, module_env::rnd, and iter_env::supports_ipv6.
Referenced by processQueryTargets().
static int processQueryTargets | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id | |||
) | [static] |
This is the request event state where the request will be sent to one of its current query targets.
This state also handles issuing target lookup queries for missing target IP addresses. Queries typically iterate on this state, both when they are just trying different targets for a given delegation point, and when they change delegation points. This state roughly corresponds to RFC 1034 algorithm steps 3 and 4.
qstate,: | query state. | |
iq,: | iterator query state. | |
ie,: | iterator shared global environment. | |
id,: | module id. |
References delegpt_addr::addr, delegpt_addr::addrlen, BIT_CD, iter_qstate::chase_flags, delegpt_add_unused_targets(), delegpt_count_missing_targets(), delegpt_log(), iter_qstate::depth, iter_qstate::dnssec_expected, iter_qstate::dp, EDNS_DO, module_qstate::env, error_response(), module_qstate::ext_state, fptr_ok, fptr_whitelist_modenv_send_query(), iter_server_selection(), log_addr(), log_name_addr(), log_query_info(), iter_env::max_dependency_depth, MAX_REFERRAL_COUNT, module_wait_reply, delegpt::name, delegpt::namelen, next_state(), iter_qstate::num_current_queries, iter_qstate::num_target_queries, outbound_list_insert(), iter_qstate::outlist, iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, query_for_targets(), QUERYTARGETS_STATE, iter_qstate::referral_count, module_env::send_query, iter_env::target_fetch_policy, VERB_ALGO, VERB_OPS, VERB_QUERY, and verbose().
Referenced by iter_handle().
static int processQueryResponse | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
int | id | |||
) | [static] |
Process the query response.
All queries end up at this state first. This process generally consists of analyzing the response and routing the event to the next state (either bouncing it back to a request state, or terminating the processing for this event).
qstate,: | query state. | |
iq,: | iterator query state. | |
id,: | module id. |
References comm_reply::addr, comm_reply::addrlen, BIT_RD, cache_fill_missing(), iter_qstate::chase_flags, iter_qstate::deleg_msg, delegpt_from_message(), delegpt_log(), module_env::detach_subs, iter_qstate::dnssec_expected, iter_qstate::dp, module_qstate::env, error_response(), final_state(), fptr_ok, fptr_whitelist_modenv_detach_subs(), handle_cname_response(), module_env::infra_cache, infra_set_lame(), INIT_REQUEST_STATE, iter_dns_store(), iter_indicates_dnssec(), iter_msg_from_zone(), iter_msg_has_dnssec(), log_dns_msg(), log_err(), log_warn(), delegpt::name, delegpt::namelen, next_state(), module_env::now, iter_qstate::num_current_queries, iter_qstate::num_target_queries, outbound_list_clear(), iter_qstate::outlist, iter_qstate::qchase, query_info::qclass, dns_msg::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, iter_qstate::query_restart_count, QUERYTARGETS_STATE, iter_qstate::referral_count, module_qstate::region, dns_msg::rep, module_qstate::reply, iter_qstate::response, RESPONSE_TYPE_ANSWER, RESPONSE_TYPE_CNAME, response_type_from_server(), RESPONSE_TYPE_LAME, RESPONSE_TYPE_REFERRAL, RESPONSE_TYPE_THROWAWAY, RESPONSE_TYPE_UNTYPED, VERB_ALGO, VERB_DETAIL, verbose(), and verbosity.
Referenced by iter_handle().
static void prime_supers | ( | struct module_qstate * | qstate, | |
int | id, | |||
struct module_qstate * | forq | |||
) | [static] |
Return priming query results to interestes super querystates.
Sets the delegation point and delegation message (not nonRD queries). This is a callback from walk_supers.
qstate,: | priming query state that finished. | |
id,: | module id. | |
forq,: | the qstate for which priming has been done. |
References iter_qstate::deleg_msg, delegpt_from_message(), delegpt_log(), dns_copy_msg(), iter_qstate::dp, INIT_REQUEST_2_STATE, INIT_REQUEST_3_STATE, module_qstate::is_priming, log_assert, log_err(), log_query_info(), module_qstate::minfo, module_qstate::qinfo, QUERYTARGETS_STATE, module_qstate::region, module_qstate::return_msg, module_qstate::return_rcode, iter_qstate::state, VERB_ALGO, VERB_DETAIL, verbose(), and iter_qstate::wait_priming_stub.
Referenced by iter_inform_super().
static int processPrimeResponse | ( | struct module_qstate * | qstate, | |
int | id | |||
) | [static] |
This handles the response to a priming query.
This is used to handle both root and stub priming responses. This is basically the equivalent of the QUERY_RESP_STATE, but will not handle CNAME responses and will treat REFERRALs as ANSWERS. It will also update and reactivate the originating event.
qstate,: | query state. | |
id,: | module id. |
References iter_qstate::dp, module_qstate::ext_state, module_qstate::minfo, module_finished, iter_qstate::qchase, iter_qstate::response, RESPONSE_TYPE_ANSWER, response_type_from_server(), module_qstate::return_msg, and module_qstate::return_rcode.
Referenced by iter_handle().
static void processTargetResponse | ( | struct module_qstate * | qstate, | |
int | id, | |||
struct module_qstate * | forq | |||
) | [static] |
Do final processing on responses to target queries.
Events reach this state after the iterative resolution algorithm terminates. This state is responsible for reactiving the original event, and housekeeping related to received target responses (caching, updating the current delegation point, etc). Callback from walk_supers for every super state that is interested in the results from this query.
qstate,: | query state. | |
id,: | module id. | |
forq,: | super query state. |
References delegpt_add_ns(), delegpt_add_rrset(), delegpt_find_ns(), delegpt_log(), packed_rrset_key::dname, packed_rrset_key::dname_len, log_assert, log_err(), log_query_info(), module_qstate::minfo, iter_qstate::qchase, module_qstate::qinfo, query_info::qname, query_info::qname_len, QUERYTARGETS_STATE, module_qstate::region, dns_msg::rep, reply_find_answer_rrset(), delegpt_ns::resolved, module_qstate::return_msg, module_qstate::return_rcode, ub_packed_rrset_key::rk, VERB_ALGO, and verbose().
Referenced by iter_inform_super().
static int processFinished | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
int | id | |||
) | [static] |
This handles the final state for first-tier responses (i.e., responses to externally generated queries).
qstate,: | query state. | |
iq,: | iterator query state. | |
id,: | module id. |
References iter_qstate::an_prepend_list, BIT_AA, BIT_QR, BIT_RA, BIT_RD, module_qstate::env, error_response(), module_qstate::ext_state, reply_info::flags, iter_dns_store(), iter_prepend(), log_err(), log_query_info(), module_finished, iter_qstate::ns_prepend_list, dns_msg::qinfo, module_qstate::qinfo, module_qstate::query_flags, module_qstate::region, dns_msg::rep, iter_qstate::response, module_qstate::return_msg, module_qstate::return_rcode, VERB_ALGO, VERB_QUERY, and verbose().
Referenced by iter_handle(), and val_handle().
void iter_inform_super | ( | struct module_qstate * | qstate, | |
int | id, | |||
struct module_qstate * | super | |||
) |
Return priming query results to interestes super querystates.
Sets the delegation point and delegation message (not nonRD queries). This is a callback from walk_supers.
qstate,: | query state that finished. | |
id,: | module id. | |
super,: | the qstate to inform. |
References error_supers(), module_qstate::is_priming, prime_supers(), processTargetResponse(), and module_qstate::return_rcode.
Referenced by fptr_whitelist_mod_inform_super().
static void iter_handle | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id | |||
) | [static] |
Handle iterator state.
Handle events. This is the real processing loop for events, responsible for moving events through the various states. If a processing method returns true, then it will be advanced to the next state. If false, then processing will stop.
qstate,: | query state. | |
ie,: | iterator shared global environment. | |
iq,: | iterator query state. | |
id,: | module id. |
References FINISHED_STATE, INIT_REQUEST_2_STATE, INIT_REQUEST_3_STATE, INIT_REQUEST_STATE, iter_state_to_string(), log_warn(), PRIME_RESP_STATE, processFinished(), processInitRequest(), processInitRequest2(), processInitRequest3(), processPrimeResponse(), processQueryResponse(), processQueryTargets(), QUERY_RESP_STATE, QUERYTARGETS_STATE, iter_qstate::state, VERB_ALGO, and verbose().
Referenced by iter_operate(), process_request(), and process_response().
static void process_request | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id | |||
) | [static] |
This is the primary entry point for processing request events.
Note that this method should only be used by external modules.
qstate,: | query state. | |
ie,: | iterator shared global environment. | |
iq,: | iterator query state. | |
id,: | module id. |
References iter_qstate::final_state, FINISHED_STATE, INIT_REQUEST_STATE, iter_handle(), iter_qstate::state, VERB_ALGO, and verbose().
Referenced by iter_operate().
struct module_func_block* iter_get_funcblock | ( | ) | [read] |
Get the iterator function block.
Referenced by checkconf(), and module_factory().
const char* iter_state_to_string | ( | enum iter_state | state | ) |
Get iterator state as a string.
state,: | to convert |
References FINISHED_STATE, INIT_REQUEST_2_STATE, INIT_REQUEST_3_STATE, INIT_REQUEST_STATE, PRIME_RESP_STATE, QUERY_RESP_STATE, and QUERYTARGETS_STATE.
Referenced by iter_handle().
int iter_state_is_responsestate | ( | enum iter_state | s | ) |
See if iterator state is a response state.
s,: | to inspect |
References INIT_REQUEST_2_STATE, INIT_REQUEST_3_STATE, INIT_REQUEST_STATE, and QUERYTARGETS_STATE.
Referenced by next_state().
struct module_func_block iter_block [static] |
Initial value:
{ "iterator", &iter_init, &iter_deinit, &iter_operate, &iter_inform_super, &iter_clear, &iter_get_mem }