Deleted Added
full compact
iterator.h (275852) iterator.h (276605)
1/*
2 * iterator/iterator.h - iterative resolver DNS query response module
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36/**
37 * \file
38 *
39 * This file contains a module that performs recusive iterative DNS query
40 * processing.
41 */
42
43#ifndef ITERATOR_ITERATOR_H
44#define ITERATOR_ITERATOR_H
45#include "services/outbound_list.h"
46#include "util/data/msgreply.h"
47#include "util/module.h"
48struct delegpt;
49struct iter_hints;
50struct iter_forwards;
51struct iter_donotq;
52struct iter_prep_list;
53struct iter_priv;
54
55/** max number of targets spawned for a query and its subqueries */
56#define MAX_TARGET_COUNT 32
57/** max number of query restarts. Determines max number of CNAME chain. */
58#define MAX_RESTART_COUNT 8
59/** max number of referrals. Makes sure resolver does not run away */
60#define MAX_REFERRAL_COUNT 130
61/** max number of queries-sent-out. Make sure large NS set does not loop */
1/*
2 * iterator/iterator.h - iterative resolver DNS query response module
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36/**
37 * \file
38 *
39 * This file contains a module that performs recusive iterative DNS query
40 * processing.
41 */
42
43#ifndef ITERATOR_ITERATOR_H
44#define ITERATOR_ITERATOR_H
45#include "services/outbound_list.h"
46#include "util/data/msgreply.h"
47#include "util/module.h"
48struct delegpt;
49struct iter_hints;
50struct iter_forwards;
51struct iter_donotq;
52struct iter_prep_list;
53struct iter_priv;
54
55/** max number of targets spawned for a query and its subqueries */
56#define MAX_TARGET_COUNT 32
57/** max number of query restarts. Determines max number of CNAME chain. */
58#define MAX_RESTART_COUNT 8
59/** max number of referrals. Makes sure resolver does not run away */
60#define MAX_REFERRAL_COUNT 130
61/** max number of queries-sent-out. Make sure large NS set does not loop */
62#define MAX_SENT_COUNT 16
62#define MAX_SENT_COUNT 32
63/** at what query-sent-count to stop target fetch policy */
64#define TARGET_FETCH_STOP 3
65/** how nice is a server without further information, in msec
66 * Equals rtt initial timeout value.
67 */
68#define UNKNOWN_SERVER_NICENESS 376
69/** maximum timeout before a host is deemed unsuitable, in msec.
70 * After host_ttl this will be timed out and the host will be tried again.
71 * Equals RTT_MAX_TIMEOUT
72 */
73#define USEFUL_SERVER_TOP_TIMEOUT 120000
63/** at what query-sent-count to stop target fetch policy */
64#define TARGET_FETCH_STOP 3
65/** how nice is a server without further information, in msec
66 * Equals rtt initial timeout value.
67 */
68#define UNKNOWN_SERVER_NICENESS 376
69/** maximum timeout before a host is deemed unsuitable, in msec.
70 * After host_ttl this will be timed out and the host will be tried again.
71 * Equals RTT_MAX_TIMEOUT
72 */
73#define USEFUL_SERVER_TOP_TIMEOUT 120000
74/** Number of lost messages in a row that get a host blacklisted.
75 * With 16, a couple different queries have to time out and no working
76 * queries are happening */
77#define USEFUL_SERVER_MAX_LOST 16
78/** number of retries on outgoing queries */
79#define OUTBOUND_MSG_RETRY 5
80/** RTT band, within this amount from the best, servers are chosen randomly.
81 * Chosen so that the UNKNOWN_SERVER_NICENESS falls within the band of a
82 * fast server, this causes server exploration as a side benefit. msec. */
83#define RTT_BAND 400
84/** Start value for blacklisting a host, 2*USEFUL_SERVER_TOP_TIMEOUT in sec */
85#define INFRA_BACKOFF_INITIAL 240
86
87/**
88 * Global state for the iterator.
89 */
90struct iter_env {
91 /** A flag to indicate whether or not we have an IPv6 route */
92 int supports_ipv6;
93
94 /** A flag to indicate whether or not we have an IPv4 route */
95 int supports_ipv4;
96
97 /** A set of inetaddrs that should never be queried. */
98 struct iter_donotq* donotq;
99
100 /** private address space and private domains */
101 struct iter_priv* priv;
102
103 /** The maximum dependency depth that this resolver will pursue. */
104 int max_dependency_depth;
105
106 /**
107 * The target fetch policy for each dependency level. This is
108 * described as a simple number (per dependency level):
109 * negative numbers (usually just -1) mean fetch-all,
110 * 0 means only fetch on demand, and
111 * positive numbers mean to fetch at most that many targets.
112 * array of max_dependency_depth+1 size.
113 */
114 int* target_fetch_policy;
115};
116
117/**
118 * State of the iterator for a query.
119 */
120enum iter_state {
121 /**
122 * Externally generated queries start at this state. Query restarts are
123 * reset to this state.
124 */
125 INIT_REQUEST_STATE = 0,
126
127 /**
128 * Root priming events reactivate here, most other events pass
129 * through this naturally as the 2nd part of the INIT_REQUEST_STATE.
130 */
131 INIT_REQUEST_2_STATE,
132
133 /**
134 * Stub priming events reactivate here, most other events pass
135 * through this naturally as the 3rd part of the INIT_REQUEST_STATE.
136 */
137 INIT_REQUEST_3_STATE,
138
139 /**
140 * Each time a delegation point changes for a given query or a
141 * query times out and/or wakes up, this state is (re)visited.
142 * This state is reponsible for iterating through a list of
143 * nameserver targets.
144 */
145 QUERYTARGETS_STATE,
146
147 /**
148 * Responses to queries start at this state. This state handles
149 * the decision tree associated with handling responses.
150 */
151 QUERY_RESP_STATE,
152
153 /** Responses to priming queries finish at this state. */
154 PRIME_RESP_STATE,
155
156 /** Collecting query class information, for qclass=ANY, when
157 * it spawns off queries for every class, it returns here. */
158 COLLECT_CLASS_STATE,
159
160 /** Find NS record to resolve DS record from, walking to the right
161 * NS spot until we find it */
162 DSNS_FIND_STATE,
163
164 /** Responses that are to be returned upstream end at this state.
165 * As well as responses to target queries. */
166 FINISHED_STATE
167};
168
169/**
170 * Per query state for the iterator module.
171 */
172struct iter_qstate {
173 /**
174 * State of the iterator module.
175 * This is the state that event is in or should sent to -- all
176 * requests should start with the INIT_REQUEST_STATE. All
177 * responses should start with QUERY_RESP_STATE. Subsequent
178 * processing of the event will change this state.
179 */
180 enum iter_state state;
181
182 /**
183 * Final state for the iterator module.
184 * This is the state that responses should be routed to once the
185 * response is final. For externally initiated queries, this
186 * will be FINISHED_STATE, locally initiated queries will have
187 * different final states.
188 */
189 enum iter_state final_state;
190
191 /**
192 * The depth of this query, this means the depth of recursion.
193 * This address is needed for another query, which is an address
194 * needed for another query, etc. Original client query has depth 0.
195 */
196 int depth;
197
198 /**
199 * The response
200 */
201 struct dns_msg* response;
202
203 /**
204 * This is a list of RRsets that must be prepended to the
205 * ANSWER section of a response before being sent upstream.
206 */
207 struct iter_prep_list* an_prepend_list;
208 /** Last element of the prepend list */
209 struct iter_prep_list* an_prepend_last;
210
211 /**
212 * This is the list of RRsets that must be prepended to the
213 * AUTHORITY section of the response before being sent upstream.
214 */
215 struct iter_prep_list* ns_prepend_list;
216 /** Last element of the authority prepend list */
217 struct iter_prep_list* ns_prepend_last;
218
219 /** query name used for chasing the results. Initially the same as
220 * the state qinfo, but after CNAMEs this will be different.
221 * The query info used to elicit the results needed. */
222 struct query_info qchase;
223 /** query flags to use when chasing the answer (i.e. RD flag) */
224 uint16_t chase_flags;
225 /** true if we set RD bit because of last resort recursion lame query*/
226 int chase_to_rd;
227
228 /**
229 * This is the current delegation point for an in-progress query. This
230 * object retains state as to which delegation targets need to be
231 * (sub)queried for vs which ones have already been visited.
232 */
233 struct delegpt* dp;
234
235 /** state for 0x20 fallback when capsfail happens, 0 not a fallback */
236 int caps_fallback;
237 /** state for capsfail: current server number to try */
238 size_t caps_server;
74/** number of retries on outgoing queries */
75#define OUTBOUND_MSG_RETRY 5
76/** RTT band, within this amount from the best, servers are chosen randomly.
77 * Chosen so that the UNKNOWN_SERVER_NICENESS falls within the band of a
78 * fast server, this causes server exploration as a side benefit. msec. */
79#define RTT_BAND 400
80/** Start value for blacklisting a host, 2*USEFUL_SERVER_TOP_TIMEOUT in sec */
81#define INFRA_BACKOFF_INITIAL 240
82
83/**
84 * Global state for the iterator.
85 */
86struct iter_env {
87 /** A flag to indicate whether or not we have an IPv6 route */
88 int supports_ipv6;
89
90 /** A flag to indicate whether or not we have an IPv4 route */
91 int supports_ipv4;
92
93 /** A set of inetaddrs that should never be queried. */
94 struct iter_donotq* donotq;
95
96 /** private address space and private domains */
97 struct iter_priv* priv;
98
99 /** The maximum dependency depth that this resolver will pursue. */
100 int max_dependency_depth;
101
102 /**
103 * The target fetch policy for each dependency level. This is
104 * described as a simple number (per dependency level):
105 * negative numbers (usually just -1) mean fetch-all,
106 * 0 means only fetch on demand, and
107 * positive numbers mean to fetch at most that many targets.
108 * array of max_dependency_depth+1 size.
109 */
110 int* target_fetch_policy;
111};
112
113/**
114 * State of the iterator for a query.
115 */
116enum iter_state {
117 /**
118 * Externally generated queries start at this state. Query restarts are
119 * reset to this state.
120 */
121 INIT_REQUEST_STATE = 0,
122
123 /**
124 * Root priming events reactivate here, most other events pass
125 * through this naturally as the 2nd part of the INIT_REQUEST_STATE.
126 */
127 INIT_REQUEST_2_STATE,
128
129 /**
130 * Stub priming events reactivate here, most other events pass
131 * through this naturally as the 3rd part of the INIT_REQUEST_STATE.
132 */
133 INIT_REQUEST_3_STATE,
134
135 /**
136 * Each time a delegation point changes for a given query or a
137 * query times out and/or wakes up, this state is (re)visited.
138 * This state is reponsible for iterating through a list of
139 * nameserver targets.
140 */
141 QUERYTARGETS_STATE,
142
143 /**
144 * Responses to queries start at this state. This state handles
145 * the decision tree associated with handling responses.
146 */
147 QUERY_RESP_STATE,
148
149 /** Responses to priming queries finish at this state. */
150 PRIME_RESP_STATE,
151
152 /** Collecting query class information, for qclass=ANY, when
153 * it spawns off queries for every class, it returns here. */
154 COLLECT_CLASS_STATE,
155
156 /** Find NS record to resolve DS record from, walking to the right
157 * NS spot until we find it */
158 DSNS_FIND_STATE,
159
160 /** Responses that are to be returned upstream end at this state.
161 * As well as responses to target queries. */
162 FINISHED_STATE
163};
164
165/**
166 * Per query state for the iterator module.
167 */
168struct iter_qstate {
169 /**
170 * State of the iterator module.
171 * This is the state that event is in or should sent to -- all
172 * requests should start with the INIT_REQUEST_STATE. All
173 * responses should start with QUERY_RESP_STATE. Subsequent
174 * processing of the event will change this state.
175 */
176 enum iter_state state;
177
178 /**
179 * Final state for the iterator module.
180 * This is the state that responses should be routed to once the
181 * response is final. For externally initiated queries, this
182 * will be FINISHED_STATE, locally initiated queries will have
183 * different final states.
184 */
185 enum iter_state final_state;
186
187 /**
188 * The depth of this query, this means the depth of recursion.
189 * This address is needed for another query, which is an address
190 * needed for another query, etc. Original client query has depth 0.
191 */
192 int depth;
193
194 /**
195 * The response
196 */
197 struct dns_msg* response;
198
199 /**
200 * This is a list of RRsets that must be prepended to the
201 * ANSWER section of a response before being sent upstream.
202 */
203 struct iter_prep_list* an_prepend_list;
204 /** Last element of the prepend list */
205 struct iter_prep_list* an_prepend_last;
206
207 /**
208 * This is the list of RRsets that must be prepended to the
209 * AUTHORITY section of the response before being sent upstream.
210 */
211 struct iter_prep_list* ns_prepend_list;
212 /** Last element of the authority prepend list */
213 struct iter_prep_list* ns_prepend_last;
214
215 /** query name used for chasing the results. Initially the same as
216 * the state qinfo, but after CNAMEs this will be different.
217 * The query info used to elicit the results needed. */
218 struct query_info qchase;
219 /** query flags to use when chasing the answer (i.e. RD flag) */
220 uint16_t chase_flags;
221 /** true if we set RD bit because of last resort recursion lame query*/
222 int chase_to_rd;
223
224 /**
225 * This is the current delegation point for an in-progress query. This
226 * object retains state as to which delegation targets need to be
227 * (sub)queried for vs which ones have already been visited.
228 */
229 struct delegpt* dp;
230
231 /** state for 0x20 fallback when capsfail happens, 0 not a fallback */
232 int caps_fallback;
233 /** state for capsfail: current server number to try */
234 size_t caps_server;
239 /** state for capsfail: stored query for comparisons */
235 /** state for capsfail: stored query for comparisons. Can be NULL if
236 * no response had been seen prior to starting the fallback. */
240 struct reply_info* caps_reply;
241
242 /** Current delegation message - returned for non-RD queries */
243 struct dns_msg* deleg_msg;
244
245 /** number of outstanding target sub queries */
246 int num_target_queries;
247
248 /** outstanding direct queries */
249 int num_current_queries;
250
251 /** the number of times this query has been restarted. */
252 int query_restart_count;
253
254 /** the number of times this query as followed a referral. */
255 int referral_count;
256
257 /** number of queries fired off */
258 int sent_count;
259
260 /** number of target queries spawned in [1], for this query and its
261 * subqueries, the malloced-array is shared, [0] refcount. */
262 int* target_count;
263
264 /**
265 * The query must store NS records from referrals as parentside RRs
266 * Enabled once it hits resolution problems, to throttle retries.
267 * If enabled it is the pointer to the old delegation point with
268 * the old retry counts for bad-nameserver-addresses.
269 */
270 struct delegpt* store_parent_NS;
271
272 /**
273 * The query is for parent-side glue(A or AAAA) for a nameserver.
274 * If the item is seen as glue in a referral, and pside_glue is NULL,
275 * then it is stored in pside_glue for later.
276 * If it was never seen, at the end, then a negative caching element
277 * must be created.
278 * The (data or negative) RR cache element then throttles retries.
279 */
280 int query_for_pside_glue;
281 /** the parent-side-glue element (NULL if none, its first match) */
282 struct ub_packed_rrset_key* pside_glue;
283
284 /** If nonNULL we are walking upwards from DS query to find NS */
285 uint8_t* dsns_point;
286 /** length of the dname in dsns_point */
287 size_t dsns_point_len;
288
289 /**
290 * expected dnssec information for this iteration step.
291 * If dnssec rrsigs are expected and not given, the server is marked
292 * lame (dnssec-lame).
293 */
294 int dnssec_expected;
295
296 /**
297 * We are expecting dnssec information, but we also know the server
298 * is DNSSEC lame. The response need not be marked dnssec-lame again.
299 */
300 int dnssec_lame_query;
301
302 /**
303 * This is flag that, if true, means that this event is
304 * waiting for a stub priming query.
305 */
306 int wait_priming_stub;
307
308 /**
309 * This is a flag that, if true, means that this query is
310 * for (re)fetching glue from a zone. Since the address should
311 * have been glue, query again to the servers that should have
312 * been returning it as glue.
313 * The delegation point must be set to the one that should *not*
314 * be used when creating the state. A higher one will be attempted.
315 */
316 int refetch_glue;
317
318 /** list of pending queries to authoritative servers. */
319 struct outbound_list outlist;
320};
321
322/**
323 * List of prepend items
324 */
325struct iter_prep_list {
326 /** next in list */
327 struct iter_prep_list* next;
328 /** rrset */
329 struct ub_packed_rrset_key* rrset;
330};
331
332/**
333 * Get the iterator function block.
334 * @return: function block with function pointers to iterator methods.
335 */
336struct module_func_block* iter_get_funcblock(void);
337
338/**
339 * Get iterator state as a string
340 * @param state: to convert
341 * @return constant string that is printable.
342 */
343const char* iter_state_to_string(enum iter_state state);
344
345/**
346 * See if iterator state is a response state
347 * @param s: to inspect
348 * @return true if response state.
349 */
350int iter_state_is_responsestate(enum iter_state s);
351
352/** iterator init */
353int iter_init(struct module_env* env, int id);
354
355/** iterator deinit */
356void iter_deinit(struct module_env* env, int id);
357
358/** iterator operate on a query */
359void iter_operate(struct module_qstate* qstate, enum module_ev event, int id,
360 struct outbound_entry* outbound);
361
362/**
363 * Return priming query results to interestes super querystates.
364 *
365 * Sets the delegation point and delegation message (not nonRD queries).
366 * This is a callback from walk_supers.
367 *
368 * @param qstate: query state that finished.
369 * @param id: module id.
370 * @param super: the qstate to inform.
371 */
372void iter_inform_super(struct module_qstate* qstate, int id,
373 struct module_qstate* super);
374
375/** iterator cleanup query state */
376void iter_clear(struct module_qstate* qstate, int id);
377
378/** iterator alloc size routine */
379size_t iter_get_mem(struct module_env* env, int id);
380
381#endif /* ITERATOR_ITERATOR_H */
237 struct reply_info* caps_reply;
238
239 /** Current delegation message - returned for non-RD queries */
240 struct dns_msg* deleg_msg;
241
242 /** number of outstanding target sub queries */
243 int num_target_queries;
244
245 /** outstanding direct queries */
246 int num_current_queries;
247
248 /** the number of times this query has been restarted. */
249 int query_restart_count;
250
251 /** the number of times this query as followed a referral. */
252 int referral_count;
253
254 /** number of queries fired off */
255 int sent_count;
256
257 /** number of target queries spawned in [1], for this query and its
258 * subqueries, the malloced-array is shared, [0] refcount. */
259 int* target_count;
260
261 /**
262 * The query must store NS records from referrals as parentside RRs
263 * Enabled once it hits resolution problems, to throttle retries.
264 * If enabled it is the pointer to the old delegation point with
265 * the old retry counts for bad-nameserver-addresses.
266 */
267 struct delegpt* store_parent_NS;
268
269 /**
270 * The query is for parent-side glue(A or AAAA) for a nameserver.
271 * If the item is seen as glue in a referral, and pside_glue is NULL,
272 * then it is stored in pside_glue for later.
273 * If it was never seen, at the end, then a negative caching element
274 * must be created.
275 * The (data or negative) RR cache element then throttles retries.
276 */
277 int query_for_pside_glue;
278 /** the parent-side-glue element (NULL if none, its first match) */
279 struct ub_packed_rrset_key* pside_glue;
280
281 /** If nonNULL we are walking upwards from DS query to find NS */
282 uint8_t* dsns_point;
283 /** length of the dname in dsns_point */
284 size_t dsns_point_len;
285
286 /**
287 * expected dnssec information for this iteration step.
288 * If dnssec rrsigs are expected and not given, the server is marked
289 * lame (dnssec-lame).
290 */
291 int dnssec_expected;
292
293 /**
294 * We are expecting dnssec information, but we also know the server
295 * is DNSSEC lame. The response need not be marked dnssec-lame again.
296 */
297 int dnssec_lame_query;
298
299 /**
300 * This is flag that, if true, means that this event is
301 * waiting for a stub priming query.
302 */
303 int wait_priming_stub;
304
305 /**
306 * This is a flag that, if true, means that this query is
307 * for (re)fetching glue from a zone. Since the address should
308 * have been glue, query again to the servers that should have
309 * been returning it as glue.
310 * The delegation point must be set to the one that should *not*
311 * be used when creating the state. A higher one will be attempted.
312 */
313 int refetch_glue;
314
315 /** list of pending queries to authoritative servers. */
316 struct outbound_list outlist;
317};
318
319/**
320 * List of prepend items
321 */
322struct iter_prep_list {
323 /** next in list */
324 struct iter_prep_list* next;
325 /** rrset */
326 struct ub_packed_rrset_key* rrset;
327};
328
329/**
330 * Get the iterator function block.
331 * @return: function block with function pointers to iterator methods.
332 */
333struct module_func_block* iter_get_funcblock(void);
334
335/**
336 * Get iterator state as a string
337 * @param state: to convert
338 * @return constant string that is printable.
339 */
340const char* iter_state_to_string(enum iter_state state);
341
342/**
343 * See if iterator state is a response state
344 * @param s: to inspect
345 * @return true if response state.
346 */
347int iter_state_is_responsestate(enum iter_state s);
348
349/** iterator init */
350int iter_init(struct module_env* env, int id);
351
352/** iterator deinit */
353void iter_deinit(struct module_env* env, int id);
354
355/** iterator operate on a query */
356void iter_operate(struct module_qstate* qstate, enum module_ev event, int id,
357 struct outbound_entry* outbound);
358
359/**
360 * Return priming query results to interestes super querystates.
361 *
362 * Sets the delegation point and delegation message (not nonRD queries).
363 * This is a callback from walk_supers.
364 *
365 * @param qstate: query state that finished.
366 * @param id: module id.
367 * @param super: the qstate to inform.
368 */
369void iter_inform_super(struct module_qstate* qstate, int id,
370 struct module_qstate* super);
371
372/** iterator cleanup query state */
373void iter_clear(struct module_qstate* qstate, int id);
374
375/** iterator alloc size routine */
376size_t iter_get_mem(struct module_env* env, int id);
377
378#endif /* ITERATOR_ITERATOR_H */