Deleted Added
sdiff udiff text old ( 256281 ) new ( 269257 )
full compact
1/*
2 * services/mesh.h - deal with mesh of query states and handle events for that.
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

--- 7 unchanged lines hidden (view full) ---

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 LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36/**
37 * \file
38 *
39 * This file contains functions to assist in dealing with a mesh of
40 * query states. This mesh is supposed to be thread-specific.
41 * It consists of query states (per qname, qtype, qclass) and connections

--- 4 unchanged lines hidden (view full) ---

46#ifndef SERVICES_MESH_H
47#define SERVICES_MESH_H
48
49#include "util/rbtree.h"
50#include "util/netevent.h"
51#include "util/data/msgparse.h"
52#include "util/module.h"
53#include "services/modstack.h"
54struct mesh_state;
55struct mesh_reply;
56struct mesh_cb;
57struct query_info;
58struct reply_info;
59struct outbound_entry;
60struct timehist;
61

--- 58 unchanged lines hidden (view full) ---

120 size_t ans_bogus;
121 /** (extended stats) rcodes in replies */
122 size_t ans_rcode[16];
123 /** (extended stats) rcode nodata in replies */
124 size_t ans_nodata;
125
126 /** backup of query if other operations recurse and need the
127 * network buffers */
128 ldns_buffer* qbuf_bak;
129
130 /** double linked list of the run-to-completion query states.
131 * These are query states with a reply */
132 struct mesh_state* forever_first;
133 /** last entry in run forever list */
134 struct mesh_state* forever_last;
135
136 /** double linked list of the query states that can be jostled out

--- 77 unchanged lines hidden (view full) ---

214 /** qname from this query. len same as mesh qinfo. */
215 uint8_t* qname;
216};
217
218/**
219 * Mesh result callback func.
220 * called as func(cb_arg, rcode, buffer_with_reply, security, why_bogus);
221 */
222typedef void (*mesh_cb_func_t)(void*, int, ldns_buffer*, enum sec_status,
223 char*);
224
225/**
226 * Callback to result routine
227 */
228struct mesh_cb {
229 /** next in list */
230 struct mesh_cb* next;
231 /** edns data from query */
232 struct edns_data edns;
233 /** id of query, in network byteorder. */
234 uint16_t qid;
235 /** flags of query, for reply flags */
236 uint16_t qflags;
237 /** buffer for reply */
238 ldns_buffer* buf;
239
240 /** callback routine for results. if rcode != 0 buf has message.
241 * called as cb(cb_arg, rcode, buf, sec_state);
242 */
243 mesh_cb_func_t cb;
244 /** user arg for callback */
245 void* cb_arg;
246};

--- 42 unchanged lines hidden (view full) ---

289 * @param edns: edns data from client query.
290 * @param buf: buffer for reply contents.
291 * @param qid: query id to reply with.
292 * @param cb: callback function.
293 * @param cb_arg: callback user arg.
294 * @return 0 on error.
295 */
296int mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
297 uint16_t qflags, struct edns_data* edns, ldns_buffer* buf,
298 uint16_t qid, mesh_cb_func_t cb, void* cb_arg);
299
300/**
301 * New prefetch message. Create new query state if needed.
302 * Will run the mesh area queries to process if a new query state is created.
303 *
304 * @param mesh: the mesh.
305 * @param qinfo: query from client.
306 * @param qflags: flags from client query.
307 * @param leeway: TTL leeway what to expire earlier for this update.
308 */
309void mesh_new_prefetch(struct mesh_area* mesh, struct query_info* qinfo,
310 uint16_t qflags, uint32_t leeway);
311
312/**
313 * Handle new event from the wire. A serviced query has returned.
314 * The query state will be made runnable, and the mesh_area will process
315 * query states until processing is complete.
316 *
317 * @param mesh: the query mesh.
318 * @param e: outbound entry, with query state to run and reply pointer.

--- 149 unchanged lines hidden (view full) ---

468 * @param buf: buffer for reply
469 * @param cb: callback to call with results.
470 * @param cb_arg: callback user arg.
471 * @param qid: ID of reply.
472 * @param qflags: original query flags.
473 * @return: 0 on alloc error.
474 */
475int mesh_state_add_cb(struct mesh_state* s, struct edns_data* edns,
476 ldns_buffer* buf, mesh_cb_func_t cb, void* cb_arg, uint16_t qid,
477 uint16_t qflags);
478
479/**
480 * Run the mesh. Run all runnable mesh states. Which can create new
481 * runnable mesh states. Until completion. Automatically called by
482 * mesh_report_reply and mesh_new_client as needed.
483 * @param mesh: mesh area.
484 * @param mstate: first mesh state to run.

--- 58 unchanged lines hidden (view full) ---

543 * This buffer is necessary, because the following sequence in calls
544 * can result in an overwrite of the incoming query:
545 * delete_other_mesh_query - iter_clean - serviced_delete - waiting
546 * udp query is sent - on error callback - callback sends SERVFAIL reply
547 * over the same network channel, and shared UDP buffer is overwritten.
548 * You can pass NULL if there is no buffer that must be backed up.
549 * @return false if no space is available.
550 */
551int mesh_make_new_space(struct mesh_area* mesh, ldns_buffer* qbuf);
552
553/**
554 * Insert mesh state into a double linked list. Inserted at end.
555 * @param m: mesh state.
556 * @param fp: pointer to the first-elem-pointer of the list.
557 * @param lp: pointer to the last-elem-pointer of the list.
558 */
559void mesh_list_insert(struct mesh_state* m, struct mesh_state** fp,

--- 12 unchanged lines hidden ---